ATR STOP AND ATR TARGET

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15612 quote
    tattbytattby
    Participant
    Average

    Dear all, I have tested all kind of coding regarding the ATR stop and ATR limit without success. I have follwoed earlier forum discussions but it wont work. I show my code and would appreciate if someone could comment!

    This is for backtesting;

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    cond1 = X
    cond2 = X
    longconditions = cond1 and cond2
    //Entry level
    entrylevel = Close - 0.5*AverageTrueRange[10](close)
    IF NOT LongOnMarket AND longConditions THEN
    BUY 60000 cash AT entrylevel limit
    ENDIF
    
    //Reset Target / stop
    IF NOT ONMARKET THEN
    atrstop= 0
    atrtarget= 0
    endif
    // ATR Stops and targets
    IF LONGONMARKET THEN
    atrstop = atrlimit - (5* AverageTrueRange[10](CLOSE))        (ALSO Tested without +/- and atrlimit)
    atrtarget = atrlimit +(2* AverageTrueRange[10](CLOSE))
    Endif
    
    // STOP AND TARGET
    SET STOP LOSS atrstop
    SET TARGET PROFIT atrtarget

     

    Best regards

    Johan

    #15615 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    >> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<

    Hi,

    Unless I’ve read too fast, first thing that comes to mind is: your atrlimit is not defined, so your atrstop in line 18 is probably either not defined, or if atrlimit=0 your atrstop is either negative or equal to zero (when you test without the -(5*…)), in any case it wouldn’t work without a positive value for the stop amount “atrstop”

    Best way to find out what happens when debugging personal code is to use the “graph” command at the end of your backtest code. It will open an extra window displaying all values asked by a “graph” line (up to 5 values at the same time last time I checked). For example:

    graph atrstop as "my atr stop"
    #15626 quote
    tattbytattby
    Participant
    Average

    Hi

     

    Nothing comes up when I write the graph command.

    #15631 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    By “nothing”, do you mean there ‘s no graph window opened when adding any graph line at the end of your backtest code? Or do you mean there is a graph window, but you don’t see an atrstop line in the window?

    #15636 quote
    tattbytattby
    Participant
    Average

    Sorry, yes no window comes up

    #15639 quote
    tattbytattby
    Participant
    Average

    It didn’t work, but I solved my coding. Thanks anyway

    #46343 quote
    robdavrobdav
    Participant
    Veteran

    Hi,

    Would you be willing to share your fixed code?

    Thanks

    Rob

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

ATR STOP AND ATR TARGET


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
tattby @tattby Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by robdavrobdav
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/27/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...