externint iOpenHour = 6;
int start()
{
int b, scannedhour;
datetime bartime;
double dibsclose, dibsopen, prevdayrange[4]; // prevdayrange Array Categorys ( 1 EURUSD, 2 GBPUSD, 3 USDCHF, 4 USDJPY )//----------------------------------------------------------------------------------------------// EURUSD PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("EURUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("EURUSD", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("EURUSD", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[1] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// GBPUSD PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("GBPUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("GBPUSD", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("GBPUSD", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[2] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// USDCHF PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("EURUSD", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("USDCHF", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("USDCHF", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[3] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------// USDJPY PREV DAY RANGE CALCfor(b=0; b<=24; b++) // scans the last 24 bars on eurusd
{
bartime = iTime("USDJPY", 60, b); // checks the open time of each bar
scannedhour = TimeHour(bartime); // extracts the hour of that barif ( scannedhour == iOpenHour ) // Check to see if scanned hour = Dibs hour
{
dibsclose = iOpen("USDJPY", 60, b); // Get the open value of that bar (Close of 6gmt day)
dibsopen = iOpen("USDJPY", 60, b+24); // Get the value of the bar 24 bars before the Dibs bar (Open of 6gmt day)
prevdayrange[4] = (dibsclose-dibsopen); // Calculate the range of the Dibs day
} // End of if statement
} // End of for statement//----------------------------------------------------------------------------------------------Comment("EURUSD RANGE=", prevdayrange[1], //Display Ranges of each pair"GBPUSD RANGE=", prevdayrange[2],
"USDCHF RANGE=", prevdayrange[3],
"USDJPY RANGE=", prevdayrange[4]);
return(0);
}
好吧,我把它修好了,所以prevdayrange是唯一的数组。现在由于某些原因,代码中的USDJPY部分不工作了。它与其他4个语句一样,在iopen's中改变了货币对,并且有正确的数组值......
下面是它的作用--->http://clip2net.com/s/13WDY
你是如何在注释函数 中加入空格的,你能让它打印到下一行吗?
好吧,我把它修好了,所以prevdayrange是唯一的数组。现在由于某些原因,代码中的USDJPY部分不工作了。它与其他4个语句一样,在iopen's中改变了货币对,并使用了正确的数组值......
下面是它的作用--->http://clip2net.com/s/13WDY
如何在注释函数中加入空格,能否让它打印到下一行?
数组中的第一个元素是0,如果一个数组有4个元素,最后一个将是3而不是4;-)https://docs.mql4.com/basis/variables
评论()
好吧,这段代码几乎是在做它应该做的事情,除了当一个新的6:00蜡烛打开时,它没有更新信息。如果当前的蜡烛是6:00的蜡烛,我希望它能扫描该条的开盘,然后回到24条,扫描该条的开盘,并进行所有的计算,如果当前的条不是6:00的条,那么继续往后退一个条,直到它找到最后的6:00的蜡烛。它似乎在往回走,但似乎不喜欢当前的蜡烛是6:00的。无法解决这个问题。各位传奇人物能发现这个问题吗?
这段代码太长了,无法在这里发布,所以我不得不上传源代码。
它似乎在往回走,但似乎不喜欢当前的蜡烛是6点的。无法解决这个问题。各位传奇人物能发现这个问题吗?
这是使用策略测试器吗? 如果是的话 ......
不,Raptor,这是在一个实时图表上,我是否应该改变
只是大声想一下,不知道这是否能解决任何问题。不,Raptor,这是在一个实时图表上,我是否应该改变
只是大声想一下,不知道这是否能解决任何问题。一切似乎都很正常,但它不会接收6点的酒吧,除非它在当前的酒吧后面,如果这有意义的话。
谢谢你的时间,Raptor
一切似乎都很正常,但它不会接收6点的酒吧,除非它在当前的酒吧后面,如果这有意义的话。
谢谢你的时间,Raptor
是的,我想我明白你的意思,当时间从05:59变为06:00时,它不会更新 . . .
我正在使用MBT进行测试,它的服务器时间 为当前H1条的04:00,所以我已经将iOpenHour设置为5,让我们看看20分钟后会发生什么。
好吧,我也有同样的问题,当当前的蜡烛在05:00打开时没有更新......有趣。