asesor experto - preguntas varias - página 25

 

Intento que después de los arrastres terminadosOBJPROP_SELECTED pueda ser " false " con el código de abajo, sin efectos.

¿Cómo puedo solucionarlo, por favor?

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

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

Gracias de antemano.

 
Siento no haber utilizado nunca CHARTEVENT_OBJECT_DRAG.
 
Marco vd Heijden:
Siento no haber usado nunca CHARTEVENT_OBJECT_DRAG.
¡OK! ¡Gracias de todos modos!
 

Al final, he encontrado "OBJ_RECTANGLE y OBJ_TEXT ", que estoy pensando que puedo utilizar ambos en lugar de " OBJ_LABEL y OBJ_RECTANGLE_LABEL " que ambos se mueven juntos línea de la oferta.

P:¿Cuáles son los objetos más útiles para mover juntos las líneas de oferta, por favor?

Realmente necesito comentarios informativos.
Que tengan un buen fin de semana.

 

ID

Descripción

OBJ_VLINE

Línea vertical

OBJ_HLINE

Línea horizontal

OBJ_TREND

Línea de tendencia

OBJ_TRENDBYANGLE

Línea de tendencia por ángulo

OBJ_CICLOS

Líneas de ciclo

OBJ_ARROWED_LINE

Línea flechada

OBJ_CHANNEL

Canal equidistante

OBJ_STDDEVCHANNEL

Canal de desviación estándar

OBJ_REGRESSION

Canal de regresión lineal

OBJ_PITCHFORK

Horquilla de Andrews

OBJ_GANNLINE

Línea de Gann

OBJ_GANNFAN

Abanico de Gann

OBJ_GANNGRID

Rejilla de Gann

OBJ_FIBO

Retroceso de Fibonacci

OBJ_FIBOTIMES

Zonas de tiempo de Fibonacci

OBJ_FIBOFAN

Abanico de Fibonacci

OBJ_FIBOARC

Arcos de Fibonacci

OBJ_FIBOCHANNEL

Canal de Fibonacci

OBJ_EXPANSION

Expansión de Fibonacci

OBJ_ELLIOTWAVE5

Onda Motivacional de Elliott

OBJ_ELLIOTWAVE3

Onda de corrección de Elliott

OBJ_RECTANGLE

Rectángulo

OBJ_TRIANGLE

Triángulo

OBJ_ELLIPSE

Elipse

OBJ_ARROW_THUMB_UP

Pulgar hacia arriba

OBJ_ARROW_THUMB_DOWN

Pulgares hacia abajo

OBJ_ARROW_UP

Flecha hacia arriba

OBJ_ARROW_DOWN

Flecha hacia abajo

OBJ_ARROW_STOP

Señal de Stop

OBJ_ARROW_CHECK

Signo de verificación

OBJ_ARROW_LEFT_PRICE

Etiqueta de precio izquierda

OBJ_ARROW_RIGHT_PRICE

Etiqueta de precio derecha

OBJ_ARROW_BUY

Signo de compra

OBJ_ARROW_SELL

Signo de venta

OBJ_ARROW

Flecha

OBJ_TEXT

Texto

OBJ_LABEL

Etiqueta

OBJ_BUTTON

Botón

OBJ_CHART

Gráfico

OBJ_BITMAP

Mapa de bits

OBJ_BITMAP_LABEL

Etiqueta de mapa de bits

OBJ_EDIT

Editar

OBJ_EVENT

El objeto "Evento" correspondiente a un evento del calendario económico

OBJ_RECTANGLE_LABEL

El objeto "Etiqueta rectangular" para crear y diseñar la interfaz gráfica personalizada.


¿A qué se refiere con "mover juntos"?

 
Max Enrik:

Intento que después de los arrastres terminadosOBJPROP_SELECTED pueda ser " false " con el código de abajo, sin efectos.

¿Cómo puedo solucionarlo, por favor?

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

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

Gracias de antemano.

A no ser que estés probando sparam más arriba, ese código se dispara cuando cualquier el objeto es arrastrado.

Mi código original:

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

Ya sé / leer su uno de gran ejemplo CrossHair.mq4.
Pero estoy luchando para dar precio de oferta a Label, RectLabel objetos. Que es lo que estoy tratando de Etiqueta, RectLabel objetos se mueve con la línea de oferta juntos.

Sólo necesito como la imagen, por favor, encontrar el archivo adjunto.

Todo lo mejor.

Archivos adjuntos:
 

Para los objetos de tamaño fijo OBJ_BUTTON, OBJ_RECTANGLE_LABEL y OBJ_EDIT, las propiedades OBJPROP_XDISTANCE y OBJPROP_YDISTANCE establecen la posición del punto superior izquierdo del objeto respecto a la esquina del gráfico (OBJPROP_CORNER), a partir de la cual se contarán las coordenadas X e Y en píxeles.

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

A menos que estés probando sparam más arriba, ese código se dispara cuando cualquier el objeto es arrastrado.
Mi código original:

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
Ya he probado como el código de abajo.
if(id==CHARTEVENT_OBJECT_DRAG && sparam=="#"+IntegerToString(OrderTicket())+"-TP")
  {
// here was my functions
  }

Eso no fue respuesta a mí.

---

Pero yo uso como el código de abajo que es yo poco cambio de su código para mí - y funciona perfectamente para mí que quiero. Hasta ahora no he tenido ningún problema.
¿Estoy haciendo mal, por favor?

if(id==CHARTEVENT_OBJECT_DRAG){}

Todo lo mejor.

 

Tal vez esto ayude.

Añade esto a un gráfico y verás:

  • Una alerta cada vez que la línea se ha movido (con el nuevo precio).
  • No hay retraso entre el movimiento de la línea y la alerta.
  • Ninguna alerta cuando algo más se mueve.
  • Ninguna alerta mientras se mueve la línea.

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