This script builds an EMA (Exponential Moving Average) on special price conditions using the following: Averaged price if the current bar (c.=1/4(o.+c.+l.+c.) Midpoint of the previous bar (o.=1/2(o. of prev. bar+ c. of prev. bar) and h.=max(h.,o.,c.) l.=min(l.,o.,c.)
It gives alerts on price crossing the EMA (breakout/breakdown) and plots OUT and IN when the event occurs and the trigger is activated. Script works in real time. It is used only in trending markets like bullish trends and/or bearish trends and never in flat. It can get very bad results so pay attention!
Feel free to test it and add comments. I am open to answer any questions. I would like to know what you think and how can we improve this study.