LOOKING FOR EXP. M/A EA!!

 
Hi, does anyone have an EA for a 2 line exp m/a crossover entry and exit signals?

thnx
 
//+------------------------------------------------------------------+
//|                                                 MA8-13 cross.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                         https://www.metaquotes.net/ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "https://www.metaquotes.net/"
 
extern int ExtPeriod1=8;
extern int ExtPeriod2=13;
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   static datetime PrevTime=0;
   double Ma8Current, Ma8Previous, Ma8Previous2;
   double Ma13Current, Ma13Previous, Ma13Previous2;
   bool   IsCrossDown, IsCrossUp;
//---- если на текущем баре предыдущий бар уже обработан, выходим.
   if (PrevTime==Time[0]) return(0);
   PrevTime=Time[0];
//---- возьмём значения мувингов
   Ma8Current=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,1);
   Ma8Previous=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,2);
   Ma8Previous2=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,3);
   Ma13Current=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,1);
   Ma13Previous=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,2);
   Ma13Previous2=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,3);
//---- и проверим условие пересечения
   IsCrossDown=(Ma8Current<Ma13Current && Ma8Previous>=Ma13Previous &&
                Ma8Previous2>Ma13Previous2);
   IsCrossUp  =(Ma8Current>Ma13Current && Ma8Previous<=Ma13Previous &&
                Ma8Previous2<Ma13Previous2);
//----
   if(IsCrossDown)
     {
      for(int i=OrdersTotal()-1; i>=0; i--)
        {
         //---- exit longs
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
            OrderClose(OrderTicket(),OrderLots(),Bid,3);
        }
      //---- entry short
      OrderSend(Symbol(),OP_SELL,1.0,Bid,3,0.0,0.0);
     }
//----
   if(IsCrossUp)
     {
      for(i=OrdersTotal()-1; i>=0; i--)
        {
         //---- exit shorts
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
            OrderClose(OrderTicket(),OrderLots(),Ask,3);
        }
      //---- entry long
      OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0.0,0.0);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
hey stringo, thnx but i dont know how to program this. can you please guide me somehow?

thnx
 
First read our documentation and articles
 
hey stringo, within the codes there's stuff in Russian. i dont know if it matters but do i need to know what it says?

thnx
 
another thing stringo, i opened the metaeditor and do i start the coding where it says "expert start function'' or ''expert deintialization function"?

thnx
 

there are simple comments

Process bar only once at beginning
Get MA values
Check crossing

 
criss73 wrote:
another thing stringo, i opened the metaeditor and do i start the coding where it says "expert start function'' or ''expert deintialization function"?

thnx

https://docs.mql4.com/basis/functions/special
 
ok stringo, i managed to write in the codes and compile them but i want to be able to add lots.  in the "input" all i can do is change the ema values.  
 
another thing stringo, i want to add Gridsize,Gridstep and Extendgrid!

thnx
 
hey stringo, forget about the Gridsize, Gridstep, and Extendgrid. i still want to know how to code the lots but, also, say the trend is up and i open my charts and turn on the EA, i want it to automatically enter me in the trade in the direction of the ema average; which is in this ex., up. do you know what i mean?

thnx
Reason: