Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. DefineCommand ('WaveTrend', 'WaveTrend')
  2.  
  3. -- Define command parameters.
  4. local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 1, 'Number')
  5. local name = DefineParameter(StringType, 'name', 'Unique name of the indicator.', false, '', 'Text')
  6. local interval = DefineParameter(NumberType, 'interval', 'Used interval for price data. Default is 0 and the main interval will be used.', false, 0, 'Number,InputInterval')
  7.  
  8. local n1 = Input("Channel Length", 10)
  9. local n2 = Input("Average Length", 21)
  10. local obLevel1 = Input("Over Bought Level 1", 60)
  11. local obLevel2 = Input("Over Bought Level 2", 53)
  12. local osLevel1 = Input("Over Sold Level 1", -60)
  13. local osLevel2 = Input("Over Sold Level 2", -53)
  14.  
  15. OptimizedForInterval(CurrentInterval(), function()
  16. local ap = HLCPrices()
  17. local esa = EMA(ap, n1)
  18. local d = EMA(Abs(ap - esa), n1)
  19. local ci = (ap - esa) / (0.015 * d)
  20. local tci = EMA(ci, n2)
  21.  
  22. local wt1 = tci
  23. local wt2 = SMA(wt1,4)
  24.  
  25. local color1 = SkyBlue
  26. local color2 = Blue
  27. local l1 = Plot(1, "WT1", wt1, color1)
  28. local l2 = Plot(1, "WT2", wt2, color2)
  29. PlotDoubleColor(l1, 0, color1)
  30. PlotDoubleColor(l2, 0, color2)
  31.  
  32. local histo = Plot(1, "Histogram", wt1-wt2, Yellow)
  33. PlotHistogram(histo, Yellow, false)
  34.  
  35. PlotHorizontalLine(1, "Zero", Gray, 0)
  36. PlotHorizontalLine(1, "OB1", Red, obLevel1)
  37. PlotHorizontalLine(1, "OS1", Green, osLevel1)
  38. PlotHorizontalLine(1, "OB2", Red, obLevel2)
  39. PlotHorizontalLine(1, "OS2", Green, osLevel2)
  40. end)
  41.  
  42. -- Determine the signal.
  43. local signal = GetBuySellLevelSignal(n1, osLevel2, osLevel2)
  44.  
  45. DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, IndicatorContainer, Signal Helpers')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement