Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
Eu tento depois de arrastarOBJPROP_SELECTED terminado pode ser "falso" com código abaixo, sem efeitos.
Como posso resolver isso, por favor?
{
SL_TPdrags();
Sleep(1000);
drag_onoff=false; // OBJPROP_SELECTED
}
Obrigado de antemão.
Lamento nunca usar CHARTEVENT_OBJECT_DRAG.
No final do dia, fui encontrado "OBJ_RECTANGLE e OBJ_TEXT", que penso que posso usar ambos em vez de "OBJ_LABEL e OBJ_RECTANGLE_LABEL", que ambos se movem juntos Linha de licitação.
P: Então, quais objetos são muito úteis para movimentos em conjunto Linhas de licitação, por favor?
Eu realmente preciso de um comentário informativo.
Tenha um bom fim de semana.
ID
Descrição
OBJ_VLINE
Linha Vertical
OBJ_HLINE
Linha Horizontal
OBJ_TREND
Linha de tendência
OBJ_TRENDBYANGLE
Linha de tendência por ângulo
OBJ_CYCLES
Linhas de Ciclo
OBJ_ARROWED_LINE
Linha com flechas
OBJ_CHANNEL
Canal equidistante
OBJ_STDDEVCHANNEL
Canal de Desvio Padrão
OBJ_REGRESSION
Canal de Regressão Linear
OBJ_PITCHFORK
Andrews Pitchfork
OBJ_GANNLINE
Linha Gann
OBJ_GANNFAN
Gann Fan
OBJ_GANNGRID
Rede de Gann
OBJ_FIBO
Fibonacci Retracement
OBJ_FIBOTIMES
Fusos Horários Fibonacci
OBJ_FIBOFAN
Ventilador Fibonacci
OBJ_FIBOARC
Arcos de Fibonacci
OBJ_FIBOCHANNEL
Canal Fibonacci
OBJ_EXPANSION
Expansão de Fibonacci
OBJ_ELLIOTWAVE5
Onda Motiva Elliott
OBJ_ELLIOTWAVE3
Onda de Correção Elliott
OBJ_RECTÂNGULO
Rectângulo
OBJ_TRIÂNGULO
Triângulo
OBJ_ELLIPSE
Ellipse
OBJ_ARROW_THUMB_UP
Polegares para cima
OBJ_ARROW_THUMB_DOWN
Polegares para baixo
OBJ_ARROW_UP
Flecha para cima
OBJ_ARROW_DOWN
Flecha para baixo
OBJ_ARROW_STOP
Sinal de parada
OBJ_ARROW_CHECK
Sinal de verificação
OBJ_ARROW_LEFT_PRICE
Etiqueta de preço à esquerda
OBJ_ARROW_RIGHT_PRICE
Etiqueta de Preço Direito
OBJ_ARROW_BUY
Sinal de compra
OBJ_ARROW_SELL
Sinal de venda
OBJ_ARROW
Flecha
OBJ_TEXT
Texto
OBJ_LABEL
Etiqueta
OBJ_BUTTON
Botão
OBJ_CHART
Quadro
OBJ_BITMAP
Bitmap
OBJ_BITMAP_LABEL
Rótulo Bitmap
OBJ_EDIT
Editar
OBJ_EVENT
O objeto "Evento" correspondente a um evento no calendário econômico
OBJ_RECTANGLE_LABEL
O objeto "Rectangle label" para criar e projetar a interface gráfica personalizada.
O que você quis dizer com "mover juntos"?
Eu tento depois de arrastarOBJPROP_SELECTED terminado pode ser "falso" com código abaixo, sem efeitos.
Como posso resolver isso, por favor?
{
SL_TPdrags();
Sleep(1000);
drag_onoff=false; // OBJPROP_SELECTED
}
Obrigado de antemão.
A menos que você esteja testando a sparam mais acima, esse código aciona quando qualquer objeto é arrastado.
Meu código original:
{
if(id==CHARTEVENT_OBJECT_DRAG && sparam=="line") // the chart event of dragging the line
Eu já sei / leia seu um dos grandes exemplos CrossHair.mq4.
Mas eu estou lutando para dar preço de licitação para a Label, RectLabel Objects. O que eu estou tentando rotular, RectLabel Objects move-se com a Bid Line juntos.
Eu só preciso como imagem, por favor, encontre o arquivo anexo.
Tudo de bom.
Para os objetos de tamanho fixo: OBJ_BUTTON, OBJ_RECTANGLE_LABEL e OBJ_EDIT, as propriedades OBJPROP_XDISTANCE e OBJPROP_YDISTANCE definem a posição do ponto superior esquerdo do objeto em relação ao canto do gráfico (OBJPROP_CORNER), a partir do qual as coordenadas X e Y serão contadas em pixels.
//| 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);
}
//+------------------------------------------------------------------+
A menos que você esteja testando a sparam mais acima, esse código aciona quando qualquer objeto é arrastado.
Meu código original:
{
if(id==CHARTEVENT_OBJECT_DRAG && sparam=="line") // the chart event of dragging the line
{
// here was my functions
}
Isso não foi uma resposta para mim.
---
Mas eu uso como o código abaixo, que é o que eu pouco mudo seu código para mim - e ele funciona perfeitamente para mim qual eu quero. Até agora eu não tive nenhum problema.
Estou fazendo mal, por favor?
Tudo de bom.
Talvez isto ajude.
Adicione isto a um gráfico e você verá:
#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);
}