Algo not exiting trade on sell signal
Forums › ProRealTime English forum › ProOrder support › Algo not exiting trade on sell signal
- This topic has 12 replies, 4 voices, and was last updated 3 years ago by Vonasi.
-
-
11/20/2020 at 10:37 PM #151100
Hello folks,
Here’s my code:
1234567891011121314151617181920212223242526272829303132DEFPARAM CumulateOrders = False//dynamic position sizingINITIALCAPITAL = 10000d = (INITIALCAPITAL/close)if d < 0.2 thend = 0.2endif//end dynamic position sizingindicator1 = SAR[0.3,0.3,0.1]c1 = (close > indicator1)indicator2 = RSI[4](close)c2 = (indicator2 < 80)c3 = (close >= open)indicator3 = AroonUp[15]c4 = (indicator3 > 5)IF c1 AND c2 AND c3 AND c4 THENBUY d PERPOINT AT MARKETENDIFindicator4 = SAR[0.3,0.1,0.1]c5 = (indicator4 > close)indicator5 = RSI[4](close)c6 = (indicator5 > 80)set stop $loss 800IF c5 OR c6 THENSELL AT MARKETENDIFAs you can see, one of the sell rules is:
12indicator4 = SAR[0.3,0.1,0.1]c5 = (indicator4 > close)However, once these conditions where satisfied last night, the algo did not exit my trade. What am I missing?
I’ve looked over my code five times and I’m starting to think I’m going crazy. I’d appreciate any help.
Thanks,
Aleks
11/20/2020 at 11:55 PM #151106In your chart I can’t see where it was supposed to exit.
Append
12GRAPH c5GRAPH c6then, after backtesting, check the variables’window to see what value they retain candle by candle. If their value is not, then conditions are not met.
11/21/2020 at 3:17 AM #15111211/21/2020 at 9:05 AM #151114Your pic shows that on the bar where your mouse is sitting there were no trades open!
11/21/2020 at 7:59 PM #15116711/21/2020 at 8:41 PM #15116811/21/2020 at 8:51 PM #15116911/21/2020 at 8:53 PM #15117011/21/2020 at 9:26 PM #151171Anyway your condition c5 = (indicator4 > close) occurs on the bar marked with the red arrows on attached and so the Sell will occur at the open of the next bar … as indeed it does??
Or maybe you just haven’t shown any more bars??
Forgive my brusque comment in my previous post … I have one eye on the tv and I’ve had a beer! 🙂
11/21/2020 at 9:41 PM #151174The GRAPH shows that C5 was true at the close of the second to last bar so the trade should be closed at the open of the last bar shown on the chart. I think we will not see the true backtest actions until this latest bar is actually closed and the backtest engine can see what trading actions would have occurred in that last bar. It is a back test and not live trading and actions are not real time.
I’ve not been back testing for a while so might be a bit rusty and talking rubbish though!
1 user thanked author for this post.
11/21/2020 at 9:46 PM #151175Hi GraHal,
Thanks for your answer. All good- personally I’m nursing quite a hard hangover from yesterday, so my English might not be as clear as I’d like it to be. I apologise for any miscommunication.
In my last screenshot, my cursor hides the first red dot that appeared on the 19th of November. The trade should’ve been closed on the opening of the 20th of November.
I thought I might also add that this system was actually live while these trades where on, and I thought that the system would’ve exited me out of my trade in real time?
Thanks,
Aleks
1 user thanked author for this post.
11/21/2020 at 10:02 PM #151178Try using this as line 30:
1IF c5 <> 0 OR c6 <> 0 THENit’s the same as the original one but… never say never!
11/21/2020 at 10:08 PM #151179 -
AuthorPosts
Find exclusive trading pro-tools on