WaveTrendCrossV2 signals on cross when above below OB OS levels, and plots on chart

stable
By Kobalt in Trend Published July 2021 👁 1,263 views 💬 0 comments

Description

While clearing out my library saw multiple versions of this one, none of them finished, so made a start. removing the rest (default plotting to index1 and not making the parameter is bound to make a mess but you do catch on after a while, perhaps a case of persistence luck..) Just needed to fill in the blanks! Beautified the histogram, and added the nicest most functional plotting to date, for testing purposes,. This is still work in progress, but can't take on every half finished , let alone if not my own.. Need to get back to deleting, already removed over 600, still killing it.. The signal logic could use an input options because in down/up trend the crosses when not OB OS are still the tops and bottoms As seen in plots for signal used OBS levels 1 made these the inner levels OBS2 the outer more OB OS thresholds so could add verystrongcbuy cross and below os2 , verystrongcsell cross and above ob2 etc
HaasScript
DefineCommand ('WaveTrendCrossV2', 'WaveTrendCross v2: Specified Input Group, added InputInterval, index(defaults to 11) and ordered items. -Other Settings- No more!' )
 
-- Define command parameters.
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'index to plot WaveTrendCross', true, 11, 'Number')
local name = DefineParameter(StringType, 'name', 'Unique name of the indicator.', false, 'WaveTrendCross', 'Text')
local interval = DefineParameter(NumberType, 'interval', 'Used interval for price data. Default is 0 and the main interval will be used.', false, 0, 'Number,InputInterval')


-- Input fields for the indicator.
InputGroupHeader(''..name..' Settings')
local interval = InputInterval("     Interval", 0, {group = "Wave Trend Cross Settings"}) 
local n1 = Input("    Channel Length", 10, {group = "Wave Trend Cross Settings"}) 
local n2 = Input("    Average Length", 21, {group = "Wave Trend Cross Settings"}) 
local obLevel1 = Input("Over Bought Level 1", 53, {group = "Wave Trend Cross Settings"}) 
local obLevel2 = Input(" Over Bought Level 2", 60, {group = "Wave Trend Cross Settings"}) 
local osLevel1 = Input("Over Sold Level 1", -53, {group = "Wave Trend Cross Settings"}) 
local osLevel2 = Input("Over Sold Level 2", -60, {group = "Wave Trend Cross Settings"}) 
 
-- Speed optimization
DefineIntervalOptimization(interval)
 
    local ap = HLCPrices()
    local esa = EMA(ap, n1)
    local d = EMA(Abs(ap - esa), n1)
    local ci = (ap - esa) / (0.015 * d)
    local tci = EMA(ci, n2)
   
    local wt1 = tci
    local wt2 = SMA(wt1,4)
 
    local color1 = SkyBlue
    local color2 = Fuchsia
    local l1 = Plot(1, "WT1", wt1, color1)
    local l2 = Plot(1, "WT2", wt2, color2)
    PlotDoubleColor(l1, 0, color1)
    PlotDoubleColor(l2, 0, color2)
 
    local histo = Plot(1, "Histogram", wt1-wt2, Olive)
    PlotHistogram(histo, Orange, true)
 
    PlotHorizontalLine(1, "Zero", DarkGray, 0)
    PlotHorizontalLine(1, "OB1", Red(60), obLevel1)
    PlotHorizontalLine(1, "OS1", Green(60), osLevel1)
    PlotHorizontalLine(1, "OB2", Red, obLevel2)
    PlotHorizontalLine(1, "OS2", Green, osLevel2)

-- Caculate Buy & Sell Signal.
 
local cbuy = CrossOver(wt1, wt2) 
if cbuy then
PlotShape(0, ShapeCircle, Olive, 4, false)
end
local csell = CrossUnder(wt1, wt2)
if csell then 
PlotShape(0, ShapeCircle, Orange, 4, true)
end
local strongcbuy = cbuy and wt1 or wt2 < osLevel1
local strongcsell = cbuy and wt1 or wt2 > obLevel1
local signal = SignalNone
 
if strongcbuy then
    signal = SignalLong
   -- if strongcbuy then
PlotShape(0, ShapeCircle, Teal, 5, false)
elseif strongcsell then
    signal = SignalShort
  --  if strongcsell then
PlotShape(0, ShapeCircle, Fuchsia, 5, true)
end
 
DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, IndicatorContainer, Signal Helpers')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!