with & endwith statement for mql5

 
hi all, is there something in MQL5 that is similar to excel vba macro for this: instead of: Cells.Activate Cells.Copy Cells.PasteSpecial xlPasteValues Cells.Delete to keep the code tidier: With Cells .Activate .Copy .PasteSpecial xlPasteValues .Delete End With in MQL5, how can i make the code tidier like above? MqlTradeRequest myrequest; myrequest.type = ORDER_TYPE_BUY; myrequest.action = TRADE_ACTION_DEAL; myrequest.tp = 0; myrequest.sl = 0; how do i 'group' the myrequest with 'with' and 'endwith' statement like in vba excel? many thanks!
 

It is extremely difficult trying to decipher your code example when it is all just one continuous line.

Please insert your code samples properly with the CODE button (Alt-S).

Code button in editor

 
Regarding "with ... end with", I don't know of any such equivalent syntax in MQL nor C/C++ on which MQL is based.
 
antaeusguy:
hi all, is there something in MQL5 that is similar to excel vba macro for this: instead of: Cells.Activate Cells.Copy Cells.PasteSpecial xlPasteValues Cells.Delete to keep the code tidier: With Cells .Activate .Copy .PasteSpecial xlPasteValues .Delete End With in MQL5, how can i make the code tidier like above? MqlTradeRequest myrequest; myrequest.type = ORDER_TYPE_BUY; myrequest.action = TRADE_ACTION_DEAL; myrequest.tp = 0; myrequest.sl = 0; how do i 'group' the myrequest with 'with' and 'endwith' statement like in vba excel? many thanks!

I suppose you can implement this yourself, like the foreach loops, which do not exist in MQL5 either: https://www.mql5.com/en/articles/4332

LifeHack for traders: Blending ForEach with defines (#define)
LifeHack for traders: Blending ForEach with defines (#define)
  • www.mql5.com
The article is an intermediate step for those who still writes in MQL4 and has no desire to switch to MQL5. We continue to search for opportunities to write code in MQL4 style. This time, we will look into the macro substitution of the #define preprocessor.