Condition in if block not getting triggered

Hi,

I have set Periodicity setting to 5 Min and then using TimeFrameSet, I am changing it to Hourly as I want to work with both 5 min and hourly data.

TimeFrameSet(inHourly);

triggerCondition = ...;

if (triggerCondition[BarCount - 1]) {
   // This doesn't trigger
} else {
    // This code works
}

I am using the above code to check a condition on the last bar. But only the else block triggers, if block never does even though I have verified on chart that data which should have triggered it occurred on multiple occasions. Else block works perfectly, it is giving the correct data.

Code in if block generates buy signal and code in else block generates sell signal. I am only getting sell signals.

Any help would be appreciated. Thanks.

You have not posted enough code for anyone to help you solve your problem. Please post a working example.

2 Likes

I have now understood the issue I was facing. In if check, I am only checking the last bar, that would be either true or false. Whenever the afl runs and it does every 5 minutes as I have set it to auto refresh every 5 minutes, it will check the condition and it could be either true or false.

If it's true, every single data which appears will only generate buy signal as I have put buy logic in if block and if the condition is false, sell will be generated as sell is in else block.

So at any given point in time, I will only have either buy or sell signal but not both. So I have now removed if else check but now ran into another issue with multiple time frames, will post a question on that soon.

Thanks.