How to work 'Open prices only'

 

Hello traders, I tried using this but it doesn't catch all the trades:

if(Volume[0]>1){return;}

I wonder if there is any other method for working 'Open prices only', cause optimization would be much more faster.

 

HI David,

I think by working"Open prices only" you want to execute the code only once per bar, you can use the following function to achieve the purpose.

static datetime bar_time=0; 

bool New_Bar()

{
 if(bar_time!=iTime(_Symbol,0,0))
  {
   bar_time=iTime(_Symbol,0,0);
   return true;
  } 

 return false;

}

Reason: