如何编码? - 页 67 1...606162636465666768697071727374...347 新评论 nittany1 2008.02.02 15:14 #661 计数器? 我做了这么多月的指标编程,在专家方面有点欠缺,但我打算解决这个问题。在这一过程中,我需要一点帮助。在我的专家中,我让它在收盘时检查是否有一个条件需要关闭交易。 我从一个全局变量开始。 //--- Global variable datetime PreviousBar; // record candle/bar time[/CODE] and set one bool in init() int init() { do_this = true; } [/CODE] blah blah boring stuff.... etc, etc then in the main loop I have: [CODE] if(do_this == true) { PreviousBar = Time[0]; do_this= false; // so it does this only once only } if(NewBar() == true) { if(TotalOpenOrders() == blah blah close my order you crazy monkey) } and outside the main loop I have: [CODE]//--- returns true if current bar just formed bool NewBar() { if(PreviousBar<Time[0]) { PreviousBar = Time[0]; return(true); } else { return(false); } return(false); } 好吧,它被设置为每个条形图做一次。我想做的是有一个函数,将90秒或60秒或其他的时间递增,然后在递增后将一个bool设置为true。基本上我想每隔60秒、90秒、120秒或其他时间检查指标,而不是在收盘时检查。我如何做到这一点? 谢谢你的帮助。 - nittany1 How to code? 'Close all'/'Open' tools Need help creating a omelette 2008.02.02 16:41 #662 nittany1: 我做了这么多月的指标编程,对专家有点欠缺,但我打算解决这个问题。在这一过程中,我需要一点帮助。在我编写的专家程序中,我让它在收盘时检查是否有需要关闭交易的情况。 我从一个全局变量开始。 //--- Global variable datetime PreviousBar; // record candle/bar time[/CODE] and set one bool in init() int init() { do_this = true; } [/CODE] blah blah boring stuff.... etc, etc then in the main loop I have: [CODE] if(do_this == true) { PreviousBar = Time[0]; do_this= false; // so it does this only once only } if(NewBar() == true) { if(TotalOpenOrders() == blah blah close my order you crazy monkey) } and outside the main loop I have: [CODE]//--- returns true if current bar just formed bool NewBar() { if(PreviousBar<Time[0]) { PreviousBar = Time[0]; return(true); } else { return(false); } return(false); } 好的,所以它被设置为每条街做一次。我想做的是有一个函数,将90秒或60秒或其他的时间递增,然后在递增后将一个bool设置为true。基本上我想每隔60秒、90秒、120秒或其他时间检查指标,而不是在收盘时检查。我如何做到这一点? 谢谢你的帮助。 - 尼特尼1 这应该可以做到。请记住,MT使用基于tick的执行方式,所以不可能做到每秒钟的精确性(除非你在Init()子程序中循环所有的东西)。 如果(CallIndicatorsCheck()) { // 你的代码在这里 } bool CallIndicatorsCheck() { static datetime Oldtime; int Secs = 90; bool Flag。 如果(CurrTime() >= Oldtime) { Oldtime = CurrTime() + Secs; Flag = true; } return(Flag); } wolfe 2008.02.04 01:03 #663 评论的位置 谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码? 谢谢! Linuxser 2008.02.04 01:27 #664 wolfe: 谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码? 谢谢! 你不能这样做。来自MQL4手册。 void Comment(...)该函数在图表的左上角输出用户定义的评论。 如果你需要死亡,你可以创建对象。 mog 2008.02.04 02:24 #665 wolfe: 谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码? 谢谢! LinusGuy是对的;没有直接的方法。 简单的解决方法是在你的注释中加入空格 -- Comment(" hello world!")。 将会使文本向右偏移。 你也可以加入换行符,使页面下拉。 Comment("\n\n\n\nyour text")。 或者结合换行和空格来打印在屏幕的右下角。 mog wolfe 2008.02.04 05:33 #666 mog: LinusGuy是对的;没有直接的方法。 简单的解决方法是用空格填充你的Comment --Comment(" hello world!")。 将使文本向右偏移。 你也可以加入换行,使页面下拉。 Comment("\n\n\n\nyour text")。 或者结合换行和空格,在屏幕的右下角打印。 mog 谢谢你的帮助。 我会试试的! mikerawson 2008.02.04 07:30 #667 亏损的交易后,在X条内没有新的交易 嗨,团队 - 希望有人能帮忙。 如果最后一笔交易是亏损的,我如何阻止新的交易在10个柱子内开始? 欢呼声 ralphronnquist 2008.02.04 07:59 #668 当账户历史上有一笔亏损交易在过去的第10个柱子(当前柱子为0)开盘时或之后关闭,下面的函数 将返回true。 否则返回false。 bool postMortem() { datetime since = Time[ bar+10 ]; for ( int i = OrdersHistoryTotal() - 1; i >= 0; i-- ) { if ( ! OrderSelect( i, SELECT_BY_POS, MODE_HISTORY ) continue; if ( OrderProfit() = since ) return( true ); } return( false ); } [/PHP] If you add that function to your EA, then include a statement like the following in the start() function, then Bob's your uncle. [PHP]if ( postMortem() ) return( 0 ); How to code? 问吧! [WARNING CLOSED!] Any newbie mikerawson 2008.02.04 18:10 #669 非常感谢 - 我会尝试的。 问候 latotona 2008.02.06 19:29 #670 各位,你们有同样的问题吗? 我编了一个专家程序。我想在价格与一个指标相同时开仓。要做到这一点,我使用以下句子。 //要买入 double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); 如果(close[1]indicatornow)OpenBUY()。 如果(close[1]>indicatorpast && close[0]<indicatornow)OpenSELL()。 但在这种情况下,专家不仅在价格越过指标时开仓,而且还在指标之上开仓。我希望专家只在价格越过指标时开仓,所以我试着这样做。 //买入 double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); 如果(close[1]<indicatorpast && close[0]== indicatornow)OpenBUY()。 如果(close[1]>indicatorpast && close[0]== indicatornow)OpenSELL()。 但是这个语句没有执行。 你知道发生了什么吗?因为我认为该语句中没有错误。 请注意。 1...606162636465666768697071727374...347 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
计数器?
我做了这么多月的指标编程,在专家方面有点欠缺,但我打算解决这个问题。在这一过程中,我需要一点帮助。在我的专家中,我让它在收盘时检查是否有一个条件需要关闭交易。
我从一个全局变量开始。
datetime PreviousBar; // record candle/bar time[/CODE]
and set one bool in init()
{
do_this = true;
}
[/CODE]
blah blah boring stuff.... etc, etc
then in the main loop I have:
[CODE]
if(do_this == true)
{
PreviousBar = Time[0];
do_this= false; // so it does this only once only
}
if(NewBar() == true)
{
if(TotalOpenOrders() == blah blah close my order you crazy monkey)
}
and outside the main loop I have:
[CODE]//--- returns true if current bar just formed
bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar = Time[0];
return(true);
}
else
{
return(false);
}
return(false);
}好吧,它被设置为每个条形图做一次。我想做的是有一个函数,将90秒或60秒或其他的时间递增,然后在递增后将一个bool设置为true。基本上我想每隔60秒、90秒、120秒或其他时间检查指标,而不是在收盘时检查。我如何做到这一点?
谢谢你的帮助。
- nittany1
我做了这么多月的指标编程,对专家有点欠缺,但我打算解决这个问题。在这一过程中,我需要一点帮助。在我编写的专家程序中,我让它在收盘时检查是否有需要关闭交易的情况。
我从一个全局变量开始。
datetime PreviousBar; // record candle/bar time[/CODE]
and set one bool in init()
{
do_this = true;
}
[/CODE]
blah blah boring stuff.... etc, etc
then in the main loop I have:
[CODE]
if(do_this == true)
{
PreviousBar = Time[0];
do_this= false; // so it does this only once only
}
if(NewBar() == true)
{
if(TotalOpenOrders() == blah blah close my order you crazy monkey)
}
and outside the main loop I have:
[CODE]//--- returns true if current bar just formed
bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar = Time[0];
return(true);
}
else
{
return(false);
}
return(false);
}好的,所以它被设置为每条街做一次。我想做的是有一个函数,将90秒或60秒或其他的时间递增,然后在递增后将一个bool设置为true。基本上我想每隔60秒、90秒、120秒或其他时间检查指标,而不是在收盘时检查。我如何做到这一点?
谢谢你的帮助。
- 尼特尼1这应该可以做到。请记住,MT使用基于tick的执行方式,所以不可能做到每秒钟的精确性(除非你在Init()子程序中循环所有的东西)。
如果(CallIndicatorsCheck())
{
// 你的代码在这里
}
bool CallIndicatorsCheck()
{
static datetime Oldtime;
int Secs = 90;
bool Flag。
如果(CurrTime() >= Oldtime) {
Oldtime = CurrTime() + Secs;
Flag = true; }
return(Flag);
}
评论的位置
谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码?
谢谢!
谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码? 谢谢!
你不能这样做。来自MQL4手册。
如果你需要死亡,你可以创建对象。
谁能告诉我把评论放在屏幕的右上角,而不是默认的左上角的代码? 谢谢!
LinusGuy是对的;没有直接的方法。 简单的解决方法是在你的注释中加入空格 --
Comment(" hello world!")。
将会使文本向右偏移。
你也可以加入换行符,使页面下拉。
Comment("\n\n\n\nyour text")。
或者结合换行和空格来打印在屏幕的右下角。
mog
LinusGuy是对的;没有直接的方法。 简单的解决方法是用空格填充你的Comment --
Comment(" hello world!")。
将使文本向右偏移。
你也可以加入换行,使页面下拉。
Comment("\n\n\n\nyour text")。
或者结合换行和空格,在屏幕的右下角打印。
mog谢谢你的帮助。 我会试试的!
亏损的交易后,在X条内没有新的交易
嗨,团队 - 希望有人能帮忙。
如果最后一笔交易是亏损的,我如何阻止新的交易在10个柱子内开始?
欢呼声
当账户历史上有一笔亏损交易在过去的第10个柱子(当前柱子为0)开盘时或之后关闭,下面的函数 将返回true。
否则返回false。
{
datetime since = Time[ bar+10 ];
for ( int i = OrdersHistoryTotal() - 1; i >= 0; i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS, MODE_HISTORY )
continue;
if ( OrderProfit() = since )
return( true );
}
return( false );
}
[/PHP]
If you add that function to your EA, then include a statement like the following in the start() function, then Bob's your uncle.
[PHP]if ( postMortem() ) return( 0 );非常感谢 - 我会尝试的。
问候
各位,你们有同样的问题吗?
我编了一个专家程序。我想在价格与一个指标相同时开仓。要做到这一点,我使用以下句子。
//要买入
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
如果(close[1]indicatornow)OpenBUY()。
如果(close[1]>indicatorpast && close[0]<indicatornow)OpenSELL()。
但在这种情况下,专家不仅在价格越过指标时开仓,而且还在指标之上开仓。我希望专家只在价格越过指标时开仓,所以我试着这样做。
//买入
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
如果(close[1]<indicatorpast && close[0]== indicatornow)OpenBUY()。
如果(close[1]>indicatorpast && close[0]== indicatornow)OpenSELL()。
但是这个语句没有执行。
你知道发生了什么吗?因为我认为该语句中没有错误。
请注意。