This script looks for a set up condition where 5 consecutive candles have broken away from the fast EMA (set to 8 by default) followed by a "trigger" candle that crosses back over the fast EMA but not the medium EMA (set to 13 by default). It then determines the entry point based on the bar high or low (not tail or wick) depending on direction of the trend. Once the entry point is crossed, we can enter the position. Win or loss is determined whether the lower or upper levels are crossed (as per trend). After the position is won or lost and if the entry level is re-crossed before a new set up condition is found then a new entry signal is given.
Please note that this should really be used in conjunction with a higher timeframe "Anchor" chart with a fast and a slow EMA so setups and positions should should correspond to the trend of the higher timeframe chart. This was designed for a 5 minute timeframe and a 60 minute anchor chart.