Is there a major bug with the ONCE statement?

Forums ProRealTime English forum ProOrder support Is there a major bug with the ONCE statement?

  • This topic has 2 replies, 2 voices, and was last updated 7 years ago by avatarGST.
Viewing 3 posts - 1 through 3 (of 3 total)
  • #31636
    GST

    When examining some problems with my ProOrder code, I found some very strange behaviour using the ONCE statement. I have shortened those problems to some demonstrative examples.


    First example:

    Expected behaviour: Generating only short orders.
    Real behaviour: Generating only short orders.
    That is ok


    Second example, adding the line i = 1:

    Expected behaviour: First should be a short order, after that only long orders.
    Real behaviour: Generating only long orders.
    That is not ok. Why is the first sellshort statement skipped although i is not equal to 1?


    Third example, adding the line i = 0:

    Expected behaviour: Alternating short and long orders, starting with a short order.
    Real behaviour: Alternating short and long orders, starting with a short order.
    That is ok again.


    Fourth example, something with a counter:

    Expected behaviour: First 3 orders are long orders, after that only short orders.
    Real behaviour: Generating only long orders
    That is not ok again.


    You can try those examples on any market in any timeframe. The result is the same every time.

    My conclusion is: The ONCE statement does not work correct. Or did I overlook something? Can anyone provide a clue what went wrong here?

    Many thanks in advance for any reply!

     

    1 user thanked author for this post.
    #31706

    To prevent this kind of “wrong” calculation of your i variable, you must use this line at the top of your code:

    It will disallow the system to load bars history before starting the strategy. It should solve your issue.

     

    #31732
    GST

    Oh yes! I was not aware that the code is being executed even before the startdate of the strategy. Therefore your advice certainly clarifies the situation. Many thanks for that, Nicolas.

    Unfortunately, it does not solve my issue completely. After including the defparam statement, I would expect 3 buy orders in the fourth example (i = 0 / 1 / 2). But I only get 2 buy orders before the system moves to trigger sellshort orders. I have shown this in attachment Once1. And the second example does not work at all. So it seems, that the first round of calculation still happens before starting the strategy. And I am not able to guess why. Could you be of help once again?

    P.S.: When changing the starttime of the strategy to 00:00, the result does make me mad. Why is it starting 2 days earlier? See attachment Once2.

    Many thanks in advance!

Viewing 3 posts - 1 through 3 (of 3 total)

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