genel başlatma başarısız !!!!!!! - sayfa 4

 
deysmacro :

Nesnenin zaten var olup olmadığını kontrol etmek için herhangi bir nesne bulma işlevi koymazsınız. Oradan, nesneyi buna göre yaratırsınız.


Şu anda sana yardım ediyorum.


Şimdi, bu OnInit()'i temizlemek için iyi bir ipucu, teşekkürler.

Yukarıdaki sorunlardan herhangi birini gerçekten çözdüğünden değil, biliyorsunuz.

Etiketler hala yerine kilitlenmiyor.

Yaptığım onca şeyden sonra daha iyi ama yine de mükemmel değil.

Sorunun çok daha derin olduğunu ve verilerin temizlenmemesiyle ilgili olduğunu düşünüyorum.

Sanki bir şekilde MT4, bazı temizlenmemiş kayıtlardan bazı eski verileri aldı.

 

Sadece ipuçları verdiğim için özür dilerim çünkü kodlamada son nokta aslında kodlamayı yapandır.

Ne yazık ki, çoğu verilen ipucunu anlamıyor/almıyor.

 
qjol :



1. Etiketler, XDISTANCE ve YDISTANCE kurallarına uyulmamış gibi çizginin dışına çıkıyor.

Yalnızca Tf'leri ileri geri değiştirdikten sonra sıraya girerler.

Grafik pencerelerini değiştirdikten veya parametre girişini değiştirdikten sonra hat dışına çıkarlar.

bu, kodunuzda düzeltebileceğiniz anlamına gelir

Çok şey yaptım, hiçbir şey yardımcı olmuyor.

Daha iyi olur, ama yine de, yani. X,Y değil, parametrelerdeki smth'yi değiştirdikten sonra, etiket çizgiyi aşıyor!

 //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

extern double StopLoss    = 30 ;
extern double RiskPercent = 3 ;
extern int Corner = 3 ;
extern int Font_Size = 13 ;
extern string Font_Type = "Berlin Sans FB" ;
extern color Font_Color = clrSnow ;
extern color Warning_Color = clrRed ;
extern int XDistance = 9 ;
extern int YDistance = 27 ;
string   comment;
int X,Y;


int OnInit ()   {   
 X = XDistance;
 Y = YDistance;
if ( ObjectFind ( "Lot_Size_Label" )== 0 )
 {
 ObjectDelete ( "Lot_Size_Label" );
 }
ObjectCreate ( "Lot_Size_Label" , OBJ_LABEL , 0 , 0 , 0 ); return ( 0 ); 
  }

//-------------------------------------------------------------+
  
int OnDeinit ( int reason) 
  {
   ObjectDelete ( "Lot_Size_Label" ); 
   return ( 0 ); 
  }

//-------------------------------------------------------------+
int start()  
{
       string AcctCurrency = AccountCurrency ();
       
       if (AcctCurrency == "" )
           return ( 0 );
 X = XDistance;
 Y = YDistance;
           
   double pipValue = MarketInfo ( Symbol (), MODE_TICKVALUE ); 
   if ( Digits == 3 || Digits == 5 ) pipValue *= 10 ;
   double step     = MarketInfo ( Symbol (), MODE_LOTSTEP );
       int norm     = 0 ;
             if (step== 1 )    norm = 0 ;
             if (step== 0.1 )  norm = 1 ;
             if (step== 0.01 ) norm = 2 ;
   double minLot = MarketInfo ( Symbol (), MODE_MINLOT );
   double maxLot = MarketInfo ( Symbol (), MODE_MAXLOT );
   if (pipValue!= 0 )
    {
   double lots   = AccountBalance ()*(RiskPercent/ 100.0 )/(StopLoss*pipValue);
    }
         lots   = NormalizeDouble (lots,norm);
          
         comment = "SL(" + DoubleToStr (RiskPercent, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (lots,norm)+ " Lot" ;
          
           double actualRisk,maxRiskSL; 
           if (lots<minLot)
            {
               actualRisk = ( 100 *minLot*StopLoss*pipValue)/ AccountBalance ();
               if (RiskPercent<= 0 ) RiskPercent= 1 ;
               maxRiskSL = StopLoss/(actualRisk/RiskPercent);
               comment = "SL(" + DoubleToStr (actualRisk, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (minLot,norm)+ " Lot" + "  SL(" + IntegerToString (RiskPercent, 0 )+ "%): " + IntegerToString (maxRiskSL, 0 )+ " Pts" ;
               Font_Color=Warning_Color;
            }
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_CORNER ,Corner);

   ObjectSet     ( "Lot_Size_Label" , OBJPROP_XDISTANCE ,X);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_YDISTANCE ,Y);
   ObjectSetText ( "Lot_Size_Label" ,comment,Font_Size,Font_Type,Font_Color);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_SELECTABLE , false ); 
 
   return ( 0 );
}

Kodda yanlış bir şey var mı?



 
Dadas :


Kodda yanlış bir şey var mı?


zaten söylendi unut gitsin

 int start()  

yeni yöntemleri kullanmaya başlayın

 int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {

daymacro zaten yukarıda yazılı

ObjectFind() göremiyorum

 if ( ObjectFind (....) == xxx, or != yyy ...)
   {
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_CORNER ,Corner);
   
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_XDISTANCE ,X);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_YDISTANCE ,Y);
   ObjectSetText ( "Lot_Size_Label" ,comment,Font_Size,Font_Type,Font_Color);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_SELECTABLE , false ); 
   }
else
   {
   do something maybe GetLastError() ??
   }
 
qjol :

zaten söylendi unut gitsin

yeni yöntemleri kullanmaya başlayın

daymacro zaten yukarıda yazılı

ObjectFind() göremiyorum



Ben de yaptım:

 //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

extern double StopLoss    = 30 ;
extern double RiskPercent = 3 ;
extern int Corner = 3 ;
extern int Font_Size = 13 ;
extern string Font_Type = "Berlin Sans FB" ;
extern color Font_Color = clrSnow ;
extern color Warning_Color = clrRed ;
extern int XDistance = 9 ;
extern int YDistance = 27 ;
string   comment;
int X,Y;
//
//
//
//
//

int OnInit ()   {   
 X = XDistance;
 Y = YDistance;
if ( ObjectFind ( "Lot_Size_Label" )== 0 )
 {
 ObjectDelete ( "Lot_Size_Label" );
 }
ObjectCreate ( "Lot_Size_Label" , OBJ_LABEL , 0 , 0 , 0 ); 

   return ( INIT_SUCCEEDED ); 
  }
  
void OnDeinit ( const int reason) 
  {
   ObjectDelete ( "Lot_Size_Label" ); 
  }

int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime & time[],
                 const double & open[],
                 const double & high[],
                 const double & low[],
                 const double & close[],
                 const long & tick_volume[],
                 const long & volume[],
                 const int & spread[])
 {                
       string AcctCurrency = AccountCurrency ();
       
       if (AcctCurrency == "" )
           return (rates_total);
          
 X = XDistance;
 Y = YDistance;
           
   double pipValue = MarketInfo ( Symbol (), MODE_TICKVALUE ); 
   if ( Digits == 3 || Digits == 5 ) pipValue *= 10 ;
   double step     = MarketInfo ( Symbol (), MODE_LOTSTEP );
       int norm     = 0 ;
             if (step== 1 )    norm = 0 ;
             if (step== 0.1 )  norm = 1 ;
             if (step== 0.01 ) norm = 2 ;
   double minLot = MarketInfo ( Symbol (), MODE_MINLOT );
   double maxLot = MarketInfo ( Symbol (), MODE_MAXLOT );
   if (pipValue!= 0 )
    {
   double lots   = AccountBalance ()*(RiskPercent/ 100.0 )/(StopLoss*pipValue);
    }
         lots   = NormalizeDouble (lots,norm);
          
           //
           //
           //
           //
           //
          comment = "SL(" + DoubleToStr (RiskPercent, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (lots,norm)+ " Lot" ;
          
           double actualRisk,maxRiskSL; 
           if (lots<minLot)
            {
               actualRisk = ( 100 *minLot*StopLoss*pipValue)/ AccountBalance ();
               if (RiskPercent<= 0 ) RiskPercent= 1 ;
               maxRiskSL = StopLoss/(actualRisk/RiskPercent);
               comment = "SL(" + DoubleToStr (actualRisk, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (minLot,norm)+ " Lot" + "  SL(" + IntegerToString (RiskPercent, 0 )+ "%): " + IntegerToString (maxRiskSL, 0 )+ " Pts" ;
               Font_Color=Warning_Color;
            }
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_CORNER ,Corner);

   ObjectSet     ( "Lot_Size_Label" , OBJPROP_XDISTANCE ,X);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_YDISTANCE ,Y);
   ObjectSetText ( "Lot_Size_Label" ,comment,Font_Size,Font_Type,Font_Color);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_SELECTABLE , false );  
   return (rates_total);
}

Yine aynı etki. Bu, etiket konumlandırma açısından hiçbir şeyi değiştirmedi.

ObjectFind(), OnInit() içinde, nesnenin orada olup olmadığını kontrol eder ve varsa onu siler.

Bireysel başlatma üzerindeki etiket, olması gereken yerdedir.

Bazı parametreleri değiştirdikten sonra sağa doğru kaybolur.

Sadece Tf vites değiştirdikten sonra yerine geri atlar.

 
Aslında, ilk yükleme sırasında ilk nesne seti ve yüklemeden sonra ikinci nesne seti (toz çöker) gibi bir şeye ihtiyacınız var. Ben de aynı sorunu yaşadım, dediğim gibi sorunu çözdüm. Daha çok bir geçici çözüm gibi ama hepsi benim için yeterince iyi.
 
deysmacro :
Aslında, ilk yükleme sırasında ilk nesne seti ve yüklemeden sonra ikinci nesne seti (toz çöker) gibi bir şeye ihtiyacınız var. Ben de aynı sorunu yaşadım, dediğim gibi sorunu çözdüm. Daha çok bir geçici çözüm gibi ama hepsi benim için yeterince iyi.

Bu yüzden, kodların farklı olması durumunda etiketi sıfırlamak için X, Y kodlarını yeniden kontrol etmeyi bile sevdim.

Meyve suyu yok, hiçbir şey değişmiyor, aynen yukarıdaki gibi davranıyor.

 //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

extern double StopLoss    = 30 ;
extern double RiskPercent = 3 ;
extern int Corner = 3 ;
extern int Font_Size = 13 ;
extern string Font_Type = "Berlin Sans FB" ;
extern color Font_Color = clrSnow ;
extern color Warning_Color = clrRed ;
extern int XDistance = 9 ;
extern int YDistance = 27 ;
string   comment;
int X,Y;
//
//
//
//
//

int OnInit ()   {   
 X = XDistance;
 Y = YDistance;
if ( ObjectFind ( "Lot_Size_Label" )== 0 )
 {
 ObjectDelete ( "Lot_Size_Label" );
 }
   ObjectCreate ( "Lot_Size_Label" , OBJ_LABEL , 0 , 0 , 0 ); 
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_CORNER ,Corner);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_XDISTANCE ,X);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_YDISTANCE ,Y);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_SELECTABLE , false );    
  
   return ( INIT_SUCCEEDED ); 
  }
  
void OnDeinit ( const int reason) 
  {
   ObjectDelete ( "Lot_Size_Label" ); 
  }

int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime & time[],
                 const double & open[],
                 const double & high[],
                 const double & low[],
                 const double & close[],
                 const long & tick_volume[],
                 const long & volume[],
                 const int & spread[])
 {                
       string AcctCurrency = AccountCurrency ();
       
       if (AcctCurrency == "" )
           return (rates_total);
          
 X = XDistance;
 Y = YDistance;
           
   double pipValue = MarketInfo ( Symbol (), MODE_TICKVALUE ); 
   if ( Digits == 3 || Digits == 5 ) pipValue *= 10 ;
   double step     = MarketInfo ( Symbol (), MODE_LOTSTEP );
       int norm     = 0 ;
             if (step== 1 )    norm = 0 ;
             if (step== 0.1 )  norm = 1 ;
             if (step== 0.01 ) norm = 2 ;
   double minLot = MarketInfo ( Symbol (), MODE_MINLOT );
   double maxLot = MarketInfo ( Symbol (), MODE_MAXLOT );
   if (pipValue!= 0 )
    {
   double lots   = AccountBalance ()*(RiskPercent/ 100.0 )/(StopLoss*pipValue);
    }
         lots   = NormalizeDouble (lots,norm);
          
           //
           //
           //
           //
           //
          comment = "SL(" + DoubleToStr (RiskPercent, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (lots,norm)+ " Lot" ;
          
           double actualRisk,maxRiskSL; 
           if (lots<minLot)
            {
               actualRisk = ( 100 *minLot*StopLoss*pipValue)/ AccountBalance ();
               if (RiskPercent<= 0 ) RiskPercent= 1 ;
               maxRiskSL = StopLoss/(actualRisk/RiskPercent);
               comment = "SL(" + DoubleToStr (actualRisk, 2 )+ "%): " + DoubleToStr (StopLoss, 0 )+ " Pts  Vol: " + DoubleToStr (minLot,norm)+ " Lot" + "  SL(" + IntegerToString (RiskPercent, 0 )+ "%): " + IntegerToString (maxRiskSL, 0 )+ " Pts" ;
               Font_Color=Warning_Color;
            }
            
   if ( ObjectFind ( "Lot_Size_Label" )== 0 )
   {         
   int x_check= ObjectGet ( "Lot_Size_Label" , OBJPROP_XDISTANCE );
   int y_check= ObjectGet ( "Lot_Size_Label" , OBJPROP_YDISTANCE );  
   }  

   if (X!=x_check||Y!=y_check)
   {            
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_CORNER ,Corner);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_XDISTANCE ,X);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_YDISTANCE ,Y);
   ObjectSetText ( "Lot_Size_Label" ,comment,Font_Size,Font_Type,Font_Color);
   ObjectSet     ( "Lot_Size_Label" , OBJPROP_SELECTABLE , false );  
   }
   return (rates_total);
}
PS. this didn't happen in B625, only started with B646 update.

	          
 
Peki, daha yapıldı mı?
 

Ve komik olan, Comment() kullanarak , etiket doğru gittiğinde bile kodlar asla değişmez.

Böylece sorun kalır, yapılmaz.

 
Comment() çoğu zaman grafiği etkilemez.