// I say Once ' Do not turn... ' for ' if ' operator - this is good. if ( Morning || Midnight ) { // Do not turn on light just for today... }
// I say Twice ' Do not turn... ' for ' switch ' operator - Q: Can I say ' Once '? switch ( Today ) { case Morning : // Do not turn on light just for today... break; case Midnight : // Do not turn on light just for today... break; } //---switch Close
// I say Once ' Do not turn... ' for ' if ' operator - this is good. if ( Morning || Midnight ) { // Do not turn on light just for today... }
这将是真正的早晨或午夜
// I say Twice ' Do not turn... ' for ' switch ' operator - Q: Can I say ' Once '? switch ( Today ) { case Morning : // Do not turn on light just for today... break; case Midnight : // Do not turn on light just for today... break; } //---switch Close
是的,OnChartEvent()对两种语言都是一样的。
非常感谢。
我还发现,许多为MT5编写的代码现在也可以在MT4上使用。
我知道,因为我在过去试过很多东西,一年前不能用的东西,现在可以用了,所以这说明他们仍然在积极开发这两种语言。
我还发现,许多为MT5编写的代码现在也可以在MT4上使用。
我知道,因为我在过去试过很多东西,一年前不能用的东西,现在可以用了,所以这说明他们仍然在积极开发这两种语言。
if ( Morning || Midnight )
{
// Do not turn on light just for today...
}
// I say Twice ' Do not turn... ' for ' switch ' operator - Q: Can I say ' Once '?
switch ( Today )
{
case Morning : // Do not turn on light just for today...
break;
case Midnight : // Do not turn on light just for today...
break;
} //---switch Close
我已经读过文章并查看了其他一些人的代码,了解如何使用 "CHARTEVENT_OBJECT_DRAG"。
我的目的是,当我拖动对象 "止损、止盈、挂单 "时,该对象可以移动。(当然,所有这些都可以单独进行)但不幸的是,这对我来说是没有意义的。现在我觉得我是在浪费我的时间做无用功。因为他们的代码风格真的和我的不一样。
(我的代码风格只是简单的--就像mql4文档的代码风格--这是我理解的多一点。)
我还看到一个修改订单的EA脚本(sl, tp等) - 它在没有 "CHARTEVENT_OBJECT_DRAG "的情况下工作...我希望你明白我的意思。
现在,我真的需要帮助,只是用简单的例子来说明'CHARTEVENT_OBJECT_DRAG'与HLine或Trendline对象。或者明确的解释,或者只是一些好的(/更明确的)评论。
我已经花了很多时间,而且我还在研究这个问题。我希望我将很快得到答案。
祝你一切顺利。
谢谢。
if ( Morning || Midnight )
{
// Do not turn on light just for today...
}
这将是真正的早晨或午夜
switch ( Today )
{
case Morning : // Do not turn on light just for today...
break;
case Midnight : // Do not turn on light just for today...
break;
} //---switch Close
这有一个单独的 "早晨 "案例和一个单独的 "午夜 "案例。
所以这是两件不同的事情。
我已经读过文章并查看了其他一些人关于'CHARTEVENT_OBJECT_DRAG'的代码,知道如何使用它。
我的目的是,当我拖动对象 "止损、止盈、挂单 "时,该对象可以移动。(当然,所有这些都可以单独进行)但不幸的是,这对我来说是没有意义的。现在我觉得我是在浪费我的时间做无用功。因为他们的代码风格真的和我的不一样。
(我的代码风格只是简单的--就像mql4文档的代码风格--这是我理解的多一点。)
我还看到一个修改订单的EA脚本(sl、tp等)--它在没有 "CHARTEVENT_OBJECT_DRAG "的情况下工作。我希望你明白我的意思。
现在,我真的需要帮助,只是用简单的例子来说明'CHARTEVENT_OBJECT_DRAG'与HLine或Trendline对象。或者明确的解释,或者只是一些好的(/更明确的)评论。
我已经花了很多时间,而且我还在研究这个问题。我希望我将很快得到答案。
祝你一切顺利。
谢谢。
你可以拖动一条线,当
OBJPROP_SELECTED ==1
两者都是真实的,你可以通过使用 \来简单地读取数值。
以代替
当我开始做的时候,我几乎不知道如何为止损 和止盈 拖动写代码,非常感谢你。
现在我觉得我可以做我想做的事了,在你的伟大评论之后。
市场关闭
所以,我已经试过了,现在我可以得到我想要的'OBJPROP_PRICE'。
当我拖动'HLine'对象,然后Print()在一秒钟内更新一次。因为我使用了EventSetTimer( 1 )。
但我需要Print()不在一秒钟内更新一次。我想让Print()在我停止拖动后更新。
如果你理解我,请帮助我或给我建议。
祝你一切顺利。
所以你可以将OBJPROP_PRICE的值存储在一个双数中,然后对它们进行比较。
如果它们不同,你就知道拖动已经开始了,然后如果它们又相等,你就知道拖动已经停止了。
//| Drag Hline.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
double price; // price variable;
bool drag; // drag flag
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);
//--- create Hline
ObjectCreate(0,"line",OBJ_HLINE,0,0,Ask);
//--- store value
price=ObjectGetDouble(0,"line",OBJPROP_PRICE,0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//--- compare values
if(price!=ObjectGetDouble(0,"line",OBJPROP_PRICE,0))
{
drag=1; // set drag flag
price=ObjectGetDouble(0,"line",OBJPROP_PRICE,0); //store new value
}
if(drag==1)
{
if(price==ObjectGetDouble(0,"line",OBJPROP_PRICE,0))
{
drag=0; //reset drag flag
Alert(" New value set: ", DoubleToString(price));
}
}
}
//+------------------------------------------------------------------+
或者你可以在检测到拖动后启动一个计数器,有很多方法可以做到这一点。