closing a trade within n bars?

 
suppose I want to close a trade in n bars  (say n=5) if the price doesnt move at least 15 pips in my favor. How do I code that? I know for the trade entry price I use OrderOpenPrice() but how do I get the iClose for the next few bars? its because subsequent bars will constantly load up so I cant use iClose function with a fixed shift.
 
1mathboy1:
suppose I want to close a trade in n bars  (say n=5) if the price doesnt move at least 15 pips in my favor. How do I code that? I know for the trade entry price I use OrderOpenPrice() but how do I get the iClose for the next few bars? its because subsequent bars will constantly load up so I cant use iClose function with a fixed shift.
What does iClose() have to do with this ?  Closing a trade when it is x bars old has been asked and answered at least once in the last 3 months,  have a search for it . . .  or just look at today's posts.
 

takeprofit of 15, stoploss?.. and https://docs.mql4.com/series/iclose??.,,assuming you use a new bar verification , just count bars ,, then close trade(s).

afunction to give you exactly what you need sounds in order. not iclose since you just need close after x num of bars, nothing more.

make sure your counting bars when the signal is no longer NA.
Reason: