Scriverò un EA gratuitamente - pagina 127

 
Наджибулло Хабибов:
Ciao, ho un EA che apre un trade in tutte le valute tranne l'oro, puoi per favore aiutare quale codice devo aggiungere nell'EA per aprire e oro?

Non essere moderato nel mercato?

 
Наджибулло Хабибов:

lotto 0,01 lotto senza stop loss nessun profitto nel registro non si apre anche se non c'è nessun errore

Nella finestra dei simboli ci sono le caratteristiche tecniche di ogni simbolo, volume minimo/massimo, livello minimo di stop

Se non c'è nessun errore può essere che l'algoritmo non permette di aprire :)

 
VVT:

Nella finestra dei simboli ci sono le caratteristiche tecniche di ogni strumento; volume minimo/massimo, livello minimo di stop

Se non stampa un errore, forse l'algoritmo non permette di aprire :)

//--- ***

Se conosci l'algoritmo, puoi controllare il motivo per cui non si apre per l'oro?

 
Наджибулло Хабибов:
//--- ***

Se sapete qual è il motivo della mancata apertura per l'oro, potete controllare per favore?

Inserisci il codice correttamente: usa il pulsante Codice o in alternativa: allega il file usando il Allega file

 
Vladimir Karputov:

Inserisci il codice correttamente: usa il pulsante o in alternativa: allega il file usando il pulsante

Sì, mostra cosa sta prendendo parte all'apertura, allo spread, allo slippage o a qualcos'altro di sbagliato

 
//--- Inputs
extern double Lots       = 0.1;      // лот
extern double KLot       = 1;        // умножение лота
extern double MaxLot     = 5;        // максимальный лот
extern double Profit     = 0;        // Профит в валюте
extern int StopLoss      = 0;        // Стоп Лось
extern int TakeProfit    = 0;        // ТейкПрофит
extern int BULevel       = 0;        // уровень БУ
extern int BUPoint       = 30;       // пункты БУ
extern int TrailingStop  = 0;        // трал
extern int StartHour     = 0;        // час начала торговли
extern int StartMin      = 30;       // минута начала торговли
extern int EndHour       = 23;       // час окончания торговли
extern int EndMin        = 30;       // минута окончания торговли
extern int Reverse       = 0;        // 1-реверс
extern int CloseSig      = 0;        // 1-закрытие по сигналу
extern int Slip          = 30;       // реквот
extern int Shift         = 1;        // на каком баре сигнал индикатора
extern int Magic         = 123;      // магик

extern string IndName    = "Aroow";
extern int SignalPeriod  = 9;

datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool TimeSession(int aStartHour,int aStartMinute,int aStopHour,int aStopMinute,datetime aTimeCur)
  {
//--- время начала сессии
   int StartTime=3600*aStartHour+60*aStartMinute;
//--- время окончания сессии
   int StopTime=3600*aStopHour+60*aStopMinute;
//--- текущее время в секундах от начала дня
   aTimeCur=aTimeCur%86400;
   if(StopTime<StartTime)
     {
      //--- переход через полночь
      if(aTimeCur>=StartTime || aTimeCur<StopTime)
        {
         return(true);
        }
     }
   else
     {
      //--- внутри одного дня
      if(aTimeCur>=StartTime && aTimeCur<StopTime)
        {
         return(true);
        }
     }
   return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)
         sl=NormalizeDouble(price+StopLoss*_Point,_Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price-TakeProfit*_Point,_Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)
         sl=NormalizeDouble(price-StopLoss*_Point,_Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price+TakeProfit*_Point,_Digits);
     }

   r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()<2)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   
   if(CountTrades()>0)
     {
      lot=NormalizeDouble(lot*MathPow(KLot,CountTrades()),2);
     }
   if(lot>MaxLot)
      lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(Bid-OrderOpenPrice()>TrailingStop*_Point)
                 {
                  if(OrderStopLoss()<Bid-TrailingStop*_Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*_Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*_Point)
                 {
                  if((OrderStopLoss()>(Ask+TrailingStop*_Point)) || (OrderStopLoss()==0))
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*_Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*_Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*_Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*_Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*_Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
  {
   bool cl;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,_Digits),Slip,White);
              }
            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,_Digits),Slip,White);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
  {
   double pr=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }

            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(pr);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double blu = iCustom(NULL,0,IndName,SignalPeriod,4,Shift);
   double red = iCustom(NULL,0,IndName,SignalPeriod,5,Shift);
   double blu2 = iCustom(NULL,0,IndName,SignalPeriod,4,Shift+1);
   double red2 = iCustom(NULL,0,IndName,SignalPeriod,5,Shift+1);

   bool buy = blu<1000 && red2<1000;
   bool sell = red<1000 && blu2<1000;

   if(Reverse>0)
     {
      buy = red<1000 && blu2<1000;
      sell = blu<1000 && red2<1000;
     }

   if(BULevel>0)
      BU();
   if(TrailingStop>0)
      Trailing();
   if(AllProfit()>Profit && Profit>0)
      CloseAll();

   if(TimeSession(StartHour,StartMin,EndHour,EndMin,TimeCurrent()) && t!=Time[0])
     {
      if(buy)
        {
         PutOrder(0,Ask);
        }
      if(sell)
        {
         PutOrder(1,Bid);
        }
      t=Time[0];
     }

   if(CountTrades()>0 && CloseSig>0)
     {
      if(sell)
        {
         CloseAll(0);
        }
      if(buy)
        {
         CloseAll(1);
        }
     }

   Comment("\n blu: ",blu,
           "\n red: ",red,
           "\n All Profit: ",AllProfit());
  }
//+------------------------------------------------------------------+
VVT:

Sì, mostratemi cosa sta prendendo parte all'apertura lì, lo spread, lo slippage o qualsiasi altra cosa sia sbagliata

 

Ciao a tutti!

Ci sono 4 indicatori e una biblioteca.

Due indicatori sono necessari solo per i calcoli, 2 sono gettati sul grafico.

Voglio automatizzare questo processo, solo 3 condizioni.... ma ho bisogno di mettere tutto in un file e non so cosa fare con la libreria.

Qualcuno può farlo?

 
Наджибулло Хабибов:

Si tratta di spread e slippage? Se sì, impostare il valore più alto di 100-150 per esempio

extern int BUPoint       = 30;       // пункты БУ
extern int Slip          = 30;       // реквот
 
VVT:

Si tratta di spread e slippage? Se sì, allora impostate un valore più alto di 100-150 per esempio

sì, impostare questi valori a seconda delle caratteristiche tecniche dello strumento, cioè lo spread massimo dello strumento

 
VVT:

sì, impostare questi valori a seconda delle caratteristiche tecniche dello strumento, cioè lo spread massimo dello strumento non è o

non funziona set 150 non si apre