need help make a value that backtesing can use

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #240543 quote
    Patrick K Templar
    Participant
    Average

    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 
    #240549 quote
    JS
    Participant
    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…

    Iván González thanked this post
    #240563 quote
    Iván González
    Moderator
    Master
    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) 
    
    Patrick K Templar thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

need help make a value that backtesing can use


ProBuilder: Indicators & Custom Tools

New Reply
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Iván González
1 year, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/19/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...