ATR STOP AND ATR TARGET
Forums › ProRealTime English forum › ProOrder support › ATR STOP AND ATR TARGET
- This topic has 6 replies, 3 voices, and was last updated 7 years ago by robdav.
-
-
10/27/2016 at 10:00 AM #15612
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;
123456789101112131415161718192021222324DEFPARAM CumulateOrders = False // Cumulating positions deactivatedcond1 = Xcond2 = Xlongconditions = cond1 and cond2//Entry levelentrylevel = Close - 0.5*AverageTrueRange[10](close)IF NOT LongOnMarket AND longConditions THENBUY 60000 cash AT entrylevel limitENDIF//Reset Target / stopIF NOT ONMARKET THENatrstop= 0atrtarget= 0endif// ATR Stops and targetsIF LONGONMARKET THENatrstop = atrlimit - (5* AverageTrueRange[10](CLOSE)) (ALSO Tested without +/- and atrlimit)atrtarget = atrlimit +(2* AverageTrueRange[10](CLOSE))Endif// STOP AND TARGETSET STOP LOSS atrstopSET TARGET PROFIT atrtargetBest regards
Johan
10/27/2016 at 10:23 AM #15615>> 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:
1graph atrstop as "my atr stop"10/27/2016 at 11:51 AM #1562610/27/2016 at 12:31 PM #1563110/27/2016 at 12:57 PM #1563610/27/2016 at 2:50 PM #1563909/16/2017 at 10:36 AM #46343 -
AuthorPosts
Find exclusive trading pro-tools on