Use of datetime to open orders

 

Hi all,

 

 What I'm looking for is way to get a signal to open orders based in datetime I mean,  if time now is different from time previous then the price will obviously be different and so if  Bid now is n pips above (or down) the Bid of time previous then a condition is created to open an order.

Could anyone tell me if this is possible and if yes what should be the right way to get it.

thanks in advance for any support provided.

Best regards

Luis 

 
luisneves:

Hi all,

 

 What I'm looking for is way to get a signal to open orders based in datetime I mean,  if time now is different from time previous then the price will obviously be different and so if  Bid now is n pips above (or down) the Bid of time previous then a condition is created to open an order.

Could anyone tell me if this is possible and if yes what should be the right way to get it.

thanks in advance for any support provided.

Best regards

Luis 


 BUYLIMIT

SELLLIMIT

BUYSTOP

SELLSTOP 

 
Wait for a new bar and compare the current price to previous bar
int start(){
   static datetime Time0; if (Time0 == Time[0]) return; Time0 = Time[0];
   // start of a new bar
   double priceNow = Bid; // or Close[0]
   double pricePrev= Close[1]; // 1 Period() minutes ago
 

Hi WHRoeder,

Thank you for your prompt response to my issue.

Just clarify me, when you say // start of a new bar means that it just work on bar start or can take any price during the bar (real time price ) ?

Nevertheless I will implement your code right now.

 once again thank you for your support.

Luis 

 
deVries:


 BUYLIMIT

SELLLIMIT

BUYSTOP

SELLSTOP 


Hi deVries,

 Thank you for your attention to my issue.

Yes, in fact opting for pending orders all that stuff is out.

Best regards

Luis 

Reason: