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

Viewing 15 posts - 1 through 15 (of 17 total)
  • #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:

    …here are the results:

    Screenshot_5

    Screenshot_6

    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:

    Screenshot_7

    Screenshot_8

    Why did the results change?

    #90560

    I 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:

    Screenshot_9

    and without:

    Screenshot_10

    I feel like this has been discussed before but I can’t recall what the conclusion was!

    #90564

    If I put:

    then the strategy behaves correctly exactly the same as if it wasn’t there at all.

     

    #90574

    In 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.

    #90586

    I 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.
    avatar Bel
    #90589

    I 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.

    #90599

    Wow 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!?

    #90602

    With this code (100K data history), I get the same number of trades either using FALSE or TRUE in line 1:

     

    #90617

    robertogozzi – 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:

     

    #90623

    I am on my mobile now and can’t test it.

    Which one of these two ways line 14 is evaluated?

    because in the latter case it’s the same as line 10 and this could lead to weird results!

    Try testing both ways with parenthesis.

    #90627

    This seems to be the correct evaluation:

    Without 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.

    #90631

    After some more tests I found out that adding

    to 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).

     

    #90633

    Yes

    are 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.

    Screenshot_1-1

     

    #90714

    I’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?

    #90718

    Yes 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.
Viewing 15 posts - 1 through 15 (of 17 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login