How can this be an entry?

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #183765 quote
    Mike Boorman
    Participant
    Average

     

    once is to initialise the variable once on the first reading of algo

    I get a slight variation in my results if I use ONCE crossflag=0 at the top versus if I use crossflag=0 on its own. But why should there be a difference? If crossflag=0 at the top of the code, shouldn’t be enough to reset it every time the code runs?

    #183766 quote
    JS
    Participant
    Senior

    “Once Crossflag=0” will only processed once…

    “Crossflag=0” will be processed every time…

    #183767 quote
    Mike Boorman
    Participant
    Average

    But isn’t each piece of code only processed once? Why would the top line of crossflag=0 be processed more often?

    #183768 quote
    PeterSt
    Participant
    Master

    Mike, the code will be executed from top at each close of a bar. For example, if you receive new bars each one minute (this depends on your Chart setting of the instrument), then each one minute the code executes.
    In the example below, this is each 5 minutes.

    image_2021-12-22_174239.png image_2021-12-22_174239.png
    #183770 quote
    JS
    Participant
    Senior

    And the “once” statement, in your code, will only be executed once…(only the first time)

    #183772 quote
    Mike Boorman
    Participant
    Average

    Okay, thanks. I think I understand it better now. I can see the benefit of ONCE if I need the instruction to stay static for a number of bars while other variables calculate.

    Thanks again for explaining 🙂

Viewing 6 posts - 16 through 21 (of 21 total)
  • You must be logged in to reply to this topic.

How can this be an entry?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 20 replies,
has 5 voices, and was last updated by Mike Boorman
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/21/2021
Status: Active
Attachments: 5 files
Logo Logo
Loading...