Place order right before candle/bar ends on daily timeframe

 

Hello forum, good day.

I'm making a Pending Orders EA using a daily timeframe, and I need to place the orders on the same day that certain criteria is met. For example, lets say that if at 16.01.2014 +DI > -DI and previous candle (from 15.01.2014) is black/bearish, a BuyStop order should be placed; for SellStop orders would be viceversa (+DI < -DI and previous candle is white/bullish). Is it possible to place the order right before the candle ends with Open price of previous candle?

I'm still new to MQL5 and would appreciate if someone with more experience could help me out with a simple example so I can take it from here.

 

Regards and thank you,

codeMolecules 

 
codeMolecules:

Hello forum, good day.

I'm making a Pending Orders EA using a daily timeframe, and I need to place the orders on the same day that certain criteria is met. For example, lets say that if at 16.01.2014 +DI > -DI and previous candle (from 15.01.2014) is black/bearish, a BuyStop order should be placed; for SellStop orders would be viceversa (+DI < -DI and previous candle is white/bullish). Is it possible to place the order right before the candle ends with Open price of previous candle?

I'm still new to MQL5 and would appreciate if someone with more experience could help me out with a simple example so I can take it from here.

 

Regards and thank you,

codeMolecules 

Yes it's possible. Why not ?
 
angevoyageur:
Yes it's possible. Why not ?

Hello angevoyageur, thanks for your response.

Could you or someone with more experience help me with a simple example so I can take it from here or point me in the right direction please? I guess that what I need to do is to check for a new tick every n period of time and just before the day ends, see if criteria (ADX and type of previous candle) is met, and if so, place the order right before the day ends.

Your help will be much appreciated. 

 

Regards and thank you in advance,

codeMolecuels 

 
codeMolecules:

Hello angevoyageur, thanks for your response.

Could you or someone with more experience help me with a simple example so I can take it from here or point me in the right direction please? I guess that what I need to do is to check for a new tick every n period of time and just before the day ends, see if criteria (ADX and type of previous candle) is met, and if so, place the order right before the day ends.

Your help will be much appreciated. 

 

Regards and thank you in advance,

codeMolecuels 

You don't need a tick, you can't be sure to have a tick when you need one. Use a timer.

Please show what you tried and maybe I can help you.

 
angevoyageur:

You don't need a tick, you can't be sure to have a tick when you need one. Use a timer.

Please show what you tried and maybe I can help you.

Hello angevoyageur, good day.

I'll attach a file with what I have so far.

What this EA does so far is wait for current day close, then check conditions when 1st tick of new day appears. If conditions (current +/- DI and just closed candle color) meet criteria, use previous (just closed) day open price.

What I need is to check if +DI > -DI and previous candle is black/bullish (for BuyStop orders) right at the beginning of a new day/candle (lets say at 00:01 h.). If this criteria is met, then a pending order should be opened this same day. If the order is not placed that same day the order was opened, then the order should be deleted and check criteria next day. 

Regards and thank you in advance,

codeMolecules 

Files: