So I managed to incorporate a loop that deletes the pending order and re-applies another one on the basis that the stop is synced with the moving average. The lots would be calculated based upon the pip distance of entry to stop. Not only this, but I have managed to work out how the profit target working with the stop distance as a ratio (extern int - something I choose 1-2-3 R;R etc.) - so this too also moves as well.
So thanks for comments on previous posts with regards to Printing out my code and other bits and bobs!
Anyway - I am trying to close out half of the position when price reaches 50% of my 2x ratio profit target... I know I need to Print things out to the Journal and I am currently writing that in now, but could anyone tell me if I am writing this wrong in anyway? Perhaps with regards to "OrderLots()/2"?
"btp" = returns a specific price.
I don't think that OrderLots()/2 will cut it ( pardon the pun ) in all situations, I'm pretty sure you need to validate the position size you are looking to close against MarketInfo() MODE_LOTSTEP and MODE_MINLOT
Look here: https://www.mql5.com/en/forum/143966
Thanks RaptorUK - Not sure where I am looking WHRoeder on your link, but thanks.
Is it just me, or is the process for closing lots on an open position a little counter intuitive... seems unnecessarily complicated, considering what it is I am wanting to do...
Man, I think I have looked at this code enough for one day - I am not understanding how I use MarkerInfo() with OrderClose... it seems unnecessarily complex.
Thanks RaptorUK - Not sure where I am looking WHRoeder on your link, but thanks.
Is it just me, or is the process for closing lots on an open position a little counter intuitive... seems unnecessarily complicated, considering what it is I am wanting to do...
Man, I think I have looked at this code enough for one day - I am not understanding how I use MarkerInfo() with OrderClose... it seems unnecessarily complex.
I hope I can retain that level of programming one day... (with a little more patience on your behalf - just kidding :P)
Thanks WHRoeder!
Ah I got it! Thanks RaptorUK! Last question, when you say validate the lot size, are you saying compare it using If statements?
Nope, I'm saying adjust it so that it complies with MODE_LOTSTEP and MODE_MINLOT . . . then it is valid ( validated ), if you look at the link I posted . . .
mlots = MathFloor(mlots / lotstep) * lotstep;
Assume mlots was 0.15 mlots (MODE_MINLOT) was 0.1 and lotstep (MODE_LOTSTEP) is 0.1 so the code would do this
mlots = MathFloor(0.15 / 0.1) * 0.1;
// MathFloor(0.15 / 0.1) == MathFloor( 1.5 ) gives 1 // mlots = 1 * 0.1;
so mlots would be adjusted from 0.15 to 0.1 and would be valid.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I managed to incorporate a loop that deletes the pending order and re-applies another one on the basis that the stop is synced with the moving average. The lots would be calculated based upon the pip distance of entry to stop. Not only this, but I have managed to work out how the profit target working with the stop distance as a ratio (extern int - something I choose 1-2-3 R;R etc.) - so this too also moves as well.
So thanks for comments on previous posts with regards to Printing out my code and other bits and bobs!
Anyway - I am trying to close out half of the position when price reaches 50% of my 2x ratio profit target... I know I need to Print things out to the Journal and I am currently writing that in now, but could anyone tell me if I am writing this wrong in anyway? Perhaps with regards to "OrderLots()/2"?
"btp" = returns a specific price.