Download MetaTrader 5
To add comments, please log in or register
Have you developed a trading robot? Publish it in the Market and make profit!
poklopec
32
poklopec 2014.10.25 12:28 

what is best way for trade once per bar ??? or for create only 1 object at bar.

and how I can do to procced my EA full? I mean to ignoring new tickets to reset my ea from a new beginning on every tick so ea can procced all code in it.

Carl Schreiber
5959
Carl Schreiber 2014.10.26 07:43  
NextTradeBar = _Period*60 + Time[i]; // Time[i] = bar of last trade
if (TimeCurrent() <= NextTradeBar) return;
// untested!!
2) don't understand what you want.
rod178
276
rod178 2014.10.26 08:41  
augi182:

what is best way for trade once per bar ??? or for create only 1 object at bar.

and how I can do to procced my EA full? I mean to ignoring new tickets to reset my ea from a new beginning on every tick so ea can procced all code in it.

bool checkNewBar(int barPeriod, bool initOnly)
{  
   if(barPeriod<=0 && initOnly==true) return(false);
   int timeOldBar=0;  
   switch(barPeriod)
   {
      case PERIOD_M1:  static int timeOldBarM1 =-1; timeOldBar=timeOldBarM1;  break;
      case PERIOD_M5:  static int timeOldBarM5 =-1; timeOldBar=timeOldBarM5;  break;
      case PERIOD_M15: static int timeOldBarM15=-1; timeOldBar=timeOldBarM15; break;
      case PERIOD_M30: static int timeOldBarM30=-1; timeOldBar=timeOldBarM30; break;
      case PERIOD_H1:  static int timeOldBarH1 =-1; timeOldBar=timeOldBarH1;  break;
      case PERIOD_H4:  static int timeOldBarH4 =-1; timeOldBar=timeOldBarH4;  break;
      case PERIOD_D1:  static int timeOldBarD1 =-1; timeOldBar=timeOldBarD1;  break;
      case PERIOD_W1:  static int timeOldBarW1 =-1; timeOldBar=timeOldBarW1;  break;
      case PERIOD_MN1: static int timeOldBarMN1=-1; timeOldBar=timeOldBarMN1; break; 
   }      
   int countFrom;
   int count=0;
   if(barPeriod<=PERIOD_H1) {countFrom=PERIOD_H1;} else countFrom=barPeriod;
   while(count<=countFrom-barPeriod)
   {
      if(timeOldBar<0 || (TimeMinute(TimeCurrent())==count && TimeCurrent()>=iTime(NULL,barPeriod,0) && count!=TimeMinute(timeOldBar)))
      {   
         Print("tttt  ",TimeHour(TimeCurrent()),":",TimeMinute(TimeCurrent()),"  count->",count,"     TimeCurrent->",TimeCurrent(),"    timeNewOpen->",iTime(NULL,barPeriod,0),"    timeOldBarOpen->",timeOldBar ); 
         switch(barPeriod)
         {
            case PERIOD_M1:  timeOldBarM1 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_M5:  timeOldBarM5 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_M15: timeOldBarM15=iTime(NULL,barPeriod,0); return(true);
            case PERIOD_M30: timeOldBarM30=iTime(NULL,barPeriod,0); return(true);
            case PERIOD_H1:  timeOldBarH1 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_H4:  timeOldBarH4 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_D1:  timeOldBarD1 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_W1:  timeOldBarW1 =iTime(NULL,barPeriod,0); return(true);
            case PERIOD_MN1: timeOldBarMN1=iTime(NULL,barPeriod,0); return(true); 
         }    
      }
      count=count+barPeriod; //Print("**************** ",count);
   }
   return(false);                
}
poklopec
32
poklopec 2014.10.27 00:01  
2) example I mean that EA ignore new tickets for 10 second(ea didnt start from beginning of his code for 10 seconds)
rod178
276
rod178 2014.10.27 06:07  
augi182:
2) example I mean that EA ignore new tickets for 10 second(ea didnt start from beginning of his code for 10 seconds)

You stated trade 'once per bar'.  MT4 does not support less than M1.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.10.27 06:25  
augi182:
2) example I mean that EA ignore new tickets for 10 second(ea didnt start from beginning of his code for 10 seconds)
Create a timer then.
poklopec
32
poklopec 2014.10.27 09:49  
And how? I never do anything with time :(
Carl Schreiber
5959
Carl Schreiber 2014.10.27 11:32  
Read the book or the docs.
whroeder1
13641
whroeder1 2014.10.27 13:04  
augi182: And how? I never do anything with time :(
  1. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. void OnStart(){
       static datetime delay=0;
       if(TimeCurrent() < delay) return;
       :
       delay = TimeCurrent() + 10;      // Ignore for 10 seconds
    
    How hard is that?
/
To add comments, please log in or register