200 EMA & MACD Indicator
Forums › ProRealTime English forum › ProBuilder support › 200 EMA & MACD Indicator
- This topic has 7 replies, 4 voices, and was last updated 5 months ago by robertogozzi.
-
-
05/29/2024 at 12:51 PM #233226
Hello,
Would it be possible to get code an indicator please as follows:-
The trading timeframe is open to accommodate trading on all timeframes.
A buy signal is generated when the MACD crosses up over the MACD Signal line and the signal line and MACD are below the Zero line, and price closes above the 200 Exponential Moving Average.
Stop loss for a buy signal is based on the most recent swing low and/or the 200 period Exponential Moving Average whichever is nearest the price when the trade is taken.
A sell signal is generated when the MACD crosses under the MACD signal line and the signal line and MACD are above the MACD Zero line, and price closes below the 200 EMA.
Stop loss for a sell signal is based on the most recent swing high and/or the 200 period Exponential Moving average whichever is nearest the price when the trade is taken.
Take Profit can be based on either Option 1 an adjustable Risk/Reward ratio (Trailing Stop loss to be at 0) or Option 2 an adjustable Trailing Stop loss percentage (risk /reward ratio to be at 0).
Appreciate any assistance. Thank you
05/29/2024 at 3:16 PM #233249Haven’t you asked the question before?
https://www.prorealcode.com/topic/classic-macd-200ema-strategy/
05/29/2024 at 5:32 PM #233256Hi Thanks for replying,
The previous request was for a strategy.
This request is for an indicator that can be used as a screener.
Best regards
Brian
05/30/2024 at 9:51 AM #233265Hi
This could be something closed to that you are looking for:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859R=1.5 //risk ratio//-----------------------------------------------------------------//MyMACD = MACDline[12,26,9](close)MySLine = MACDSignal[12,26,9](close)MyHis = MACD[12,26,9](close)EMA200 = ExponentialAverage[200](close)//-----------------------------------------------------------------////-----Long Trades-------------------------------------------------//C1 = MyMACD Crosses Over MySLine AND MyMACD < 0 AND MySLine < 0C2 = Close > EMA200BuyCondition = C1 AND C2//-----BuyIF long=0 and BuyCondition THENdrawarrowup(barindex,low)coloured("green")long=1short=0SwingLow = lowest[10](low)NearestLevel = Min(SwingLow, EMA200) //Stop lossTP=R*(close-Nearestlevel)+close //Take ProfitENDIF//-----Sellif long and (low<NearestLevel or high>TP) thendrawarrowdown(barindex,high)coloured("green")long=0endif//-----------------------------------------------------------------////-----Short Trades------------------------------------------------//C3 = MyMACD Crosses Under MySLine AND MyMACD > 0 AND MySLine > 0C4 = Close < EMA200SellCondition = C3 AND C4//-----Sell ShortIF short=0 and SellCondition THENdrawarrowdown(barindex,high)coloured("red")long=0short=1SwingHigh = highest[10](high) // Assuming a 10-bar lookback for swing highNearestLevel = Max(SwingHigh, EMA200) // Selecting the nearest level to the current priceTP=close - R*(NearestLevel-Close)ENDIF//-----Cover Shortif short and (high>NearestLevel or low<TP) thendrawarrowup(barindex,low)coloured("red")short=0endif//-----------------------------------------------------------------////-----------------------------------------------------------------//if long thendrawpoint(barindex,NearestLevel)coloured("red")drawpoint(barindex,TP)coloured("blue")elsif short thendrawpoint(barindex,NearestLevel)coloured("red")drawpoint(barindex,TP)coloured("blue")endif//-----------------------------------------------------------------//return EMA20005/30/2024 at 12:00 PM #233286Hi Ivan,
Thank you very much for this. It’s much appreciated.
I have a couple of queries that you might be able to answer or provide a solution please.
- The indicator should be used on the price chart. How can this be done?
- Can the code be included in ProScreener to identify instruments that provide a signal generated by the indicator
Best regards
Brian
05/30/2024 at 5:18 PM #233300Hi Iván,
Thank you for your great work on the requested indicator.
I have figured out how to get the indicator onto the price chart and I’ll see if it works. The indicator is on TradingView so I can do a comparison. I’ll let you know after the test.
Could the code for the indicator be used in ProScreener? Would it be possible to get the amended code to enable this to work in ProScreener?
Thanks again for your assistance.
Best regards
05/31/2024 at 9:56 AM #23332505/31/2024 at 10:19 AM #233328In addition, Ema200 won’t work, as screeners with IG have a 256-bar lookback limit, but a 200-period EMA greatly exceeds that limit (I once tested an EMA and it worked fine with some 80 periods, if I remeber correctly). Lower those periods or switch to an SMA.
-
AuthorPosts
Find exclusive trading pro-tools on