Unable to use variable across time frames

Forums ProRealTime English forum ProOrder support Unable to use variable across time frames

Viewing 6 posts - 1 through 6 (of 6 total)
  • #76600

    I’m trying to get a strategy to decide on weekly candles to close a position but then not actually close it until the market opens the following Monday but I get this error:

    Screenshot_1-12

    This is the code:

    It seems a bit odd to not be able to set a variable in one time frame and then use it in another. At the moment I cannot find a solution which makes the MTF rather limited for improved exit times. Maybe I am missing something obvious – any ideas?

    #76604

    Line 7 is fine since you are simply using it, while line 9 ASSIGNs a value to a variable first used in a different TF, which is not allowed!

    #76606

    I think I found the solution:

    So a condition can be used across time frames but a variable cannot be altered across timeframes.

    #76608

     

    I wanted to set the variable to 1 in one time frame and then use it to make a decision and then turn it off in another timeframe which is apparently not allowed. Setting a condition apparently is so I will just have to start thinking in a different way about how I code as I tend to like using ‘flags’ on or off. I guess another alternative is that I could have turned it off with:

    Same result but more code!

    #76685

    Actually you should not need to bother about setting a flag in a lower TF.

    You’d better set a flag from within the LOWER TF when conditions in the HIGHER TF are met, since when, say, a new day start, also a new hour or minute or 4-hour TF starts!

    That’s why, I guess, they require TFs to be multiple of the lowest one!

    So if you want to set a flag in a hourly TF, just set/clear it on a 1-minute (or 5-minute, whatever) TF and you’ll be able to read it elsewhere, be it daily, weekly….

    #76686

    I fear my brain will need a little re-training. 🙂

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

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