4756 hatası

 

benim ea 4756 hatası veriyor

bana yardım edebilir misin teşekkürler

 //+------------------------------------------------------------------+
//|                                                    ErlyBird6.mq5 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link       "http://www.mql5.com"
#property version   "1.00"

string name, oldnameHTop,oldnameHBottom,oldnameVstart,oldnameVstop;

input int       MA_Period= 8 ;       // Moving Average Period
input int       StopLoss= 100 ;       // Stop Loss
input int       TakeProfit= 100 ;   // Take Profit
input int       Trigger= 5 ;
input double    Lot= 1 ;
input int       EA_Magic= 12345 ;   // EA Magic Number


int maHandle;   // handle for our Moving Average indicator
int     Sommerzeit     =   87 ;   // DayOfYear Beginn Sommerzeit
int     Winterzeit     =   297 ;   // DayOfYear Beginn Winterzeit
int   TimeSelect;
int STP, TKP;   // To be used for Stop Loss & Take Profit values


double maVal[]; // Dynamic array to hold the values of Moving Average for each bars
double hg[],lw[],p_close;
double High[],  Low[];
double Top,Bottom;

   MqlRates rates[];
   MqlDateTime Time;

 MqlTick latest_price;     // To be used for getting recent/latest price quotes
 MqlTradeRequest mrequest;   // To be used for sending our trade requests
 MqlTradeResult mresult;     // To be used to get our trade results
     // Initialization of mrequest structure
  

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+


int OnInit ()
  {


//--- Get the handle for Moving Average indicator
   maHandle= iMA ( _Symbol , _Period ,MA_Period, 0 , MODE_EMA , PRICE_CLOSE );
//--- What if handle returns Invalid Handle
   if ( maHandle< 0 )
     {
       Alert ( "Error Creating Handles for indicators - error: " , GetLastError (), "!!" );
       return (- 1 );
     }



//--- Let us handle currency pairs with 5 or 3 digit prices instead of 4
   STP = StopLoss;
   TKP = TakeProfit;
   if ( _Digits == 5 || _Digits == 3 )
     {
      STP = STP* 10 ;
      TKP = TKP* 10 ;
     }
   

   return ( 0 );
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//--- destroy timer
   EventKillTimer ();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
   // Do we have enough bars to work with
   if ( Bars ( _Symbol , _Period )< 60 ) // if total bars is less than 60 bars
     {
       Alert ( "We have less than 60 bars, EA will now exit!!" );
       return ;
     }  

// We will use the static Old_Time variable to serve the bar time.
// At each OnTick execution we will check the current bar time with the saved one.
// If the bar time isn't equal to the saved time, it indicates that we have a new tick.

   static datetime Old_Time;
   datetime New_Time[ 1 ];
   bool IsNewBar= false ;

// copying the last bar time to the element New_Time[0]
   int copied= CopyTime ( _Symbol , _Period , 0 , 1 ,New_Time);
   if (copied> 0 ) // ok, the data has been copied successfully
     {
       if (Old_Time!=New_Time[ 0 ]) // if old time isn't equal to new bar time
        {
         IsNewBar= true ;   // if it isn't a first call, the new bar has appeared
         if ( MQL5InfoInteger ( MQL5_DEBUGGING )) Print ( "We have new bar here " ,New_Time[ 0 ], " old time was " ,Old_Time);
         Old_Time=New_Time[ 0 ];             // saving bar time
        }
     }
   else
     {
       Alert ( "Error in copying historical times data, error =" , GetLastError ());
       ResetLastError ();
       return ;
     }

//--- EA should only check for new trade if we have a new bar
   if (IsNewBar== false )
     {
       return ;
     }
 
//--- Do we have enough bars to work with
   int Mybars= Bars ( _Symbol , _Period );
   if (Mybars< 60 ) // if total bars is less than 60 bars
     {
       Alert ( "We have less than 60 bars, EA will now exit!!" );
       return ;
     } 
  
     ArraySetAsSeries (rates, true );
     copied= CopyRates ( _Symbol , 0 , 0 , 60 ,rates);
   
     TimeToStruct (rates[ 0 ].time, Time);
     if (  Time.day_of_year>=Sommerzeit &&   Time.day_of_year<=Winterzeit) TimeSelect= 11 ; else TimeSelect= 10 ;  
     
     if (  Time.hour==TimeSelect &&  Time.min== 0 )   //draw vertical line at TimeSelect
          {
             ObjectDelete ( 0 ,oldnameVstart);  
            name = "VerticalStart" + TimeToString (rates[ 0 ].time, TIME_DATE|TIME_SECONDS);
             ObjectCreate ( 0 ,name, OBJ_VLINE , 0 ,rates[ 0 ].time, 0 ); 
             ObjectSetInteger ( 0 ,name, OBJPROP_COLOR , clrRed );
            oldnameVstart= name;       
          }
      
    
         if (  Time.hour==TimeSelect+ 5 &&  Time.min== 0 )   //draw vertical line at TimeSelect+5
           {
            
             ObjectDelete ( 0 ,oldnameVstop);      
            name = "VerticalEnd" + TimeToString (rates[ 0 ].time, TIME_DATE|TIME_SECONDS);
             ObjectCreate ( 0 , name, OBJ_VLINE , 0 ,rates[ 0 ].time, 0 );
             ObjectSetInteger ( 0 , name, OBJPROP_COLOR , clrDarkViolet );
            oldnameVstop= name;   
            
             ArraySetAsSeries (hg, true );
             ArraySetAsSeries (lw, true );
           
             CopyHigh ( _Symbol , _Period , TimeCurrent (), 5 ,hg);
             CopyLow ( _Symbol , _Period , TimeCurrent (), 5 ,lw);
       
             
             Top = NormalizeDouble (rates[ ArrayMaximum (hg, 0 , WHOLE_ARRAY )].high, _Digits );  
             Bottom = NormalizeDouble (rates[ ArrayMinimum (lw, 0 , WHOLE_ARRAY )].low, _Digits );
          
           
             // draw horizontal line at the top of  5 last  candles 
             ObjectDelete ( 0 , oldnameHTop);
            name = "HorizontalTop" + TimeToString (rates[ 0 ].time, TIME_DATE|TIME_SECONDS);
        
             ObjectCreate ( 0 ,name, OBJ_HLINE , 0 ,rates[ 0 ].time,Top);
             ObjectSetInteger ( 0 ,name , OBJPROP_COLOR , clrGreenYellow );
            oldnameHTop= name;
         
         
             // draw horizontal line at the bottom of  5 last  candles 
             ObjectDelete ( 0 ,oldnameHBottom);
            name = "HorizontalBottom" + TimeToString (rates[ 0 ].time, TIME_DATE|TIME_SECONDS);
        
             ObjectCreate ( 0 ,name, OBJ_HLINE , 0 ,rates[ 0 ].time,Bottom);
             ObjectSetInteger ( 0 ,name , OBJPROP_COLOR , clrCrimson );
            oldnameHBottom= name;
 
     ZeroMemory (mrequest);       
         
 // the MA-8 values arrays
   ArraySetAsSeries (maVal, true );
 
   if ( CopyBuffer (maHandle, 0 , 0 , 3 ,maVal)< 0 )
     {
       Alert ( "Error copying Moving Average indicator buffer - error:" , GetLastError ());
       ResetLastError ();
       return ;
     }
 
 
 
 //--- Get the last price quote using the MQL5 MqlTick Structure
   if (! SymbolInfoTick ( _Symbol ,latest_price))
     {
       Alert ( "Error getting the latest price quote - error:" , GetLastError (), "!!" );
       return ;
     }
 
 
/**********************************           BUY POSITION    ************************************************/             
 
   //--- Declare bool type variables to hold our Buy Conditions
   // bool Buy_Condition_1=(rates[0].close > Top);  
     //bool Buy_Condition_1=(latest_price.ask >Top);
    
    
         // any opened Buy position?
         if (isTrade_BUY())
           {
             Alert ( "We already have a Buy Position!!!" );
             return ;     // Don't open a new Buy Position
           }
         ZeroMemory (mrequest);
         ZeroMemory (mresult); 
         mrequest.action = TRADE_ACTION_PENDING ;   // immediate order execution
         mrequest.price = NormalizeDouble (Top+Trigger* _Point , _Digits );           // latest ask price
         mrequest.sl = NormalizeDouble (latest_price.ask - STP* _Point , _Digits ); // Stop Loss
         mrequest.tp = NormalizeDouble (latest_price.ask + TKP* _Point , _Digits ); // Take Profit
       //  mrequest.sl = 0;
       //  mrequest.tp =0;
         mrequest.symbol = _Symbol ;                                             // currency pair
         mrequest.volume = Lot;                                                 // number of lots to trade
         mrequest.magic = EA_Magic;                                             // Order Magic Number
         mrequest.type = ORDER_TYPE_BUY_STOP ;                                   // Buy Order
         mrequest.type_filling = ORDER_FILLING_RETURN ;                             // Order execution type
         mrequest.deviation= 100 ;                                                 // Deviation from current price
         //--- send order
         OrderSend (mrequest,mresult);
       // get the result code
         if (mresult.retcode== 10009 || mresult.retcode== 10008 ) //Request is completed or order placed
           {
             Alert ( "A Buy order has been successfully placed with Ticket#:" ,mresult.order, "!!" );
           }
         else
           {
             Alert ( "The Buy order request could not be completed -error:" , GetLastError ());
             ResetLastError ();           
             return ;
           }
   
      
 /**********************************          SELL POSITION    ************************************************/             
         if (isTrade_SELL())
           {
             Alert ( "We already have a Sell position!!!" );
             return ;     // Don't open a new Sell Position
           }
         ZeroMemory (mrequest);
         ZeroMemory (mresult); 
         mrequest.action= TRADE_ACTION_PENDING ;                               // immediate order execution
         mrequest.price = NormalizeDouble (Bottom-Trigger* _Point , _Digits );             // latest Bid price
         mrequest.sl = NormalizeDouble (latest_price.bid + STP* _Point , _Digits ); // Stop Loss
         mrequest.tp = NormalizeDouble (latest_price.bid - TKP* _Point , _Digits ); // Take Profit
         mrequest.symbol = _Symbol ;                                           // currency pair
         mrequest.volume = Lot;                                               // number of lots to trade
         mrequest.magic = EA_Magic;                                           // Order Magic Number
         mrequest.type= ORDER_TYPE_SELL_STOP ;                                     // Sell Order
         mrequest.type_filling = ORDER_FILLING_RETURN ;                           // Order execution type
         mrequest.deviation= 100 ;                                             // Deviation from current price
         //--- send order
         OrderSend (mrequest,mresult);
         // get the result code
         if (mresult.retcode== 10009 || mresult.retcode== 10008 ) //Request is completed or order placed
           {
             Alert ( "A Sell order has been successfully placed with Ticket#:" ,mresult.order, "!!" );
           }
         else
           {
             Alert ( "The Sell order request could not be completed -error:" , GetLastError ());
             ResetLastError ();
             return ;
           }
          
          
           }

  DeleteAllOrdersPending();
   
    }
   
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer ()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Trade function                                                   |
//+------------------------------------------------------------------+
void OnTrade ()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//---
   double ret= 0.0 ;
//---

//---
   return (ret);
  }
//+------------------------------------------------------------------+
bool isTrade_BUY()
  {
   if ( PositionSelect ( _Symbol )== true && PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_BUY ) // we have an opened position
       {
         return ( true );
        }
  
    
   else 
     {
     return ( false );
     }
  
  }
/////////////////////////////////////////////////////////////////////////////////////


bool isTrade_SELL()
  {
   if ( PositionSelect ( _Symbol )== true && PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_SELL ) // we have an opened position
       {
         return ( true );
        }
  
    
   else 
     {
     return ( false );
     }
  
  }
  
////////////////////////////////////////////////////////////////////////////////////// 
 void DeleteAllOrdersPending()
   {
    
     if (isTrade_SELL()||isTrade_BUY())
     {  
    
     int i;
   // in this loop we're checking all pending orders
       for (i= 0 ;i< OrdersTotal ();i++)
         {
         // choosing each order and getting its ticket
         ulong ticket= OrderGetTicket (i);
           // processing orders with "our" symbols only
           if ( OrderGetString ( ORDER_SYMBOL )== Symbol ())
             {
             // processing Buy Stop orders
             if ( OrderGetInteger ( ORDER_TYPE )== ORDER_TYPE_BUY_STOP )
                {
                 mrequest.action= TRADE_ACTION_REMOVE ;
                 // putting the ticket number to the structure
                 mrequest.order=ticket;
                 // sending request to trade server
                 OrderSend (mrequest,mresult);
                }
        
         // processing Sell Stop orders
             if ( OrderGetInteger ( ORDER_TYPE )== ORDER_TYPE_SELL_STOP )
               {
               // we will delete this pending order
               mrequest.action= TRADE_ACTION_REMOVE ;
               // putting the ticket number to the structure
               mrequest.order=ticket;
               // sending request to trade server
               OrderSend (mrequest,mresult);
                    
               }
           } 
       } //boucle for
      } //if
    }    
 
dan5 :

benim ea 4756 hatası veriyor

bana yardım edebilir misin teşekkürler

2013.03.10 11:19:18 2012.01.04 15:00:00 1.30505 sl'de 1.00 EURUSD alış durdurma başarısız: 1.28375 tp: 1.30375 [Geçersiz duraklar]
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

CopyHigh(_Symbol,_Period,TimeCurrent(),5,hg);

Top = NormalizeDouble(rates[ ArrayMaximum(hg,0,WHOLE_ARRAY) ].high,_Digits); 

- yanlış anlaşılan tasarım.
Maksimum çiftin değerleri arasından seçim yapın ve tamsayı dizini yerine bunu kullanın .

 
dan5 :

benim ea 4756 hatası veriyor

bana yardım edebilir misin teşekkürler

Hata 4756, "Ticaret talebi gönderilemedi". Sipariş gönderirken hata alıyorsanız, MqlTradeResult dönüş kodunu kontrol edin.

         //--- send order
         OrderSend (mrequest,mresult);
         // get the result code
         if (mresult.retcode== 10009 || mresult.retcode== 10008 ) //Request is completed or order placed
           {
             Alert ( "An order has been successfully placed with Ticket#:" ,mresult.order, "!!" );
           }
         else
           {
             Alert ( "The order request could not be completed -error:" , GetLastError (), " with trade return code " ,mresult.retcode );
             ResetLastError ();
             return ;
           }

Yukarıdaki Konstantin83'e göre geçersiz durdurma hatanız var, bu da SymbolInfoInteger SYMBOL_TRADE_STOPS_LEVEL ve SYMBOL_TRADE_FREEZE_LEVEL dışında bekleyen sipariş vermeniz gerektiği anlamına geliyor.

 
phi.nuts :

Hata 4756, "Ticaret talebi gönderilemedi". Sipariş gönderirken hata alıyorsanız, MqlTradeResult dönüş kodunu kontrol edin.

Yukarıdaki Konstantin83'e göre geçersiz durdurma hatanız var, bu da SymbolInfoInteger SYMBOL_TRADE_STOPS_LEVEL ve SYMBOL_TRADE_FREEZE_LEVEL dışında bekleyen sipariş vermeniz gerektiği anlamına geliyor.

Bir ECN tipi Broker için geçersiz duraklar da döndürülür mü?
 
RaptorUK :
Bir ECN tipi Broker için geçersiz duraklar da döndürülür mü?
Cevabın hayır olduğunu elbette biliyorsunuz. Ama bunu neden soruyorsun?
 
phi.nuts :
Cevabın hayır olduğunu elbette biliyorsunuz. Ama bunu neden soruyorsun?
Cevabın hayır olduğunu bildiğimi neden varsayıyorsun? SL veya TP OrderSend() ile bir ECN Broker'a gönderildiğinde mql4'te geçersiz duraklar ( hata 130 ) döndürülür, bu yüzden aynı şeyin mql5 için doğru olup olmadığını soruyordum. Hangi hata döndürülür?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Compilation Errors
Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Compilation Errors
  • www.mql5.com
Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Compilation Errors - Documentation on MQL5
 
RaptorUK :
Cevabın hayır olduğunu bildiğimi neden varsayıyorsun? SL veya TP OrderSend() ile bir ECN Broker'a gönderildiğinde mql4'te geçersiz duraklar ( hata 130 ) döndürülür, bu yüzden aynı şeyin mql5 için doğru olup olmadığını soruyordum. Hangi hata döndürülür?
Gerçekten ? ilginç. Daha sonra kontrol etmeliyim ;D.
 
phi.nuts :
Gerçekten ? ilginç. Daha sonra kontrol etmeliyim ;D.
mql5 ile yolumu bulmaya çalışırken biraz araştırıyorum. Strateji Test Edici davranışı bir Broker tarafından döndürülecek olana benzerse, ENUM_SYMBOL_TRADE_EXECUTION Borsa yürütmesi veya Piyasa yürütmesi olan bir Sembol için gönderildiğinde SL ve TP'nin yok sayıldığı ve hiçbir hata döndürülmediği görülüyor. Yani işler mql4 ile karşılaştırıldığında oldukça farklı.
 
RaptorUK :
mql5 ile yolumu bulmaya çalışırken biraz araştırıyorum. Strateji Test Edici davranışı bir Broker tarafından döndürülecek olana benzerse, ENUM_SYMBOL_TRADE_EXECUTION Borsa yürütmesi veya Piyasa yürütmesi olan bir Sembol için gönderildiğinde SL ve TP'nin yok sayıldığı ve hiçbir hata döndürülmediği görülüyor. Yani işler mql4 ile karşılaştırıldığında oldukça farklı.

Geçersiz Duraklarla ilgili bulduğum başka bir şey. Sembol, Borsa veya Piyasa yürütmesi olmadıkça SL & TP ile işlem yapan basit bir EA'm var, ardından SL & TP ayarlanmamış olarak işlemi gönderiyor ve ardından SL & TP'yi ayarlamak için (TRADE_ACTION_SLTP)'ye ikinci bir istek gönderiyor.

Strateji test cihazında iyi çalışıyor, bu yüzden bugün bir Demo hesabında denedim ve Geçersiz Duraklar almaya devam ettim (hata 10016). Durdurma Seviyesini ve Donma Seviyesini kontrol ettim, ikisi de 0, çeşitli SL & TP seviyelerini denedim, hiçbir şey işe yaramadı. Aynı SL & TP'yi mevcut bir pozisyon için sorunsuz bir şekilde manuel olarak ayarlayabilirim. . . bu yüzden sadece pozisyon seçilebilirse SL & TP'yi yerleştirmek için bir test ekledim. . . ve artık Geçersiz Durdurma yok, artık TRADE_ACTION_SLTP ticaret talebi de yok :-(

Bu kodu, TP & SL olmadan gönderilen ilk ticaret talebinin tamamlanması ile TP & SL'yi gönderen sonraki ticaret talebinin arasına ekledim. . .

         SelectRetryCount = 1 ;
         if (SetTPandSL)
            {
             while (! PositionSelect ( _Symbol ) && SelectRetryCount < 10 )
               {
               Sleep (SelectRetryCount * 100 ); // sleep for SelectRetryCount * 100 mS
               SelectRetryCount++;
               }
            }

SetTPandSL, ilk ticaret talebi başarılıysa doğru olarak ayarlanır, değilse bir TP & SL ayarlamaya çalışmanın bir anlamı yoktur. Konum seçilir ve 100 mS uyku başarısız olursa, seçim yeniden denenir, bu başarısız olursa 200 mS uyku gerçekleşir, vb. 9 denemeye kadar (toplam 4,5 saniye).

Henüz mql5 ile ne yaptığımı gerçekten bilmiyorum, gerçekten sadece birkaç şeyi çalıştırmaya çalışmaktan ve ilerledikçe öğrenmeyi ummaktan bahsediyorum. . . Burada bulduğum şey normal davranış mı? İlk ticaret talebi 10009 - TRADE_RETCODE_DONE döndüğünde TP & SL'yi ayarlamak için istek göndermemin uygun olacağını düşünmüştüm, durum bu değil mi? kimse biliyor mu ?

 
RaptorUK :

Geçersiz Duraklar ile ilgili bulduğum başka bir şey. Sembol Borsa veya Piyasa yürütmesi olmadıkça SL & TP ile işlem yapan basit bir EA'm var, ardından SL & TP ayarlanmamış olarak ticareti gönderir ve ardından SL & TP'yi ayarlamak için (TRADE_ACTION_SLTP)'ye ikinci bir istek gönderir.

Strateji test cihazında iyi çalışıyor, bu yüzden bugün bir Demo hesabında denedim ve Geçersiz Duraklar almaya devam ettim (hata 10016). Durdurma Seviyesini ve Donma Seviyesini kontrol ettim, ikisi de 0, çeşitli SL & TP seviyelerini denedim, hiçbir şey işe yaramadı. Aynı SL & TP'yi mevcut bir pozisyon için sorunsuz bir şekilde manuel olarak ayarlayabilirim. . . bu yüzden sadece pozisyon seçilebilirse SL & TP'yi yerleştirmek için bir test ekledim. . . ve artık Geçersiz Durdurma yok, artık TRADE_ACTION_SLTP ticaret talebi de yok :-(

Bu kodu, TP & SL olmadan gönderilen ilk ticaret talebinin tamamlanması ile TP & SL'yi gönderen sonraki ticaret talebinin arasına ekledim. . .

SetTPandSL, ilk ticaret talebi başarılıysa doğru olarak ayarlanır, değilse bir TP & SL ayarlamaya çalışmanın bir anlamı yoktur. Konum seçilir ve 100 mS uyku başarısız olursa, seçim yeniden denenir, bu başarısız olursa 200 mS uyku gerçekleşir, vb. 9 denemeye kadar (toplam 4,5 saniye).

Henüz mql5 ile ne yaptığımı gerçekten bilmiyorum, gerçekten sadece birkaç şeyi çalıştırmaya çalışmaktan ve ilerledikçe öğrenmeyi ummaktan bahsediyorum. . . Burada bulduğum şey normal davranış mı? İlk ticaret talebi 10009 - TRADE_RETCODE_DONE döndüğünde TP & SL'yi ayarlamak için istek göndermemin uygun olacağını düşünmüştüm, durum bu değil mi? kimse biliyor mu ?

Siparişlerinizi göndermek/değiştirmek için hangi işlevi , sınıfları/yöntemi kullanıyorsunuz?