检查开放交易的问题 - 页 3

 
extern int     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 CALC

for(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 bar
    
      if ( 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 CALC

for(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 bar
    
      if ( 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 CALC

for(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 bar
    
      if ( 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 CALC

for(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 bar
    
      if ( 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

你是如何在注释函数 中加入空格的,你能让它打印到下一行吗?

 
dazamate:

好吧,我把它修好了,所以prevdayrange是唯一的数组。现在由于某些原因,代码中的USDJPY部分不工作了。它与其他4个语句一样,在iopen's中改变了货币对,并使用了正确的数组值......

下面是它的作用--->http://clip2net.com/s/13WDY

如何在注释函数中加入空格,能否让它打印到下一行?


数组中的第一个元素是0,如果一个数组有4个元素,最后一个将是3而不是4;-)https://docs.mql4.com/basis/variables

评论()

Comment("This adds some spaces ", "   ", "this adds a carriage return", "\n");
 

好吧,这段代码几乎是在做它应该做的事情,除了当一个新的6:00蜡烛打开时,它没有更新信息。如果当前的蜡烛是6:00的蜡烛,我希望它能扫描该条的开盘,然后回到24条,扫描该条的开盘,并进行所有的计算,如果当前的条不是6:00的条,那么继续往后退一个条,直到它找到最后的6:00的蜡烛。它似乎在往回走,但似乎不喜欢当前的蜡烛是6:00的。无法解决这个问题。各位传奇人物能发现这个问题吗?


这段代码太长了,无法在这里发布,所以我不得不上传源代码。

附加的文件:
hothand.mq4  11 kb
 
dazamate:

它似乎在往回走,但似乎不喜欢当前的蜡烛是6点的。无法解决这个问题。各位传奇人物能发现这个问题吗?


这是使用策略测试器吗? 如果是的话 ......

WHRoeder 2011.07.18 18:30

测试器的局限性。你不能在测试器中获得其他时间段或货币对的零条数据。试试吧。

 

不,Raptor,这是在一个实时图表上,我是否应该改变


for(b=0; b<=24; b++) to for(b=-1; b<=24; b++)
只是大声想一下,不知道这是否能解决任何问题。
 
dazamate:

不,Raptor,这是在一个实时图表上,我是否应该改变


只是大声想一下,不知道这是否能解决任何问题。
啊,好吧,我再看看你的代码 . . .
 
我将在下一个小时的变化中测试你的代码,因为我看不到任何明显的东西......你确定你是在服务器时间早上6点检查的 吗? 本地PC时间不一定与服务器时间相同,服务器时间是在你的代码和图表中使用的。
 

一切似乎都很正常,但它不会接收6点的酒吧,除非它在当前的酒吧后面,如果这有意义的话。


谢谢你的时间,Raptor

 
dazamate:

一切似乎都很正常,但它不会接收6点的酒吧,除非它在当前的酒吧后面,如果这有意义的话。


谢谢你的时间,Raptor

是的,我想我明白你的意思,当时间从05:59变为06:00时,它不会更新 . . .

我正在使用MBT进行测试,它的服务器时间 为当前H1条的04:00,所以我已经将iOpenHour设置为5,让我们看看20分钟后会发生什么。

 

好吧,我也有同样的问题,当当前的蜡烛在05:00打开时没有更新......有趣。