Download MetaTrader 5

I need help - page 2

To add comments, please log in or register
qjol
3243
qjol  
deysmacro:
At least I read the doc though. None of this happened to me. XD

at least the main commands
Toast
226
Toast  

Give the original poster a break.

They came here asking for help, nobody was forced to reply. And they made an attempt at coding it themselves.

Everybody has to start somewhere; the only thing this complaining achieves is filling threads with self-congratulatory detritus.

Ian Venner
2584
Ian Venner  
toast:

Give the original poster a break.

They came here asking for help, nobody was forced to reply. And they made an attempt at coding it themselves.

Everybody has to start somewhere; the only thing this complaining achieves is filling threads with self-congratulatory detritus.

Yes sometimes it's like a trial by fire lol
Keith Watford
Moderator
9644
Keith Watford  

I suspect that the OP is using this code as a test in the strategy tester.

If so, it is possible that the data history for 28 June 2013 does not exist or there is mismatched data for that period

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
GumRai:

I suspect that the OP is using this code as a test in the strategy tester.

If so, it is possible that the data history for 28 June 2013 does not exist or there is mismatched data for that period


Its always possible. But OP haven't said anything about strategy tester. Though most probably the code is for strategy tester.
Bruce
30
Bruce  
GumRai:

I suspect that the OP is using this code as a test in the strategy tester.

If so, it is possible that the data history for 28 June 2013 does not exist or there is mismatched data for that period


Yes, these codes is only for test. There was data on that day because if I seperate the codes to two, it can work.
Daniel Petrovai
440
Daniel Petrovai  
19842008:

Explanation: It can not print "My Month is 6",why? It can only print "My Month is 8".


The only way it could not print "My month is 6" is if your test period starts after june 6, 2013.

I believe it isn't the case here, the real problem is that it prints so many times "My month is 8, that you can't see the other print.

There are some limits to the amount of stuff printed in the journal. You can see that if you check the time and date on the first print in the journal.

You will find that it is not the 2013,08,28 00:00:01.

The easy work around is to place a counter an let it print just once :

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   int TicketYear=TimeYear(TimeCurrent());
   int TicketMonth=TimeMonth(TimeCurrent());
   int TicketDay=TimeDay(TimeCurrent());
   static int count1=0;
   static int count2=0;
   if(count1<1&&TicketYear==2013 && TicketMonth==8 && TicketDay==28)
     {
      Print("My Month is ",TicketMonth);
      count1++;
     }
   if(count2<1&& TicketYear==2013 && TicketMonth==6 && TicketDay==28)
     {
      Print("My Month is ",TicketMonth);
      count2++;
     }
  }
//+------------------------------------------------------------------+

or, depending on what you want to achieve, you can use it like this :

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   int TicketYear=TimeYear(TimeCurrent());
   int TicketMonth=TimeMonth(TimeCurrent());
   int TicketDay=TimeDay(TimeCurrent());
   static datetime prevTime=0;
   datetime timeNow=iTime(NULL,PERIOD_D1,0);
   if(prevTime!=timeNow&&TicketYear==2013 && TicketMonth==8 && TicketDay==28)
     {
      prevTime=timeNow;
      Print("My Month is",TicketMonth);
     }
   if(prevTime!=timeNow&& TicketYear==2013 && TicketMonth==6 && TicketDay==28)
     {
      prevTime=timeNow;
      Print("My Month is",TicketMonth);
     }
  }
//+------------------------------------------------------------------+

If you want to print (or alert ) every hour, you can change the period to whatever suits you.

Hope it helps .

Cheers

12
To add comments, please log in or register