Just one example :)
Good luck
-BB-
//+------------------------------------------------------------------+ //| MA_Cross_RSI_Stoch_Filter.mq4 //| Copyright © 2007, Derik Breytenbach //| https://www.forex-tsd.com/suggestions-trading-systems/1589-simple-ma-cross-w-rsi-stochastic-filter.html //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Derik Breytenbach" #property link "https://www.forex-tsd.com/suggestions-trading-systems/1589-simple-ma-cross-w-rsi-stochastic-filter.html" // MA periods extern int SMA_period=5; extern int LWMA_period=20; extern int MA_Trigger=2; // Slow Stochastic input values extern int Kperiod=8; extern int Dperiod=3; extern int slowing=3; // RSI Period extern int RsiPeriod=14; // Define the maximum alowwable stoploss and tradesize (number of lots traded) extern double Stoploss = 100; extern double Takeprofit = 150; extern double Tradesize=0.1; // Define the magic number extern int Magic_number = 999; int init () { return(0); } int deinit() { return(0); } // Subroutine to determine if the entry rules are met, place take profit and stoploss values when you open the order void MA_Cross_Entry() { int ticket; double SMA5 = iMA(NULL, 0, SMA_period, 0, MODE_SMA, PRICE_CLOSE, 0); double LWMA10 = iMA(NULL, 0, LWMA_period, 0, MODE_LWMA, PRICE_CLOSE, 0); double SMA5P = iMA(NULL, 0, SMA_period, 0, MODE_SMA, PRICE_CLOSE, 1); double LWMA10P = iMA(NULL, 0, LWMA_period, 0, MODE_LWMA, PRICE_CLOSE, 1); double RSI = iRSI( NULL, 0, RsiPeriod, PRICE_CLOSE, 0); double StochMain = iStochastic(NULL, 0, Kperiod, Dperiod, slowing, MODE_SMA, 0, MODE_MAIN,0); if(SMA5 > LWMA10+MA_Trigger*Point && SMA5P < LWMA10P+MA_Trigger*Point && RSI > 50 && StochMain < 80 && OrdersTotal()<1) { ticket=OrderSend(Symbol(),OP_BUY,Tradesize,Ask,5,Ask-Stoploss*Point,Ask+Takeprofit*Point,0,Magic_number,0,Green); } if(SMA5 < LWMA10-MA_Trigger*Point && SMA5P > LWMA10P-MA_Trigger*Point && RSI < 50 && StochMain > 20 && OrdersTotal()<1) { ticket=OrderSend(Symbol(),OP_SELL,Tradesize,Bid,5,Bid+Stoploss*Point,Bid-Takeprofit*Point,0,Magic_number,0,Red); } } void MA_Cross_Exit() { double SMA5 = iMA(NULL, 0, SMA_period, 0, MODE_SMA, PRICE_CLOSE, 0); double LWMA10 = iMA(NULL, 0, LWMA_period, 0, MODE_LWMA, PRICE_CLOSE, 0); double SMA5P = iMA(NULL, 0, SMA_period, 0, MODE_SMA, PRICE_CLOSE, 1); double LWMA10P = iMA(NULL, 0, LWMA_period, 0, MODE_LWMA, PRICE_CLOSE, 1); int total; total = OrdersTotal(); if(total>0) { for(int pos=0;pos<total;pos++) { OrderSelect(pos,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY && OrderMagicNumber()==Magic_number && total==1) { if (Ask-Stoploss*Point>OrderStopLoss()) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask-Stoploss*Point,OrderTakeProfit(),0,Green); } if (SMA5 < LWMA10-MA_Trigger*Point && SMA5P > LWMA10P-MA_Trigger*Point) { OrderClose(OrderTicket(),OrderLots(),Bid,5,CLR_NONE); } return(0); } if(OrderType()==OP_SELL && OrderMagicNumber()==Magic_number && total==1) { if (Bid+Stoploss*Point<OrderStopLoss()) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid+Stoploss*Point,OrderTakeProfit(),0,Green); } if (SMA5 > LWMA10+MA_Trigger*Point && SMA5P < LWMA10P+MA_Trigger*Point) { OrderClose(OrderTicket(),OrderLots(),Ask,5,CLR_NONE); return(0); } } } } } int start() { MA_Cross_Exit(); MA_Cross_Entry(); return (0); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Please can someone help me to code RSI in such away that when it is above 50 (RSI>50) it is buy signal and when it is below 50 (RSI<50) it will be a sell signal.
thank you