전문 고문 - 기타 질문 - 페이지 25

 

드래그가 완료된 후 OBJPROP_SELECTED 가 아래 코드로 "거짓"이 될 수 있으며 효과가 없습니다.

어떻게 해결할 수 있습니까?

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

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

미리 감사드립니다.

 
죄송합니다. 저는 CHARTEVENT_OBJECT_DRAG 를 사용하지 않습니다.
 
Marco vd Heijden :
죄송합니다. 저는 CHARTEVENT_OBJECT_DRAG 를 사용하지 않습니다.
확인! 어쨌든 감사합니다!
 

하루가 끝나면 " OBJ_RECTANGLE 및 OBJ_TEXT "를 찾았습니다. 둘 다 함께 이동하는 " OBJ_LABEL 및 OBJ_RECTANGLE_LABEL " 대신에 둘 다 사용할 수 있다고 생각합니다. 입찰 라인.

Q: 입찰 라인을 함께 이동하는 데 매우 유용한 개체는 무엇입니까?

정말 유익한 댓글이 필요합니다.
좋은 주말 되세요.

 

ID

 

설명

OBJ_VLINE

수직선

OBJ_HLINE

수평선

OBJ_TREND

추세선

OBJ_TRENDBYANGLE

각도별 추세선

OBJ_CYCLES

사이클 라인

OBJ_ARROWED_LINE

화살표 선

OBJ_CHANNEL

등거리 수로

OBJ_STDDEVCHANNEL

표준편차 채널

OBJ_REGRESSION

선형 회귀 채널

OBJ_PITCHFORK

앤드류스 피치포크

OBJ_GANNLINE

간 라인

OBJ_GANNFAN

간 팬

OBJ_GANNGRID

간 그리드

OBJ_FIBO

피보나치 되돌림

OBJ_FIBOTIMES

피보나치 시간대

OBJ_FIBOFAN

피보나치 팬

OBJ_FIBOARC

피보나치 호

OBJ_FIBOCHANNEL

피보나치 수로

OBJ_EXPANSION

피보나치 확장

OBJ_ELLIOTWAVE5

엘리엇 동기 웨이브

OBJ_ELLIOTWAVE3

엘리엇 수정파

OBJ_RECTANGLE

직사각형

OBJ_TRIANGLE

삼각형

OBJ_ELLIPSE

타원

OBJ_ARROW_THUMB_UP

엄지손가락

OBJ_ARROW_THUMB_DOWN

아래로

OBJ_ARROW_UP

위쪽 화살표

OBJ_ARROW_DOWN

아래쪽 화살표

OBJ_ARROW_STOP

정지 신호

OBJ_ARROW_CHECK

서명 확인

OBJ_ARROW_LEFT_PRICE

왼쪽 가격 라벨

OBJ_ARROW_RIGHT_PRICE

올바른 가격 라벨

OBJ_ARROW_BUY

사인 구매

OBJ_ARROW_SELL

판매 사인

OBJ_ARROW

화살

OBJ_TEXT

텍스트

OBJ_LABEL

상표

OBJ_BUTTON

단추

OBJ_차트

차트

OBJ_BITMAP

비트맵

OBJ_BITMAP_LABEL

비트맵 레이블

OBJ_EDIT

편집하다

OBJ_EVENT

경제 달력의 이벤트에 해당하는 "이벤트" 개체

OBJ_RECTANGLE_LABEL

사용자 지정 그래픽 인터페이스를 만들고 디자인하기 위한 "사각형 레이블" 개체입니다.


함께 움직인다는 것은 무엇을 의미합니까?

 
Max Enrik :

드래그가 완료된 후 OBJPROP_SELECTED 가 아래 코드로 "거짓"이 될 수 있으며 효과가 없습니다.

어떻게 해결할 수 있습니까?

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

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

미리 감사드립니다.

추가로 스팸을 테스트하지 않는 한 해당 코드 개체를 끌 때 트리거됩니다.

내 원래 코드:

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
 
@마르코 vd 하이덴

나는 이미 CrossHair.mq4의 훌륭한 예 중 하나를 알고/읽었습니다.
그러나 나는 Label, RectLabel Objects에 입찰 가격을 주기 위해 고군분투하고 있습니다. 내가 레이블을 지정하려고 하는 것은 RectLabel Objects가 Bid Line과 함께 움직입니다.

이미지와 같이 필요하니 첨부파일을 찾아주세요.

모두 제일 좋다.

 

고정 크기 개체의 경우: OBJ_BUTTON, OBJ_RECTANGLE_LABEL 및 OBJ_EDIT, 속성 OBJPROP_XDISTANCE 및 OBJPROP_YDISTANCE는 X 및 Y 좌표가 픽셀 단위로 계산되는 차트 모서리(OBJPROP_CORNER)를 기준으로 개체의 왼쪽 상단 지점 위치를 설정합니다.

//+------------------------------------------------------------------+
//|                                                    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 :

추가로 스팸을 테스트하지 않는 한 해당 코드 개체를 끌 때 트리거됩니다.
내 원래 코드:

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
나는 이미 아래 코드와 같이 시도했습니다.
if (id== CHARTEVENT_OBJECT_DRAG && sparam== "#" + IntegerToString ( OrderTicket ())+ "-TP" )
  {
// here was my functions
  }

그것은 나에 대한 반응이 아니었다.

---

그러나 나는 당신의 코드를 약간 변경하는 아래 코드와 같이 사용합니다. 그리고 그것은 내가 원하는 것을 완벽하게 작동합니다. 지금까지 나는 어떤 문제에 직면하지 않았습니다.
내가 잘못하고 있습니까?

if (id== CHARTEVENT_OBJECT_DRAG ){}

모두 제일 좋다.

 

아마도 이것이 도움이 될 것입니다.

이것을 차트에 추가하면 다음이 표시됩니다.

  • 라인이 이동될 때마다 알림(새 가격으로).
  • 회선 이동 과 경고 사이에 지연이 없습니다.
  • 다른 것이 움직일 때 경고하지 않습니다.
  • 라인이 실제로 이동하는 동안에는 경고가 표시되지 않습니다.

#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);
  }
사유: