I want to be able to refer to the last green or red candle that occurred while I am in a long or short position respectively, such that I am able to deploy actions upon said candle. For example, if I am in a long position, I want my code to reference the last green candle after every bar close and place a stop loss at the open of said candle.
I know I can refer x bars back, but in this scenario I have no way of knowing how many bars back the last green candle occurred, therefore I can't refer to it.
Is there a way I can do this in the strategy builder? That would be my preference, as I am not a strong programmer, but if manual code is my only option then bring it on, thank you.
Comment