I am very new to AFL, I am not a programmer but I use google to my advantage to write up some simple programs. I am trying to code an indicator for one of my trading systems I hope if someone can help me.
The system is
If EMA9 crosses above/below EMA20 while both EMA lines are Under/Over VWMA50 then throw a long or short signal. I am using a histogram to return a value of +1 if it is a long signal and value of -1 if it is a short signal.
The challenge I am facing is that I want the signal to show up on next bars as well until I get an opposite signal. For example EMA9 Crosses Over EMA20 then the value would be +1 I would like the value of +1 to appear on every bar until I get an opposite signal of -1. I am not having any luck to get this working.
I have tried LastValue function and Cum function but no luck. I am getting a feeling I might have to use for loop function which I struggle to understand.