I’ve used this indicator or made this indicator for back testing but the issue I’m having is that the back testing won’t recognise the horizontal lines so basically price goes through it I want it to sell it’s visually visually being represent on the screen but doesn’t seem to have any value to it if you could please help me thank you very much
// NNFX ATR Band Script
atrLength = 14
atrProfit = 1.5
atrLoss = 1
// Calculate ATR
atr = averagetruerange[atrLength]
// Buy Stop-Loss and Take-Profit Levels
bAtrBuy = close[1] + atr * atrProfit // Buy Take-Profit
bAtrSell = close[1] - atr * atrLoss // Buy Stop-Loss
// Sell Stop-Loss and Take-Profit Levels
sAtrBuy = close[1] - atr * atrProfit // Sell Take-Profit
sAtrSell = close[1] + atr * atrLoss // Sell Stop-Loss
// Example condition: Indicator crosses under
indicator1 = CALL "STIPH10"[1, 10] // use ma
condition = close CROSSES over indicator1
condition = close CROSSES under indicator1
// Draw horizontal lines only when the condition is met
if condition then
// Draw horizontal lines for Buy Stop-Loss and Take-Profit
drawsegment(barindex + 15, bAtrBuy, barindex, bAtrBuy) coloured(0, 0, 255) // Blue for Buy TP
drawsegment(barindex + 15, bAtrSell, barindex, bAtrSell) coloured(255, 0, 0) // Red for Buy SL
// Draw horizontal lines for Sell Stop-Loss and Take-Profit
drawsegment(barindex + 15, sAtrBuy, barindex, sAtrBuy) coloured(0, 0, 255) // Blue for Sell TP
drawsegment(barindex + 15, sAtrSell, barindex, sAtrSell) coloured(255, 0, 0) // Red for Sell SL
endif
// Return ATR for visualization/debugging
return
JSParticipant
Senior
If you make this indicator part of your trading system and replace all the graphical elements, such as “draw segment”, with what you want there, for example a “Take Profit” (Set Target Price x) or a “Stop Loss”, then your code will execute what you see on the screen…
Also if you want to see these levels you can type at the end of the code this:
// Draw horizontal lines for Buy Stop-Loss and Take-Profit
graphonprice bAtrBuy coloured(0,0,255)
graphonprice bAtrSell coloured(255,0,0)