5 EMA Stratergy
Forums › ProRealTime English forum › ProBuilder support › 5 EMA Stratergy
- This topic has 3 replies, 2 voices, and was last updated 2 years ago by nitinvijayrane.
-
-
11/13/2022 at 12:39 PM #204066
Hi All,
Need some help with 5 EMA statergy that Im developing. Made some attempts but doesnt yield correct results but i think im quite close.
Short Conditions
1. Timeframe is 5 minutes for short trades
2. Plot 5 EMA on candles.
3. candles which are above 5 EMA (shouldnt even be touching 5 EMA at all. We call these as alert candle.
4. It is perfectly possible to have more than 1 alert candle, in case the next candle becomes alert candle and we ignore the previous ones.
5. Candle which breaks alert candle low, We should take a short.
6. Stop Loss becomes one of the previous alert candles high. This could be last 3,4,5 candles
7. target is going to be 3X of Stop loss.
8. When we reach 80% of target we want to close 75% of position size and trail 25% with last 3 candles lowLong Conditions
1. Timeframe is 15 minutes for Long trades
2. Plot 5 EMA on candles.
3. candles which are below 5 EMA (shouldnt even be touching 5 EMA at all. We call these as alert candles.
4. It is perfectly possible to have more than 1 alert candle, in case the next candle becomes alert candle and we ignore the previous ones.
5. Candle which breaks alert candle High, We should take a short.
6. Stop Loss becomes one of the previous alert candles Low. This could be last 3,4,5 candles
7. target is going to be 3X of Stop loss.
8. When we reach 80% of target we want to close 75% of position size and trail 25% with last 3 candles High11/13/2022 at 12:40 PM #2040685 EMA Short code1234567891011121314151617181920212223242526272829303132333435//5EMA//05.11.2022//NitinDEFPARAM CumulateOrders = FalseDEFPARAM PreloadBars = 200PositionSize = 1//5 minute TF (get the trend of the 5 minute chart)//timeframe(5 minutes,updateonclose)MyEma5 = ExponentialAverage[5]AlertCandleShort = (Low > MyEma5)if AlertCandleShort thenif AlertCandleShort and Low < Low[1] thensellshort positionsize contracts at marketendifendIfstoplosslong = abs(close-Low[1])-5*pointsizeLongtgt = stoplosslong * 3if longonmarket thenset stop loss stoplosslongset target profit Longtgtendifstoplosshort = abs(close-High[1])+5*pointsizeShorttgt = stoplosshort * 3if shortonmarket thenset stop loss stoplosshortset target profit Shorttgtendif11/15/2022 at 5:11 AM #204187There you go:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879DEFPARAM CumulateOrders = False//---------------------------------------------------// Short Timeframe//Timeframe(5mn,UpdateOnClose)Ema5mn5 = average[5,1](close)ShortAlert = low > Ema5mn5IF ShortAlert THENBreakLow = lowENDIFShortTrigger = close < BreakLowIF OnMarket THENShortAlert = 0BreakLow = 0ShortTrigger = 0ENDIFIF ShortTrigger THENSELLSHORT 1 CONTRACT AT MarketStopPriceS = highest[3](high)TargetSizeS = (StopPriceS - close) * 3TargetPriceS = close - TargetSizeSFirstExitS = close - (TargetSizeS * 0.8)SET STOP Price StopPriceSSET TARGET Price TargetPriceSTrailStartS = 0ENDIFIF ShortOnMarket THENIF (close <= FirstExitS) AND (TrailStartS = 0) THENEXITSHORT abs(CountOfPosition) * 0.75 CONTRACTS AT MarketTrailStartS = lowest[3](low)ENDIFIF TrailStartS THENTrailStartS = lowest[3](low)SET STOP Price TrailStartSENDIFENDIF//---------------------------------------------------// Long Timeframe//Timeframe(15mn,UpdateOnClose)Ema15mn5 = average[5,1](close)LongAlert = high < Ema15mn5IF LongAlert THENBreakHigh = highENDIFLongTrigger = close > BreakHighIF OnMarket THENLongAlert = 0Breakhigh = 0LongTrigger = 0ENDIFIF LongTrigger THENBUY 1 CONTRACT AT MarketStopPriceL = lowest[3](low)TargetSizeL = (close - StopPriceL) * 3TargetPriceL = close + TargetSizeLFirstExitL = close + (TargetSizeL * 0.8)SET STOP Price StopPriceLSET TARGET Price TargetPriceLTrailStartL = 0ENDIFIF LongOnMarket THENIF (close >= FirstExitL) AND (TrailStartL = 0) THENSELL abs(CountOfPosition) * 0.75 CONTRACTS AT MarketTrailStartL = highest[3](high)ENDIFIF TrailStartL THENTrailStartL = highest[3](high)SET STOP Price TrailStartLENDIFENDIF//---------------------------------------------------//IF ShortOnMarket THEN//GraphOnPrice StopPriceS coloured("Red")//GraphOnPrice TrailStartS coloured("Blue")//ELSIF LongOnMarket THEN//GraphOnPrice StopPriceL coloured("Red")//GraphOnPrice TrailStartL coloured("Blue")//ENDIF1 user thanked author for this post.
11/15/2022 at 9:20 AM #204192Thanks Guys this is really helpful, appreciate your help
-
AuthorPosts