Did you get a solution?
Welcome to the BEST forum for traders
Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".
Did you get a solution?
Hi,
I'm Dan, new to TradingView and new to coding, so I need your help right away. ;-)
I started building a strategy that basically consists of a publicly available indicator and a strategy:
• FLD's - Future Lines of Demarcation by HPotter
• Bollinger Bands Strategy
Aim of the strategy:
1).
srcand not
FLD) has crossed the upper Bollinger Band from bottom to top, and b. generate a sell signal when the actual price has crossed the lower Bollinger band from top to bottom.
By and large, the script stands, but it does not deliver any signals (Caution! This strategy did not generate any orders throughout the testing range.
), although I think the Nasdaq-100 (NDX) should provide enough signals.
Here is my current draft of the script:
//@version=5
strategy(title='FLD with Bollinger Bands', overlay=true)
src = input(title='Source', defval=hlcc4)
FLD = src
Period = input(title='Offset FLD', defval=40)
offset = Period
length = input.int(title=SMA BB
, minval=1, defval=20)
mult = input.float(title=StDev BB
, minval=0.001, maxval=10, defval=1.05)
//reverse = input(false, title='Trade reverse') //(Probably not needed.)
//basis = ta.sma(FLD, length) //(This code generates signals, but wrong ones.)
dev = mult * ta.stdev(src, length)
//upper = basis + dev //(This code generates signals, but wrong ones.)
upper = FLD + dev
//lower = basis - dev //(This code generates signals, but wrong ones.)
lower = FLD - dev
// Entry und Exit
buyEntry = ta.crossover(src, upper)
sellEntry = ta.crossunder(src, lower)
if (buyEntry)
strategy.entry(buyEntry
, strategy.long, comment=buy
)
else
strategy.cancel(id=buyEntry
)
if (sellEntry)
strategy.entry(sellEntry
, strategy.short, comment=sell
)
else
strategy.cancel(id=sellEntry
)
// Plotting
p1 = plot(upper, Upper
, color=#2962FF, offset = offset)
p2 = plot(lower, Lower
, color=#2962FF, offset = offset)
fill(p1, p2, title = Background
, color=color.rgb(33, 150, 243, 95))
plot(FLD, title=FLD
, color=color.new(color.orange, 10), linewidth=1, style=plot.style_line, offset = Period)
//plotshape(buyEntry, title='buyEntry', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), text='Buy', textcolor=color.new(color.black, 0), size=size.tiny)
//plotshape(sellEntry, title='sellEntry', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), text='Sell', textcolor=color.new(color.black, 0), size=size.tiny)
May I ask you to check the script and hopefully correct it?
Thank you in advance for your help!