check for TimeCurrent()

 

I have the following code for news trading

#include <Calc_Lot.mqh>
#include <Points.mqh>
#include <check for trading.mqh>

#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

//variables
double   Candle_Open;
double   Risk_Percent = 2;
datetime News_Time = D'2023.01.05 15:00:00';
int      News_Candle_Index;

//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   News_Candle_Index = iBarShift(Symbol(),Period(),News_Time,true);
   Candle_Open = iOpen(Symbol(),Period(),News_Candle_Index);

   if(OrdersTotal() == 0)
     {
      if(AccountFreeMargin()<(10*LotSize))//check for money ?
        {
         Print("We have no money. Free Margin = ",AccountFreeMargin());
         return;
        }
      // Buy order
      if(TimeCurrent() >= News_Time && (News_Candle_Index == 0 || News_Candle_Index == 1))
        {
         if(Ask - Candle_Open >= 20 * pip)
           {
            calc_lot_SL(Risk_Percent,15);// double calc_lot_SL(double Risk,double SL[in pips])
            Open_Orders(OP_BUY,LotSize,12345,Bid - (15 * pip),0); // int Open_Orders(int type,double lots,int Magic,double stop,double profit)
           }

         // Sell Order
         if(Candle_Open - Bid >= 20 * pip)
           {
            calc_lot_SL(Risk_Percent,15);
            Open_Orders(OP_SELL,LotSize,12345,Ask + (15 * pip),0);
           }
        }
     }
  }
//+------------------------------------------------------------------+

The code is running fine and passes the automatic validation on MQL5 market without this line:

if(TimeCurrent() >= News_Time && (News_Candle_Index == 0 || News_Candle_Index == 1))

when I add this condition, I got the following error on validation:


Is there any method to check TimeCurrent()? or am I doing something wrong?

 
Hany Mhmd Th Abrahym Aljml:I have the following code for news trading. The code is running fine and passes the automatic validation on MQL5 market without this line: when I add this condition, I got the following error on validation: Is there any method to check TimeCurrent()? or am I doing something wrong?

I will assume that one cannot back-test your EA, given that it is dependant on current news events.

If that is the case, then it will fail the verification, because it will not be able to generate any trading.

The verification process is after-all, equivalent to several back-tests run in the Strategy Tester.

 
Fernando Carreiro #:

I will assume that one cannot back-test your EA, given that it is dependant on current news events.

If that is the case, then it will fail the verification, because it will not be able to generate any trading.

The verification process is after-all, equivalent to several back-tests run in the Strategy Tester.

If you back test my EA, it will open only 1 trade on 05-01-2023 at 3:00 PM.
 
Hany Mhmd Th Abrahym Aljml #: If you back test my EA, it will open only 1 trade on 05-01-2023 at 3:00 PM.

On which symbol and under what conditions?

Also, such a restriction, would be in violation of the Market product rules, as your EA must be able to trade under multiple conditions and not be limited in any way.

You will have to modify your code, to be able to trade without the news filter by default. The user can then enable the news filter option for trading live.

Also, remember that potential customers will probably be downloading and testing the demo version first before purchasing the product.

If they are not able to test it first satisfactorily, they will most probably be less likely to purchase it.

 
Fernando Carreiro #:

On which symbol and under what conditions?

Also, such a restriction, would be in violation of the Market product rules, as your EA must be able to trade under multiple conditions and not be limited in any way.

You will have to modify your code, to be able to trade without the news filter by default. The user can then enable the news filter option for trading live.

Also, remember that potential customers will probably be downloading and testing the demo version first before purchasing the product.

If they are not able to test it first satisfactorily, they will most probably be less likely to purchase it.

Thank you for your help.
I will modify my code for sure.