uzman danışman - çeşitli sorular - sayfa 25

 

Sürüklemeler bittikten sonra OBJPROP_SELECTED , aşağıdaki kodla "yanlış" olabilir, efekt yok.

Nasıl çözebilirim lütfen?

if (id== CHARTEVENT_OBJECT_DRAG )
  {
   SL_TPdrags();

   Sleep ( 1000 );
   drag_onoff= false ; // OBJPROP_SELECTED
  }

Şimdiden teşekkürler.

 
Üzgünüm, asla CHARTEVENT_OBJECT_DRAG kullanmadım.
 
Marco vd Heijden :
Üzgünüm, asla CHARTEVENT_OBJECT_DRAG kullanmadım.
TAMAM! Yine de teşekkürler!
 

Günün sonunda, ikisi birlikte hareket eden " OBJ_LABEL ve OBJ_RECTANGLE_LABEL " yerine ikisini de kullanabileceğimi düşündüğüm " OBJ_RECTANGLE ve OBJ_TEXT " bulundu Teklif satırı.

S: Peki, Teklif satırlarını birlikte hareket ettirmek için çok yararlı olan nesneler, lütfen?

Gerçekten bilgilendirici yoruma ihtiyacım var.
İyi hafta sonları.

 

İD

 

Tanım

OBJ_VLINE

Dikey çizgi

OBJ_HLINE

Yatay çizgi

OBJ_TREND

Trend Çizgisi

OBJ_TRENDBYANGLE

Açıya Göre Trend Çizgisi

OBJ_CYCLES

Döngü Çizgileri

OBJ_ARROWED_LINE

oklu çizgi

OBJ_CHANNEL

eşit mesafeli kanal

OBJ_STDDEVCHANNEL

Standart Sapma Kanalı

OBJ_REGRESSION

Doğrusal Regresyon Kanalı

OBJ_PITCHFORK

Andrews'in Dirgen

OBJ_GANNLINE

Gann Hattı

OBJ_GANNFAN

Gann Hayranı

OBJ_GANNGRID

Gann Izgarası

OBJ_FIBO

Fibonacci Düzeltme

OBJ_FIBOTIMES

Fibonacci Zaman Dilimleri

OBJ_FIBOFAN

Fibonacci Yelpazesi

OBJ_FIBOARC

Fibonacci Yayları

OBJ_FIBOCHANNEL

Fibonacci Kanalı

OBJ_GENİŞLETME

Fibonacci Genişlemesi

OBJ_ELLIOTWAVE5

Elliott Motif Dalga

OBJ_ELLIOTWAVE3

Elliott Düzeltme Dalgası

OBJ_RECTANGLE

Dikdörtgen

OBJ_TRIANGLE

Üçgen

OBJ_ELLIPSE

Elips

OBJ_ARROW_THUMB_UP

Başparmak havaya

OBJ_ARROW_THUMB_DOWN

Başparmak Aşağı

OBJ_ARROW_UP

Yukarı ok

OBJ_ARROW_DOWN

Aşağı ok

OBJ_ARROW_STOP

Dur işareti

OBJ_ARROW_CHECK

İşareti Kontrol Et

OBJ_ARROW_LEFT_PRICE

Sol Fiyat Etiketi

OBJ_ARROW_RIGHT_PRICE

Doğru Fiyat Etiketi

OBJ_ARROW_BUY

Satın Al işareti

OBJ_ARROW_SELL

Satış İşareti

OBJ_OK

Ok

OBJ_TEXT

Metin

OBJ_LABEL

Etiket

OBJ_BUTTON

Buton

OBJ_CHART

Çizelge

OBJ_BITMAP

bit eşlem

OBJ_BITMAP_LABEL

Bitmap Etiketi

OBJ_EDIT

Düzenlemek

OBJ_EVENT

Ekonomik takvimdeki bir olaya karşılık gelen "Olay" nesnesi

OBJ_RECTANGLE_LABEL

Özel grafik arayüzü oluşturmak ve tasarlamak için "Dikdörtgen etiket" nesnesi.


Birlikte hareket etmekle ne demek istediniz?

 
Max Enrik :

Sürüklemeler bittikten sonra OBJPROP_SELECTED , aşağıdaki kodla "yanlış" olabilir, efekt yok.

Nasıl çözebilirim lütfen?

if (id== CHARTEVENT_OBJECT_DRAG )
  {
   SL_TPdrags();

   Sleep ( 1000 );
   drag_onoff= false ; // OBJPROP_SELECTED
  }

Şimdiden teşekkürler.

Sparam'ı daha fazla test etmediğiniz sürece, herhangi bir nesne sürüklendiğinde bu kod tetiklenir.

Orijinal kodum:

void OnChartEvent ( const int id, const long & lparam, const double & dparam, const string & sparam)
  {
   if (id== CHARTEVENT_OBJECT_DRAG && sparam== "line" ) // the chart event of dragging the line
 
@Marco vd Heijden

CrossHair.mq4 harika örneklerinden birini zaten biliyorum / okudum.
Ancak Label, RectLabel Objects'e Teklif fiyatı vermekte zorlanıyorum. Etiketlemeye çalışıyorum, RectLabel Nesneleri Teklif Satırı ile birlikte hareket ediyor.

Sadece görüntüye ihtiyacım var, lütfen ek dosyasını bulun.

Herşey gönlünce olsun.

 

Sabit boyutlu nesneler için: OBJ_BUTTON, OBJ_RECTANGLE_LABEL ve OBJ_EDIT, OBJPROP_XDISTANCE ve OBJPROP_YDISTANCE özellikleri, X ve Y koordinatlarının piksel olarak sayılacağı grafik köşesine (OBJPROP_CORNER) göre nesnenin sol üst noktasının konumunu ayarlar.

//+------------------------------------------------------------------+
//|                                                    rectangle.mq4 |
//|      Copyright 2017, Marco vd Heijden, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Marco vd Heijden, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- create timer
   EventSetTimer ( 1 );
//--- create rectangle
   RectangleCreate( 0 , "Rectangle" , 0 , 0 , 0 );  
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//--- destroy timer
   EventKillTimer ();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
//---
   RectanglePointChange( 0 , "Rectangle" , 0 , TimeCurrent (), Ask );
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer ()
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Create rectangle by the given coordinates                        |
//+------------------------------------------------------------------+
bool RectangleCreate( const long             chart_ID= 0 ,         // chart's ID
                     const string           name= "Rectangle" ,   // rectangle name
                     const int              sub_window= 0 ,       // subwindow index
                     datetime               time1= 0 ,           // first point time
                     double                 price1= 0 ,           // first point price
                     datetime               time2= 0 ,           // second point time
                     double                 price2= 0 ,           // second point price
                     const color            clr= clrRed ,         // rectangle color
                     const ENUM_LINE_STYLE style= STYLE_SOLID , // style of rectangle lines
                     const int              width= 1 ,           // width of rectangle lines
                     const bool             fill= false ,         // filling rectangle with color
                     const bool             back= false ,         // in the background
                     const bool             selection= true ,     // highlight to move
                     const bool             hidden= true ,       // hidden in the object list
                     const long             z_order= 0 )         // priority for mouse click
  {
//--- set anchor points' coordinates if they are not set
   ChangeRectangleEmptyPoints(time1,price1,time2,price2);
//--- reset the error value
   ResetLastError ();
//--- create a rectangle by the given coordinates
   if (! ObjectCreate (chart_ID,name, OBJ_RECTANGLE ,sub_window,time1,price1,time2,price2))
     {
       Print ( __FUNCTION__ ,
             ": failed to create a rectangle! Error code = " , GetLastError ());
       return ( false );
     }
//--- set rectangle color
   ObjectSetInteger (chart_ID,name, OBJPROP_COLOR ,clr);
//--- set the style of rectangle lines
   ObjectSetInteger (chart_ID,name, OBJPROP_STYLE ,style);
//--- set width of the rectangle lines
   ObjectSetInteger (chart_ID,name, OBJPROP_WIDTH ,width);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger (chart_ID,name, OBJPROP_BACK ,back);
//--- enable (true) or disable (false) the mode of highlighting the rectangle for moving
//--- when creating a graphical object using ObjectCreate function, the object cannot be
//--- highlighted and moved by default. Inside this method, selection parameter
//--- is true by default making it possible to highlight and move the object
   ObjectSetInteger (chart_ID,name, OBJPROP_SELECTABLE ,selection);
   ObjectSetInteger (chart_ID,name, OBJPROP_SELECTED ,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger (chart_ID,name, OBJPROP_HIDDEN ,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger (chart_ID,name, OBJPROP_ZORDER ,z_order);
//--- successful execution
   return ( true );
  }
//+------------------------------------------------------------------+
//| Move the rectangle anchor point                                  |
//+------------------------------------------------------------------+
bool RectanglePointChange( const long    chart_ID= 0 ,       // chart's ID
                           const string name= "Rectangle" , // rectangle name
                           const int     point_index= 0 ,     // anchor point index
                           datetime      time= 0 ,           // anchor point time coordinate
                           double        price= 0 )           // anchor point price coordinate
  {
//--- if point position is not set, move it to the current bar having Bid price
   if (!time)
      time= TimeCurrent ();
   if (!price)
      price= SymbolInfoDouble ( Symbol (), SYMBOL_BID );
//--- reset the error value
   ResetLastError ();
//--- move the anchor point
   if (! ObjectMove (chart_ID,name,point_index,time,price))
     {
       Print ( __FUNCTION__ ,
             ": failed to move the anchor point! Error code = " , GetLastError ());
       return ( false );
     }
//--- successful execution
   return ( true );
  }
//+------------------------------------------------------------------+
//| Check the values of rectangle's anchor points and set default    |
//| values for empty ones                                            |
//+------------------------------------------------------------------+
void ChangeRectangleEmptyPoints( datetime &time1, double &price1,
                                 datetime &time2, double &price2)
  {
//--- if the first point's time is not set, it will be on the current bar
   if (!time1)
      time1= TimeCurrent ();
//--- if the first point's price is not set, it will have Bid value
   if (!price1)
      price1= SymbolInfoDouble ( Symbol (), SYMBOL_BID );
//--- if the second point's time is not set, it is located 9 bars left from the second one
   if (!time2)
     {
       //--- array for receiving the open time of the last 10 bars
       datetime temp[ 10 ];
       CopyTime ( Symbol (), Period (),time1, 10 ,temp);
       //--- set the second point 9 bars left from the first one
      time2=temp[ 0 ];
     }
//--- if the second point's price is not set, move it 300 points lower than the first one
   if (!price2)
      price2=price1- 300 * SymbolInfoDouble ( Symbol (), SYMBOL_POINT );
  }
//+------------------------------------------------------------------+
 
honest_knave :

Sparam'ı daha fazla test etmediğiniz sürece, herhangi bir nesne sürüklendiğinde bu kod tetiklenir.
Orijinal kodum:

void OnChartEvent ( const int id, const long & lparam, const double & dparam, const string & sparam)
  {
   if (id== CHARTEVENT_OBJECT_DRAG && sparam== "line" ) // the chart event of dragging the line
Ben zaten aşağıdaki kod gibi denedim.
if (id== CHARTEVENT_OBJECT_DRAG && sparam== "#" + IntegerToString ( OrderTicket ())+ "-TP" )
  {
// here was my functions
  }

Bu bana cevap değildi.

---

Ama aşağıdaki kodu kullanıyorum, bu benim için kodunuzu çok az değiştiriyorum - ve hangisini istediğim benim için mükemmel çalışıyor. Şu ana kadar herhangi bir problem ile karşılaşmadım.
Yanlış mı yapıyorum lütfen?

if (id== CHARTEVENT_OBJECT_DRAG ){}

Herşey gönlünce olsun.

 

Belki bu yardımcı olacaktır.

Bunu bir grafiğe ekleyin ve göreceksiniz:

  • Hat her taşındığında bir uyarı (yeni fiyatla birlikte).
  • Hattın taşınması ile uyarı arasında gecikme olmaz.
  • Başka bir şey hareket ettiğinde uyarı yok.
  • Hat gerçekten taşınırken uyarı yok.

#property strict
#property indicator_chart_window

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
   ObjectCreate ( 0 , "MyLine" , OBJ_HLINE , 0 , 0 , Bid );
   ObjectSetInteger ( 0 , "MyLine" , OBJPROP_SELECTED , true );
   return ( INIT_SUCCEEDED );
  }

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
   ObjectDelete ( 0 , "MyLine" );  
  }

//+------------------------------------------------------------------+
//| OnChartEvent()                                                   |

//+------------------------------------------------------------------+
void
OnChartEvent ( const int id,
                   const long & lparam,
                   const double & dparam,
                   const string & sparam)
  {
   if (id== CHARTEVENT_OBJECT_DRAG && sparam== "MyLine" )
     {
       double price= ObjectGetDouble ( 0 , "MyLine" , OBJPROP_PRICE , 0 );
       Alert ( "MyLine moved! New price is " + DoubleToStr (price, _Digits ));
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {

   return (rates_total);
  }
Neden: