Exploit Strtotime - page 2

 
Kane59:

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

Yes,  correct.
 
RaptorUK:
Yes,  correct.


Ok tkanks again and again :) i will code this :)
 

I do what you tell me but nothing passed, my code is:

extern int     TF= 30;
extern string  Start= "23:00,02:00,09:00,14:00";
extern string  End=   "8:00,11:00,18:00,23:00";
datetime       Now= TimeCurrent();
double         Prix1,Prix2;
extern double  BougieS= 2;

Prix1=MarketInfo(Symbol(),MODE_ASK);
Prix2=MarketInfo(Symbol(),MODE_BID);
Time_S= StrToTime(Start);
Time_E= StrToTime(End);

 if (Allow==true)
 {
      if ((Now==Time_S)||(Now==Time_E))
      {
         for(int b=1; b<=BougieS+1; b++)
         {
            if (iClose(Symbol(),TF,b) > iClose(Symbol(),TF,b+1))
               OrderSend(Symbol(),OP_BUY,LotS,Prix1,0,SLSe,TPSe,NULL,MagicS,0,0);
      
            else if (iClose(Symbol(),TF,b) < iClose(Symbol(),TF,b+1))
               OrderSend(Symbol(),OP_SELL,LotS,Prix2,0,SLSe,TPSe,NULL,MagicS,0,0);
         }
      }      
 }
Is there an error?
 
Kane59:

I do what you tell me but nothing passed, my code is:

Is there an error?
Yes . .  .  this is not a time,  it is several times . .   23:00,02:00,09:00,14:00
 

Oh so i can't do like that... I have to write every time? No others solutions to do a list? Maybe like a swith so?


A list which be edit by extern "" under MT4

 
Kane59:

Oh so i can't do like that... I have to write every time? No others solutions to do a list? Maybe like a swith so?


A list which be edit by extern "" under MT4

Each time has to be stored in it's own variable . . . unless there is a relationship between the times that can be used to calculate the other times from the first . . .  then you only need to hold one in a variable.
 

ok ok. I was starting by this:

extern string Time_Start = "07:00,13:00,00:00,21:00";
extern string Time_End = "17:00,23:00,10:00,7:00";

   string positions[0], times_start[0], times_end[0]

   explodeStr(positions, Position, ",");
   explodeStr(times_start, Time_Start, ",");
   explodeStr(times_end, Time_End, ",");

time_start = StrToTime(TimeToStr(Time[j],TIME_DATE)+" "+times_start[i]);
         time_end = StrToTime(TimeToStr(Time[j],TIME_DATE)+" "+times_end[i]);

It's Kolier session indicator. As you see, there is 2 list of hours. The Indic use one hour of time start and one hour of time end to draw a line. i though that if i do same as it, my EA will extract one hour of the list and use it to read the price at the moment by a time Frame. The price will be used by "Ordersend" Where is my fault in the logic or in the code between mine and Kolier? 
 
Kane59:

ok ok. I was starting by this:

It's Kolier session indicator. As you see, there is 2 list of hours. The Indic use one hour of time start and one hour of time end to draw a line. i though that if i do same as it, my EA will extract one hour of the list and use it to read the price at the moment by a time Frame. The price will be used by "Ordersend" Where is my fault in the logic or in the code between mine and Kolier? 

If you are going to use someone else's code then you first need to understand that code.

The critical difference between your code and the code you have just posted is this . . .

string positions[0], times_start[0], times_end[0]

   explodeStr(positions, Position, ",");
   explodeStr(times_start, Time_Start, ",");
   explodeStr(times_end, Time_End, ",");

  . . .  do you understand what it does ?

 

oh i don't know for the moment. i do another thing and nothing passed:

extern string         TimeDayHighLow="12:43";

datetime Now= TimeCurrent(),
         TDHL= StrToTime(TimeDayHighLow);

if (Now==TDHL)
   {
//Buy conditions
      if (O<H)// Si Open B0 < High B1 ou 2     
      {
         OrderSend(Symbol(),OP_BUYSTOP,Lot,H,0,0,H+TP1,NULL,MagicHL,iTime(Symbol(), PERIOD_D1, 0 ) + (J*2*86395));
         OrderSend(Symbol(),OP_BUYSTOP,Lot,H,0,0,H+TP2,NULL,MagicHL,iTime(Symbol(), PERIOD_D1, 0 ) + (J*2*86395));

//Sell conditions  
      if (O>L)// Si Open B0 > Low B1 ou 2
      {
         OrderSend(Symbol(),OP_SELLSTOP,Lot,L,0,0,L-TP1,NULL,MagicHL,iTime(Symbol(), PERIOD_D1, 0 ) + (J*2*86395));
         OrderSend(Symbol(),OP_SELLSTOP,Lot,L,0,0,L-TP2,NULL,MagicHL,iTime(Symbol(), PERIOD_D1, 0 ) + (J*2*86395)); 

It's working without times conditions but not with.

I want to learn how to code but nothing i create is working. Maybe use string values for time is not efficient, i don't know. What can i do ? I don't know too....

 
Kane59:

oh i don't know for the moment. i do another thing and nothing passed:

It's working without times conditions but not with.

I want to learn how to code but nothing i create is working. Maybe use string values for time is not efficient, i don't know. What can i do ? I don't know too....

If you don't have a tick exactly at 12:43:00 then the Buy and Sell conditions won't be checked . . .  if you have a tick at 12:42:59 and the next at 12:43:02  then your Now time is never at 12:43
Reason: