How to identify how many bars has passed after opening position

 

Hi All

I need help on EA programming.

How to identify How many Bar(s) have passed from my opening position.


Thank you

Regards

Willy

 
wtjs wrote >>

Hi All

I need help on EA programming.

How to identify How many Bar(s) have passed from my opening position.

Thank you

Regards

Willy

Select the order and use iBarShift

iBarShift(Symbol(),0,OrderOpenTime() )

 
romrob:

Select the order and use iBarShift

iBarShift(Symbol(),0,OrderOpenTime() )

Thanks Rob, will try it.

 
Or do it yourself
int start()
{
  static datetime Time.newBar;	            // Or test EACH tick (Volume[0]<=1)
  bool newBar	= (Time[0] > Time.newBar);  if (newBar) { // A new bar began.
    Time.newBar = Time[0];
    static int order.bars;// = 0 // Initialized after the OrderSend().
    order.bars++; // How many bars has order been open.
    //...
  }
  //...
  OrderSend(...);
  order.bars = 0; // Reset for next bar.
}
 
WHRoeder:
Or do it yourself

WHRoeder Thanks a lot buddy, I will try this too.

Reason: