help me an EA

 

open buy : candle close > ma10 

open sell : candle close < ma10

close buy : candle close < ma10

close sell :  candle close > ma10 



time frame : M5


help me please 

 

Do not double post!

I have deleted your duplicate topic.

 
manhha: help me please 

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. 2004
          Prune pointless queries.

You have only four choices:

  1. Search for it. Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.
    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
              Hiring to write script - General - MQL5 programming forum 2019.08.21

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

 
William Roeder:

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. 2004
          Prune pointless queries.

You have only four choices:

  1. Search for it. Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.
    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
              Hiring to write script - General - MQL5 programming forum 2019.08.21

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

help me creat an EA


open buy : candle close > ma10 

open sell : candle close < ma10

close buy : candle close < ma10

close sell :  candle close > ma10 



time frame : M5


help me please 

 

Help you with what? You haven't stated a problem, you stated a want.

Your question has been answered. What part of "We're not going to code it for you" was unclear? What part of your four choices was unclear?

You just said the same exact thing again. Do you really expect a different answer?

Insanity: doing the same thing over and over again and expecting different results.
          Unknown
 
//+------------------------------------------------------------------+
//|                                    Moving average-Manhha         |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+

extern int MovingPeriod =10;
extern int MovingShift=1;
extern int MagicNumber=19082020;
extern double Lots =0.01;
extern double StopLoss=50;
extern double TakeProfit=50;
extern int TrailingStop=50;
extern int Slippage=3;
extern int Shift=1;

//+------------------------------------------------------------------+
//    expert start function
//+------------------------------------------------------------------+
int start()
{
  double MyPoint=Point;
  if(Digits==3 || Digits==5) MyPoint=Point*10;

  double TheStopLoss=0;
  double TheTakeProfit=0;
  if( TotalOrdersCount()==0 ) 
  {
     int result=0;
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+
// Here is your open buy rule//Ici votre strategie d'achat
 
    double ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
   
    if (iClose(Symbol(),PERIOD_M5,Shift)<ma)  
//+------------------------------------------------------------------+ 
//+------------------------------------------------------------------+    
     {
        result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
        if(result>0)
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
        if( OrderSelect(result,SELECT_BY_TICKET))
        bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
        }
        return(0);
     }
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+     
// Here is your open Sell rule//Ici votre strategie de vente    
 
    if (iClose(Symbol(),PERIOD_M5,Shift)<ma)
    
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+     
     {
        result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
        if(result>0)
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
        if( OrderSelect(result,SELECT_BY_TICKET))
        bool modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
        }
        return(0);
     }
  }
  
  for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
      if(OrderType()<=OP_SELL &&   
         OrderSymbol()==Symbol() &&
         OrderMagicNumber()==MagicNumber 
         )  
        {
         if(OrderType()==OP_BUY)  
           {
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+              
//here is your close buy rule//Ici strategie de fin d'achat 
     double   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);     

     if (iClose(Symbol(),PERIOD_M5,Shift)<ma)
        
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+               
              {
                  bool modif3= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
              }
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
                    {
                    bool modif4= OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else 
           {
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+          
// here is your close sell rule/Ici strategie de fin de vente

    double ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
  
    if (iClose(Symbol(),PERIOD_M5,Shift)<ma)                
                
//+------------------------------------------------------------------+     
//+------------------------------------------------------------------+                  
                {
                   bool modif5=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
                }
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
                    {
                    bool modif6= OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
}

int TotalOrdersCount()
{
  int result=0;
  for(int i=0;i<OrdersTotal();i++)
  {
     if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES))
     if (OrderMagicNumber()==MagicNumber) result++;

   }
  return (result);
}

You must do a Backtest 


Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: " 1 minute OHLC " using only Open, High, Low and Close prices of minute bars; detailed modeling in " Every tick " mode, as well as the most accurate " Every tick based on real ticks " mode applying actual historical data. Comparing the results allows us to...
 
You can also use a channel 
// Calculate a channel on Moving Averages, and check if the price is outside of this channel.  
        { 
                imalow = iMA ( Symbol(), PERIOD_M5, Indicatorperiod, 0, MODE_LWMA, PRICE_LOW, 0 ); 
                imahigh = iMA ( Symbol(), PERIOD_M5, Indicatorperiod, 0, MODE_LWMA, PRICE_HIGH, 0 ); 
                imadiff = imahigh - imalow;
                          
    isbidgreaterthanima =(( bid >= imahigh + imadiff / 2.0) 
     &&(Volume[volume1]> Volume[volume0])
     &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) 
     &&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper));