Please help.....

 

Hi everyone,

 

I'm new here and I would appreciate if you could help me with these 3 questions:

1. I'm developing a trading strategy on FOREX markets which must close all open trades and cancel all existing orders at about 0:00. The easy way to do this is with "if" statement (if timeCurrent = 0:00:00 than....).

Now, I read that the "start()" method repeats every time there's a change in the market quote, that means every time there's a new tick. My question is: what if there's no new tick at 0:00:00? The "if" statement won't take place and the program won't send the cancellation orders? Does anyone have an idea to overcome this problem?

 

2. I want to test my strategy on a tick base historical data. To do this I need to run the strategy tester in an "every tick" model right? But I can't fully understand the "Period", meaning H1 or M1 or whatever... I know that H1 means 1 hour and M1 means 1 minute, but what difference does it make if I'm using "every tick" model?

 

3. I'm looking for historical data on forex currencies. I mean way back tick-based data, for up to 10 years back. My broker can't provide me that. Anyone knows where can I download\purchase it?

 

Thanks a lot! 

 
adibi83:

Hi everyone,

I'm new here and I would appreciate if you could help me with these 3 questions:

1. I'm developing a trading strategy on FOREX markets which must close all open trades and cancel all existing orders at about 0:00. The easy way to do this is with "if" statement (if timeCurrent = 0:00:00 than....).

Now, I read that the "start()" method repeats every time there's a change in the market quote, that means every time there's a new tick. My question is: what if there's no new tick at 0:00:00? The "if" statement won't take place and the program won't send the cancellation orders? Does anyone have an idea to overcome this problem?

2. I want to test my strategy on a tick base historical data. To do this I need to run the strategy tester in an "every tick" model right? But I can't fully understand the "Period", meaning H1 or M1 or whatever... I know that H1 means 1 hour and M1 means 1 minute, but what difference does it make if I'm using "every tick" model?

3. I'm looking for historical data on forex currencies. I mean way back tick-based data, for up to 10 years back. My broker can't provide me that. Anyone knows where can I download\purchase it?

1.  note the time time each tick occurs and save it,  then compare the current time with the time of the last tick if the last tick was before 00:00 and the current tick is at or after 00:00 then Midnight has happened between tick and you can close your trades.  

2.   if you want to test on real tick data you will need to find a source and purchase a 3rd party tool,  MT4 does not natively support testing with real tick data.  Use google and you will find the tool,  advertising is not allowed on this Forum.  The timeframe you choose is mainly relevant if you are doing visual mode testing.

3.   there are a few sources of tick data but if you are looking for many years you are going to end up with many GBs of data and will probably end up paying for it.  The same place where you can buy the 3rd party tool to enable real tick data testing has a list of tick data sources.

 

adibi83:

1. I'm developing a trading strategy on FOREX markets which must close all open trades and cancel all existing orders at about 0:00. The easy way to do this is with "if" statement (if timeCurrent = 0:00:00 than....).

Now, I read that the "start()" method repeats every time there's a change in the market quote, that means every time there's a new tick. My question is: what if there's no new tick at 0:00:00? The "if" statement won't take place and the program won't send the cancellation orders? Does anyone have an idea to overcome this problem?

2. I want to test my strategy on a tick base historical data. To do this I need to run the strategy tester in an "every tick" model right? But I can't fully understand the "Period", meaning H1 or M1 or whatever... I know that H1 means 1 hour and M1 means 1 minute, but what difference does it make if I'm using "every tick" model?

3. I'm looking for historical data on forex currencies. I mean way back tick-based data, for up to 10 years back. My broker can't provide me that. Anyone knows where can I download\purchase it?

  1. Don't look for exactly the first second of the day. Find the existing order and test if they were opened yesterday.
    extern int      Magic.Number                    = 20121113;
    bool    MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES){
        if (!OrderSelect(iWhat, eSelect, ePool)    ) return (false);
        if (OrderMagicNumber() != Magic.Number     ) return (false);
        if (OrderSymbol()      != chart.symbol     ) return (false);
        if (ePool != MODE_HISTORY                  ) return (true);
        return(OrderType() <= OP_SELL); // Avoid cr/bal forum.mql4.com/32363#325360
                                        // https://forum.mql4.com/30708
                                        // Never select canceled orders.
    }
    #define HR2400 86400       // 24 * 3600
    int      TimeOfDay(datetime when){  return( when % HR2400            );    }
    datetime DateOfDay(datetime when){  return( when - TimeOfDay(when)   );    }
    :
        datetime today = DateOfDay(Time[0]);        // Or less efficient: DateOfDay(TimeCurrent())
    //  datetime today = iTime(NULL, PERIOD_D1, 0); // Or must less efficient.
        for(iPos = OrdersTotal() - 1; iPos >= 0; iPos--)
          if (MySelect(iPos, SELECT_BY_POS, ePool)){ 
            datetime oot  = OrderOpenTime();
            if( DateOfDay(oot) != today){ ...} // Order Opened yesterday time, to close.
        }

  2. It matters depending on your chart analysis E.g. moving average (nBars) highest high( nBars ).
  3. https://www.mql5.com/en/forum/141245 http://eareview.net/tick-data/download-free-tick-data
 
RaptorUK:

1.  note the time time each tick occurs and save it,  then compare the current time with the time of the last tick if the last tick was before 00:00 and the current tick is at or after 00:00 then Midnight has happened between tick and you can close your trades.  

2.   if you want to test on real tick data you will need to find a source and purchase a 3rd party tool,  MT4 does not natively support testing with real tick data.  Use google and you will find the tool,  advertising is not allowed on this Forum.  The timeframe you choose is mainly relevant if you are doing visual mode testing.

3.   there are a few sources of tick data but if you are looking for many years you are going to end up with many GBs of data and will probably end up paying for it.  The same place where you can buy the 3rd party tool to enable real tick data testing has a list of tick data sources.


A 3rd party tool means I'll have to write the code in a different platform or is there a tool that support MQL4 as well?

 

I understand advertising is prohibited here, so could you please send an e-mail? (adibi83@gmail.com)

 

TX 

 
WHRoeder:
  1. Don't look for exactly the first second of the day. Find the existing order and test if they were opened yesterday.
  2. It matters depending on your chart analysis E.g. moving average (nBars) highest high( nBars ).
  3. https://www.mql5.com/en/forum/141245 http://eareview.net/tick-data/download-free-tick-data

Thank you very much!