Completed Bar - page 2

 
wackena:
nondisclosure:

Wackena, I take it 60 is one hour. change for other time frames, ie 15 for 15 minutes, 240 for 4 hours, etc. Am I correct?


Yes, buy only if you use sufficient chart timeframe. Example: Max m value on M30 chart is M=30.

Wackena

Got it. m <= current tf on chart.

BTW, I see the variable g, but what is it used for? I don't see it used anywhere else in the calculations. But I'm guessing for hours left?

 

Yes, g is for hour ouput.

I use this code to comment remaining Bar time on chart with hour, minute, second.

int h,m,s;
m=Time[0]+Period()*60-TimeCurrent();;
s=m%60;
m=(m-m%60)/60;
if(m>=60) h=m/60; else h=0;
m=m-(h*60);
Comment(h," hours ",m," minutes ",s," seconds left to bar end");
 

Wackena / et al,

Where am I going wrong here? Take a look at this code:

int start()
{
  BeginHandleStopLoss();
  if (newbar()==false)  return(0);
  HandleOpenPositions();
  if (CheckOpenPositions() > 0) return(0);
  lotMM = GetLots();
  if(BuySignal())  
  {
      OpenBuyOrder();
     return(0);
  }
  if(SellSignal()) 
  {
     OpenSellOrder();
  }
  return(0);
}
 
bool newbar()
{
   double g;
   int m,s,k;
   m=Time[0]+Period()*60-TimeCurrent();
   g=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   if(m==Period()) return(true);
//   if(m==0) return(true);
   return(false);
}

It "should" kick out of the start() if it's not a new candle on the TF that I have the EA on (currently D1). But it's not exiting out of start. It's still running the rest of the code in start. Am I missing something? It does it for whomever's code for new bar I try.

THANKS IN ADVANCE FOR ALL YOUR HELP!!!!!!

 

Try this: I've not tested this, I hope it works.

int start()
{
  BeginHandleStopLoss();
  if (newbar()==Period()) {
  HandleOpenPositions();
  if (CheckOpenPositions() > 0) return(0);
  lotMM = GetLots();
  if(BuySignal())  
  {
      OpenBuyOrder();
     return(0);
  }
  if(SellSignal()) 
  {
     OpenSellOrder();
  }
  return(0);
}
}
 
int newbar()
{
   double g;
   int m,s,k;
   m=Time[0]+Period()*60-TimeCurrent();
   g=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   return(m);
}
 
THANKS!!  I'll give a shot when I get home, let it run for a couple of days and I'll let ya know in here.  Again, thanks!