I have run into a problem that requires some assistance. I have attached the file here and have it all commented so you can easily follow what's, what. I have also attached a screen shot showing it as is.
The problem I have is that there should only be one plot, or the other, printing at any given time. Clearly this is not happening. The reason it is not happening is that the "trigger", for the trend state to change only has to occur once, then the state should remain as is until the opposite "trigger" occurs. The "triggers" are based on closes above and below the 2 plots. But the problem occurs when the close is in between the 2 plots. Because the code is checking for the "trigger" on each bar. For instance an up trend can be triggered with a close above the Hi plot, which makes the Lo plot print, but then the next bar perhaps closes below the Hi plot but above the Lo plot and because it hasn't closed above the Hi plot will print the Hi plot again, which I don't wan't it to, not until such time as the down trend trigger occurs.
I just can't figure out a way to say what I can say in english, in code.
Look at the code you can see my "if", "else" statement, "else" is in english to convey to you what I think I need to say?
So, if the up trend state is triggered, change the plot colours as such.
(Once this triggers, do nothing until the down trend state is triggered.)
if the down trend state is triggered, change the plot colours as such.
(Once this triggers, do nothing until the up trend state is triggered.)
else, do nothing.
Please help I'm going mad trying to figure this out!
Cheers,
Ken.
Comment