Exploit Strtotime

 

Hi guys :),


so i want to create an EA which use string values to define a time which allow open a position.

Real example:

extern string  TimeStart= "10:00";

datetime TL= TimeLocal;

datetime Time-S;

Time_S= StrToTime(TimeToStr(TL, TIME_MINUTES)+" "+TimeStart);
I want to know how exploit this like that:


If ( "My question" == (Time_S))

      Ordersend...............


Thanks all :)

 
Kane59: so i want to create an EA which use string values to define a time which allow open a position.
extern string  TimeStart= "10:00";
:
datetime now   = TimeCurrent(),
         start = StrToTime(TimeStart);
if (now >= start){ // Allowed to trade
You can also use double startTime=10., endTime=18 and my code which allows the times to be optimized in the tester. Use a string and you can't.
 
Hello,

thanks for your reply.


I will try that.

Can i use TimeLocal for datetime now?

 
WHRoeder:
You can also use double startTime=10., endTime=18 and my code which allows the times to be optimized in the tester. Use a string and you can't.

Yes, but about my tester, it doesn't work correctly. It doesn't find a lot of ticks for optimisation. In 6 years, it could find only 24 specials ticks and said to me were not interesting...
 
Local time is your machine time. No connection with the broker's time, or tester's emulated time.
 

Thanks,


I know that, but if i use "TimeLocal", nothing will pass?


Maybe i have to calculate difference time between TimeLocal and Timecurrent so?

 

My Strat is simple:

I just want if a XX:XX time in my local time arrive, EA open trade. If only TimeCurrent is considered, so I have to do TimeLocal - TimeCurrent to have difference and work with this?

Or can i do this? :

datetime Now   = StrToTime(TimeToStr(TimeLocal(),Time_Minutes)),
         start = StrToTime(TimeStart);
if (Now >= start){ // Allowed to trade

Thanks :)


Edit: Yes if understood correctly, i have to convert my local time to string to be used by my EA like a current time. Am I in a nice way?

 

Sorry, but anyone can tell me if i understood correctly?


Thanks by advance :)

 
Kane59:

My Strat is simple:

I just want if a XX:XX time in my local time arrive, EA open trade. If only TimeCurrent is considered, so I have to do TimeLocal - TimeCurrent to have difference and work with this?

Or can i do this? :

Yes you can,  but why would you ?  why would you convert a datetime to a string so that you can convert the string back to a datetime ?

datetime Now   = TimeLocal(),
         start = StrToTime(TimeStart);

if (Now >= start){ // Allowed to trade

 Isn't this more efficient ? and it will give the same result.

 
Kane59:

Sorry, but anyone can tell me if i understood correctly?

Determine the difference between your local time and your Brokers time and then use your Brokers time . . .  so, tomorrow, when the markets are open, check your local time and check your Brokers time,  if the difference is 2 hrs (Your Broker is 2 hrs ahead of you )  and you want to trade after 10am local time you just code,   time >= 12:00
 
RaptorUK:

Yes you can,  but why would you ?  why would you convert a datetime to a string so that you can convert the string back to a datetime ?

 Isn't this more efficient ? and it will give the same result.

 

Hi Raptor and thanks :)

Yes like you tell me, it seem to be stupid to write code like that, thanks :)

RaptorUK:
Determine the difference between your local time and your Brokers time and then use your Brokers time . . .  so, tomorrow, when the markets are open, check your local time and check your Brokers time,  if the difference is 2 hrs (Your Broker is 2 hrs ahead of you )  and you want to trade after 10am local time you just code,   time >= 12:00

You advice me to use only the server time? So calculate the difference between Local and Current.

Many many thanks toWHRoeder and you Raptor for the time passed with me to explain how to write my code :)

Reason: