Did something change with BarIndex ? (warning !)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #185063 quote
    PeterSt
    Participant
    Master

     

    DefParam PreloadBars = 1250
    
    graph barindex coloured (255,255,255,255)
    
    If BarIndex > 0 then   // 05-08-2021,PS. So all the code is not called when PreLoadBars is running (yep).
       // My Code.
    endif   // Very end of the code.

    Below shows the very beginning of a chart.
    In the 05-08-2021 comment you can see that at that day I surrounded all my code with the If BarIndex > 0. This was also the day that I filed a complaint related to PreLoadBars with a response from 2nd line support in the realm of “this is how it works – deal with it” (the tone was nicer, but the solution was not there 🙂 ).

    The past days I am suffering from an issue which is related to the start of the strategy (I changed something so I could notice it), and now I am stumped because what I see :
    The BarIndex variable (I think people in the PRT environment tend to call it a constant) is not zero any more at the start of the chart. And so my code is running into trouble, and it could finally explain why I usually lose a first trade after starting the backtest (happens also in Live).

    The orange line shows best what I mean – the strategy thinks that I entered the market which really happened only at ~ 13:20 for the first time.

    This is a moment that I really hate it that PRT does not provide anything like a changelog / releasenotes and I think it is inordinate that something crucial like this has been changed. That is, if I did not go bananas by now. Roberto @robertoguzzi, I recall that I saw you using the If barIndex > 0 for good habit, but maybe I dreamt it. Maybe I dream too much anyway.


    I recall that my complaint this summer was about all code just executing in the PreLoadBars phase, except for the orders not really being taken. Thus, all of the code executes, but the Buy xx at Market etc. is ignored until the bars to be preloaded are all there. And now, with the BarIndex not being at zero when the chart starts, this happens all the same – wrongly – again; my code again all executes, but the orders are ignored. This time, however, I don’t know the solution.

    I suppose (and hope) this is a bug. But for now people should be aware that this bug is there, which is a mighty dangerous one. I am putting this through to support in a minute …
    Meanwhile please let me know if I overlook something or judge wrongly. Thanks !

    image_2022-01-11_091951.png image_2022-01-11_091951.png
    #185065 quote
    PeterSt
    Participant
    Master
    DefParam PreloadBars = 1250
     
    graph barindex coloured (255,255,255,255)
     
    If BarIndex > 1250 then   // 11-01-2022,PS, Equal this redundantly to the DefParam PreloadBars argument.
       // My Code.
    endif   // Very end of the code.

    The above should be the solution for now (or forever). Credits go to first line support. 🙂 … why didn’t I think of that myself. 🙁

    GraHal thanked this post
    image_2022-01-11_095501.png image_2022-01-11_095501.png
    #185067 quote
    PeterSt
    Participant
    Master

    Roberto @robertoguzzi, I recall that I saw you using the If barIndex > 0 for good habit

    robertogozzi, Apologies for that “typo”.

    #185077 quote
    robertogozzi
    Moderator
    Master

    robertogozzi, Apologies for that “typo”.

    don’t worry about that (Moto GUZZI is the brand of an italian motorcycle manufacturer) 🙂

    I often use that to avoid using (sometimes) ONCE, with the definition of Heikin-Ashi candlesticks and maybe in other cases when I want to be sure that enough bars have been built before I calculate something.

    Example:

    IF BarIndex = 0 THEN
       Var1 = 0
       Var2 = 0
    ENDIF
    
    // instead of
    
    ONCE Var1 = 0
    ONCE Var2 = 0
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Did something change with BarIndex ? (warning !)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
PeterSt @peterst Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/11/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...