Checking time in Strategy Tester

 

Hi,

I'm using the following code as a time filter. It works well in my EA but not in the Strategy Tester. I know this has been covered elsewhere in the forum but I'm still at a loss. Any assistance would be appreciated. Thx Neil

//+------------------------------------------------------------------+
//
// tradeTime2.
//
// Trade Time Filter @http://kolier.li
// @see http://kolier.li/example/script-function-trade-time-filter
//+------------------------------------------------------------------+
bool tradeTime2()
  {
   if(Trade2TimeFilter) 
     {
      datetime time_now,time_begin,time_end,time_end_today;

      time_now=TimeCurrent(); MarketInfo(
      time_begin=StrToTime(Trade2Begin);
      if(!EndInTomorrow2)
        {
         time_end=StrToTime(Trade2End);
        }

      else if(EndInTomorrow2)
        {
         time_end=StrToTime(Trade2End)+86400;
         time_end_today=StrToTime(Trade2End);
        }

      if(!EndInTomorrow2 && (time_now<time_begin || time_now>time_end))
        {
         return(false);
        }

      else if(EndInTomorrow2 && time_now>time_end_today && time_now<time_begin)
        {
         return(false);
        }
     }

   return(true);
  }
//+------------------------------------------------------------------+
 
snafu4:

Hi,


I'm using the following code as a time filter. It works well in my EA but not in the Strategy Tester. I know this has been covered elsewhere in the forum but I'm still at a loss. Any assistance would be appreciated. Thx Neil


<CODE REMOVED>

Please read some other posts before posting . . .

Please edit your post or have your thread removed . . . please use the SRC button to post code: How to use the SRC button.

 
snafu4:

Hi,


I'm using the following code as a time filter. It works well in my EA but not in the Strategy Tester. I know this has been covered elsewhere in the forum but I'm still at a loss. Any assistance would be appreciated. Thx Neil


Your posted code is incomplete . . .

time_now = TimeCurrent(); MarketInfo(

. . . do you think MarketInfo() will work in the Strategy Tester ?

 
RaptorUK:

Your posted code is incomplete . . .

. . . do you think MarketInfo() will work in the Strategy Tester ?

Sorry for the confusion in my post. I did use the SRC button on the first 2 posts and not everything I typed in was included so I stopped using it - I'm trying it again now. MarketInfo() [included accidentally] was removed from the post [using SRC] but I obviously did something wrong.

I did look at other posts such as forum.mql4.com/43342, altered my code and it is still not working which is why I'm asking for help. Here is the code ... it works in my EA running outside of the Strategy Tester but not in the ST. As before, any assistance/suggestions are appreciated.
// Trade Time 2 Filter

extern bool        Trade2TimeFilter     = false;         // Whether to use trade time filter
extern string      Trade2Begin          = "13:00";       // Don't trade before this time - GMT
extern string      Trade2End            = "16:00";       // Don't trade after this time - GMT
extern bool        EndInTomorrow2       = false;         // Whether TradeEnd is the next day, like you want to trade the period: 18:00~06:00, the 06:00 is the next am


//+------------------------------------------------------------------+
//
//       tradeTime2.
//
// Trade Time Filter @http://kolier.li                              
//   @see http://kolier.li/example/script-function-trade-time-filter
//+------------------------------------------------------------------+
bool tradeTime2()
{
   if(Trade2TimeFilter) {
      datetime time_now, time_begin, time_end, time_end_today;
      time_now = TimeCurrent();
      time_begin = StrToTime(Trade2Begin);
      if(!EndInTomorrow2)
      {
         time_end = StrToTime(Trade2End);
      }
      else if(EndInTomorrow2)
      {
         time_end = StrToTime(Trade2End) + 86400;
         time_end_today = StrToTime(Trade2End);
      }
      if ( !EndInTomorrow2 && (time_now<time_begin || time_now>time_end) )
      {
         return(false);
      }
      else if(EndInTomorrow2 && time_now>time_end_today && time_now<time_begin)
            {
               return(false);
            }
   }
   return(true);  
}
 
snafu4:
Sorry for the confusion in my post. I did use the SRC button on the first 2 posts and not everything I typed in was included so I stopped using it - I'm trying it again now. MarketInfo() [included accidentally] was removed from the post [using SRC] but I obviously did something wrong.

I did look at other posts such as forum.mql4.com/43342, altered my code and it is still not working which is why I'm asking for help. Here is the code ... it works in my EA running outside of the Strategy Tester but not in the ST. As before, any assistance/suggestions are appreciated.

RaptorUK:

Please edit your post or have your thread removed . . . please use the SRC button to post code: How to use the SRC button.

I'll ask you once more to edit your post . . . is it too much to ask ?
 

RaptorUK - you have been very helpful to me and others on this forum. The comment below is not meant to be rude/disrespectful but I don't understand what you are asking for ...

I have edited my post multiple times trying to be more clear. I obviously do not understand what you are asking for so threatening to remove my post [I'll ask you once more to edit your post . . . is it too much to ask ?] will not help me understand exactly what it is that you are looking nor what it is that I have done wrong.

 

Play video
Please edit your post.
For large amounts of code, attach it.

If you can't be bothered to answer our questions and edit your posts as requested, I can't be bothered to look at your code and try to help you.

If you can't be bothered to click on the links that show you exactly how, then I assume asking you for any additional information and/or testing will also be useless, thus there is no way to help you.

If you can't be bothered to learn since 2009 how this forum works, I'm certainly not going to waste my time with your posts.

 
snafu4:

RaptorUK - you have been very helpful to me and others on this forum. The comment below is not meant to be rude/disrespectful but I don't understand what you are asking for ...

I have edited my post multiple times trying to be more clear. I obviously do not understand what you are asking for so threatening to remove my post [I'll ask you once more to edit your post . . . is it too much to ask ?] will not help me understand exactly what it is that you are looking nor what it is that I have done wrong.

Click this ------> How to use the SRC button. then edit your post so that your code is posted using the SRC button.
 

snafu4,

I think that they are referring to your first post.

 
Thanks GumRai. It would appear. I've given up.
 
snafu4:
Thanks GumRai. It would appear. I've given up.
I edit your post for you . . . . why is it so hard to do ?
Reason: