calculate candles after pending order

 
Hello everyone, I've been trying to create a code to count candles from the last pending order, so that after x candles of the pending order, it automatically cancels.
However, I didn't get to the calculation, could someone give me a tip?
 
  • Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).
  • Finally, you also have the option to hire a programmer in the Freelance section.
MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for MetaTrader 5
 
Fernando Carreiro #:
  • Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).
  • Finally, you also have the option to hire a programmer in the Freelance section.

Yes, thanks, i really cannot code but i learning actually. That is the reason for my question.
And, i think that my description is very clearly and i don't have a code, because all my tryes do not plays, but thank so much.

I believe that don't understood the proposite of this forum, i'm so sorry.

 
w.s.g:
Hello everyone, I've been trying to create a code to count candles from the last pending order, so that after x candles of the pending order, it automatically cancels.
However, I didn't get to the calculation, could someone give me a tip?

1. First add a checkmark when your pending order is triggered, e.g. 

bool executed =true;
// Find candle where order executed
int shift = iBarShift(NULL,0,iTime(NULL,0,1));

then start counting 

int candle = 5; // lets say you want to exit at 5th candle from when order is executed

then run a for loop as per your requirement to close order 

 
w.s.g:
Hello everyone, I've been trying to create a code to count candles from the last pending order, so that after x candles of the pending order, it automatically cancels.
However, I didn't get to the calculation, could someone give me a tip?

Why not set expiration date?

datetime expiry=TimeCurrent()+bars_count*PeriodSeconds();
 
Yashar Seyyedin #:

Why not set expiration date?

Thanks Yashar, its done!

 
Arpit T #:

1. First add a checkmark when your pending order is triggered, e.g. 

then start counting 

then run a for loop as per your requirement to close order 

Thanks you, i got it!

 
w.s.g #:

Thanks you, i got it!

Could you please post your code here so I can see how you coded this solution? I´m trying to learn it´d be very helpful

Could you please post your code here so I can see how you coded this solution?

I´m trying to learn and it would be really helpful for my general understanding

Thanks a lot.