Strategy get stucks with ProBacktest with both long and short orders
Forums › ProRealTime English forum › ProOrder support › Strategy get stucks with ProBacktest with both long and short orders
- This topic has 6 replies, 3 voices, and was last updated 7 years ago by
maximus78.
-
-
02/22/2018 at 1:51 PM #63518
Good Morning guys,
I need some help for the following simple strategy.
Basically if i use the strategies in separated long and short versions, probacktest works fine, but if I use them together in this way probacktests start to calculate and gets stuck.
Could someone help me and show me if I make some mistakes?
Thanks a lot in advance.
Max
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647defparam cumulateorders=false// LONG STRATEGYbarlimit =10c1=low[2]>low[1] and low[0]>low[1] and average[10](close)>average[24](close)if not longonmarket and c1 thenentrylong=highest[1](high)+2*pointsizemyindex=barindexSLlong=entrylong-(lowest[2](low)-2*pointsize)endifif barindex>=myindex + barlimit thenentrylong =0endifif entrylong>0 and not longonmarket thenBUY 1 shares at entrylong stopset stop loss SLlong trailing SLlongendif//-----------------------------------------------// SHORT STRATEGYbarlimit =10c2=high[2]<high[1] and high[0]<high[1] and average[10](close)<average[24](close)if not shortonmarket and c2 thenentryshort=lowest[1](low)-2*pointsizemyindex=barindexSLshort=(highest[2](high)+2*pointsize)-entryshortendifif barindex>=myindex + barlimit thenentryshort =0endifif entryshort>0 and not shortonmarket thensellshort 1 shares at entryshort stopset stop loss SLshort trailing SLshortendifgraph entrylong as "entry long"graph entryshort as "entry short"graph entrylong-SLlong as "stop loss long"graph entryshort+SLshort as "stop loss short"02/22/2018 at 2:18 PM #63520You should name your variable differently for short and long side of the strategy. For example ‘myindex’ is used in both sides and could generate problem when you compare it with barindex at lines 14 and 35. This is just what first come in mind when reading your code.
Of course as you already know it, you can have together long and short orders in the same strategy, one cancels other (also known as OCO).
02/22/2018 at 9:32 PM #63588Hi Nicolas, I’ve changed the name of the variables in “mylongindex” and “myshortindex” as you suggested but it doesn’t work the same.
I’ve also tried with “if not onmarket” instead of ” if not longonmarket” and “if not shortonmarket” but the system doesn’t work either.
Have you some other ideas?
Thanks
Max
02/22/2018 at 11:52 PM #63597I tested your code on Eur/Usd, h1, and it didn’t get stuck, as you can see from the screenshot.
I only modified the names as suggested by Nicolas and commented out all GRAPH instructions.
02/23/2018 at 1:02 PM #6366402/23/2018 at 2:01 PM #63680Yes, it works anytime I launch it.
02/24/2018 at 9:11 PM #63836Thanks Roberto, yes probably it’s my internet connection, but it has happened also on the pc where I work.
Very strange it’s the first time that a system gets stuck.
Now with the forex market closed it works everytime i launch it.
-
AuthorPosts
Find exclusive trading pro-tools on