CrossMA: Your Go-To Trading System for MetaTrader 5

Mike 2017.01.26 18:05 24 0 0
Attachments

Idea Creator: George F. Peskov, MQL5 Code Author: barabashkakvn.

Are you looking for a powerful trading system that harnesses the strength of moving averages? Look no further! The CrossMA system is built on the intersection of two moving averages, with automatic stop loss settings based on the Average True Range (ATR). Plus, you’ll receive email notifications every time a position is opened or closed. The parameters can be fine-tuned by backtesting, ensuring you get the most out of your trades.

Getting Started with Indicator Values

Here’s how you can retrieve values for the first and second bars:

//--- Get Moving Average
   mas=iMAGet(handle_iMA1,1);       // Long moving average 12
   maf=iMAGet(handle_iMA2,1);       // Short moving average 4
   mas_p=iMAGet(handle_iMA1,2);     // Long moving average 12
   maf_p=iMAGet(handle_iMA2,2);     // Short moving average 4
   Atr=iATRGet(0);

Checking Conditions for Selling

//--- Condition for selling
   if(maf<mas && maf_p>=mas_p)
     {
      double lots=LotsOptimized();
      double stop_loss=NormalizeDouble(m_symbol.Ask()+Atr,Digits());
      res=m_trade.Sell(lots,Symbol(),m_symbol.Bid(),stop_loss,0);
      if(SndMl==true && res)
        {
         sHeaderLetter="Operation SELL by"+Symbol()+"";
         sBodyLetter="Deal Sell by"+Symbol()+" at "+DoubleToString(m_symbol.Bid(),Digits())+
                     ", and set stop/loss at "+DoubleToString(stop_loss,Digits())+"";
         sndMessage(sHeaderLetter,sBodyLetter);
        }
      return;
     }

Checking Conditions for Buying

//--- Condition for buying
   if(maf>mas && maf_p<=mas_p)
     {
      double lots=LotsOptimized();
      double stop_loss=NormalizeDouble(m_symbol.Bid()-Atr,Digits());
      res=m_trade.Buy(lots,Symbol(),m_symbol.Ask(),stop_loss,0);
      if(SndMl==true && res)
        {
         sHeaderLetter="Operation BUY at"+Symbol()+"";
         sBodyLetter="Deal Buy at"+Symbol()+" for "+DoubleToString(m_symbol.Ask(),Digits())+
                     ", and set stop/loss at "+DoubleToString(stop_loss,Digits())+"";
         sndMessage(sHeaderLetter,sBodyLetter);
        }
      return;
     }


 

List
Comments 0