Need Day and time from my PC

 

Hi,

Anyone have a script to get the day and time from my PC for an EA?

I can't use the weird times I'm getting from Siberia or wherever the MT4 is displaying data times.

TIA

Bill H.

 

TimeLocal()

Time function here

To see time as a string

int start()
  {
   Comment("Time Last Tick ", StrToTime(TimeLocal()) ) ;   
   return(0) ;
  }
 

Please can you or anybody in this forum help and give me the right code for solving the situation below:

1. my EA trade very good but it open a new position immediately after taking profit even if the market is going other way.

2. i want a code that will not allow two same order-type from following each other after taking profit.( once it takes profit for example on buy trade, it should wait for next sell signal before opening new position for that same symbol)


i used OrderHistoryTotal but i did not get the right coding.

 
Ickyrus:

TimeLocal()

Time function here

To see time as a string


Thanks Ickyrus, I will try that.

Bill H.

 
ayogbenga2003:

Please can you or anybody in this forum help and give me the right code for solving the situation below:

1. my EA trade very good but it open a new position immediately after taking profit even if the market is going other way.

2. i want a code that will not allow two same order-type from following each other after taking profit.( once it takes profit for example on buy trade, it should wait for next sell signal before opening new position for that same symbol)


i used OrderHistoryTotal but i did not get the right coding.


ayogbenga2003, don't post your question on another subject inside someone elses question, it may not get read.

Your question is just logic, to have a buy and then a sell, then a buy and then a sell.

extern int BuyOrSell = 0;

if (BuyOrSell != 1 && whatever your criteria is to buy) // allows 0 to begin or previous trade was a sell

{do your buy

BuyOrSell = 1 } // Buys = 1

if (BuyOrSell != 2 && whatever your criteria is to sell) // allows 0 to begin or previous trade was a buy

{do your sell

BuyOrSell = 2 } // Sells = 2

 
15011974:


Thanks Ickyrus, I will try that.

Bill H.


Ickyrus, that gets the stupid data tick time, not the time from my PC.

 
//< This is EA : Compile and run in folder "/experts" >

 
int start()
{
static int iClockPeriod = 1000 ;
 
static int iTimeStamp          ;
static int iRunTime            ;
 
while  ( ! IsStopped () )
       {
           iTimeStamp = GetTickCount ()                                                        ;
 
           Comment    ( "Day of week "  , DayOfWeek ()                                , "\n" ,
                        "PC time "      , TimeToStr ( TimeLocal   () , TIME_SECONDS ) , "\n" ,
                        "Server time "  , TimeToStr ( TimeCurrent () , TIME_SECONDS )        ) ;
 
           iRunTime   = GetTickCount () - iTimeStamp                                           ;
           Sleep      ( iClockPeriod    - iRunTime                                           ) ;
       }
}
 
//</This is EA : Compile and run in folder "/experts" > 

Reason: