// Downloaded From https://www.WiseStockTrader.com NperIn = Optimize("NPerIn", 10, 10, 40, 5); /* The close has to be less than this % of its daily and N day range */ LookBackIn = Optimize("LookBackIn", 17, 5, 21, 1); /*LookBack Period of Days for Close % determination */ LExitDays = Optimize("LExitDays", 5, 1, 30, 1); SExitDays = Optimize("SExitDays", 5, 1, 30, 1); /* */ NperOut = 2* NperIn;/* The close has to be less than this % of its daily and N day range */ LookBackOut = LookBackIn/2; /*LookBack Period of Days for Close % determination */ IndexLen =200; /*****************************************************************************************************************/ //Indicator #1 - On the Current Bar, what % is the Close Condition1 = (100 * (C-L) / (H-L)) < NperIn; Condition10 = (100* (C-L) / (H-L)) > 100-NperOut; //Indicator #2 - In the past Len1 days, Condition2 = 100 * (C - LLV(L,LookBackIn)) / (HHV(H,LookBackIn) - LLV(L,LookBackIn)) < NperIn; Condition20= 100 * (C - LLV(L,LookBackOut)) / (HHV(H,LookBackout) - LLV(L,LookBackout)) >100- NperOut; //Indicator #4 - Long Term Market StrongTrendUp = Close > MA(Close, IndexLen) AND MA(Close,IndexLen) > Ref(MA(Close,IndexLen),-1) ; StrongTrendDn = Close < MA(Close, IndexLen/4) AND MA(Close,IndexLen/4) < Ref(MA(Close,IndexLen/4),-1) ; TrendLess = NOT(StrongTrendDn OR StrongTrendUp); /*****************************************************************************************************************/ Buy = Condition1 AND Condition2 AND NOT StrongTrendDn; Short = False; Sell= Ref(Buy, -LExitDays) OR Short OR (Condition10 AND Condition20) ; Buy= ExRem(Buy, Sell); Sell= ExRem(Sell, Buy) ; Cover=Ref(Short, -SExitDays) OR Buy OR (Condition1 AND Condition2); Short= ExRem(Short, Cover); Cover= ExRem(Cover, Short);