Weird results for one position with and without defparam cumulate orders
Forums › ProRealTime English forum › ProOrder support › Weird results for one position with and without defparam cumulate orders
- This topic has 16 replies, 3 voices, and was last updated 5 years ago by Vonasi.
Tagged: CUMULATEORDERS
-
-
02/05/2019 at 10:17 PM #90552
I wrote a very simple end of day strategy that went long and short the EURUSD Daily and that only had one position open at a time and only held for one day or continued holding the one position if conditions were still true. Here is the strategy but with the entry conditions removed because they are not relevant to the problem:
1234567891011121314c1 = (simple price action condition)c2 = (simple long look back filter)c3 = (simple short look back filter)sell at marketexitshort at marketif c1 and c2 thenbuy 1 contract at marketendifif not c1 and c3 thensellshort 1 contract at marketendif…here are the results:
I then thought that I would add a DEFPARAM CUMULATEORDERS = FALSE to the strategy just as belt and braces but surprisingly the results changed – even though neither version opens more than one position at a time.
Here are the results:
Why did the results change?
02/05/2019 at 10:27 PM #90560I think I found out why the results are so different but I still don’t understand why adding DEFPARAM CUMULATEORDERS = FALSE has made the difference. It appears that with it there is never a position shown as open two days in a row but without it there is.
Here is with DEFPARAM CUMULATEORDERS = FALSE:
and without:
I feel like this has been discussed before but I can’t recall what the conclusion was!
02/05/2019 at 10:39 PM #9056402/06/2019 at 9:11 AM #90574In the cold light of the morning I think I might have worked out what is happening.
Without The DEFPARAM instruction if you are already say long on the market and conditions are met again then a BUY order and a SELL order are sent to the market and cancel each other out so you stay on the market – but with the DEFPARAM CUMULATEORDERS = FALSE instruction the same thing happens but the DEFPARAM cancels the BUY order to stop multiple positions being opened so we are just left with a SELL order. This results in earlier exits and buying only possible on alternate candles.
I think we need to be careful when using DEFPARAM CUMULATEORDERS = FALSE in our strategies. It seems that it is sometimes better to use other methods in the code to avoid multiple entry.
02/06/2019 at 10:09 AM #90586I always use DEFPARAM CumulateOrders=false, nonetheless I always add NOT ONMARKET to my conditions to enter a trade.
1 user thanked author for this post.
02/06/2019 at 10:46 AM #90589I always add NOT ONMARKET to my conditions to enter a trade.
Yes I do too and I rarely put DEFPARAM CUMULATEORDERS = FALSE in my code but in the strategy above using NOT ONMARKET (or LONGON or SHORTON) would also break the strategy because a sell order would go to market but no buy order so staying in the trade would be impossible.
02/06/2019 at 11:42 AM #90599Wow gold star for finding this out Vonasi (and you didn’t even the need the xray specs! 🙂 ).
So, apart from reducing overall performance from not staying in trades etc, we are also incurring more instances of spread costs than we need to!?
02/06/2019 at 12:10 PM #90602With this code (100K data history), I get the same number of trades either using FALSE or TRUE in line 1:
123456789101112131415DEFPARAM CumulateOrders = falsec1 = Open > Closec2 = summation[20](c1) > 10 AND not c1[1]c3 = summation[20](not c1) > 10 AND c1[1]sell at marketexitshort at marketif c1 and c2 thenbuy 1 contract at marketendifif not c1 and c3 thensellshort 1 contract at marketendif02/06/2019 at 2:09 PM #90617robertogozzi – Yes you will get the same results whether it is TRUE or FALSE but different results if you delete the DEFPARAM instruction altogether. Your code does seem to get the same results when deleted so I think it is a something to do with your entry conditions.
If you try this code you will see that without the DEFPARAM instruction you get far more trades than with either FALSE or TRUE:
12345678910111213141516//DEFPARAM CumulateOrders = truec1 = Open > Closec2 = summation[20](c1) > 10c3 = summation[20](c1) < 10sell at marketexitshort at marketif c1 and c2 thenbuy 1 contract at marketendifif not c1 and c3 thensellshort 1 contract at marketendif02/06/2019 at 3:06 PM #90623I am on my mobile now and can’t test it.
Which one of these two ways line 14 is evaluated?
12if (not c1) and c3 thenif not (c1 and c3) thenbecause in the latter case it’s the same as line 10 and this could lead to weird results!
Try testing both ways with parenthesis.
02/06/2019 at 3:37 PM #90627This seems to be the correct evaluation:
1if (not c1) and c3 thenWithout DEFPARAM it yields the same results as DEFPARAM CumulateOrders = true.
So, the difference comes from DEFPARAM CumulateOrders = true (or no DEFPARAM) and DEFPARAM CumulateOrders = false.
We must try to find out what’s the behaviour of ProOrder in these two cases.
02/06/2019 at 4:20 PM #90631After some more tests I found out that adding
1and not onmarketto your conditions to enter a trade will yield no difference in using or not using DEFPARAM with either FALSE or TRUE.
So, I think there must be something in the way TRUE behaves that we can’t manage.
From my attached pic the difference is on July 25th, 1979 (I started from the beginning to find the first difference).
02/06/2019 at 4:20 PM #90633Yes
123if (not c1) and c3 thenif not c1 and c3 thenare the same logic.
I think we may be confusing each other as your code didn’t highlight the issue at all due to the conditions in it. If we only consider my last example code which does show the issue then I think ProOrders behaviour is as I suggested earlier – it just cancels any orders to enter the market if CUMULATE ORDERS = FALSE so if you have a BUY and a SELL then you just get left with a SELL. TRUE changes nothing as the the code itself will never allow more than one position because you are only buying or shorting once per bar and closing trades once per bar.
The number of trades was:
- FALSE = 3689
- TRUE = 2830
- NONE = 2830
Once again it can be seen that there is never a trade for two joined bars with it set to FALSE so the DEFPARAM order is just cancelling all BUY or SELLSHORT orders because we are already on the market.
02/07/2019 at 11:58 AM #90714I’m not clear on this, do I need to read above again a few times in depth?
Maybe you are still investigating Vonasi?
there is never a trade for two joined bars with it set to FALSE so the DEFPARAM order is just cancelling all BUY or SELLSHORT orders because we are already on the market.
Isn’t that what False is supposed to do so we don’t get an increase in Contracts onmarket?
What is a joined bar anyway? Do you mean one followed by another? So we need a space before a new Order can be opened?So do you think there is an Issue with PRT and does it affect all Timeframes?
Are we paying excess spread fees due to this Issue?
02/07/2019 at 12:54 PM #90718Yes by joined I mean one following the other.
I don’t believe that this is a bug – it is just that we need to fully understand how DEFPARAM CUMULATEORDERS = FALSE works before deciding to put it in our strategy code.
Considering just the long side of my strategy – if it is on the market with no DEFPARAM CUMULATEORDERS = FALSE or with a DEFPARAM CUMULATEORDERS = TRUE in the code then it can do one of two things at the close of a candle:
- Sends a BUY order and a SELL order that cancel each other out so it just stays on the market with the one position.
- Send just a SELL order so the position closes.
If we add a DEFPARAM CUMULATEORDERS = FALSE to the strategy then it does the following:
- Sends a BUY order and a SELL order but the BUY order is cancelled by the DEFPARAM CUMULATEORDERS = FALSE so we are left with just a SELL order. This means that it is impossible to stay on the market two candles in a row.
- Send just a SELL order so the position closes.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on