efficiency in 2 different scenario of code structure on mql4 Expert Advisor

efficiency in 2 different scenario of code structure on mql4 Expert Advisor

Manage alerts

Loading saved threads...

Luandre Ezra · External communityPost link
External question — Stack Overflow Stack Exchange Author: Luandre Ezra Original post: https://stackoverflow.com/questions/73864646 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Hi I have EA with code structure like this, void OnTick() { resetCounterVar(); //there's for loop CloseOrders(); //there's for loop UpdateAllOpenOrders(); //there's for loop SetSLTP(); //there's for loop CheckPendOrder(); //there's for loop if(IsNewCandle() && pendingOrderCount<MaxPendingOrder) OpenOrders(); } I want to make the for loop instead for every function into like this, for(int i = OrdersTotal() - 1; i >= 0; i--) { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol() == Symbol() { resetCounterVar(); CloseOrders(); UpdateAllOpenOrders(); SetSLTP(); CheckPendOrder(); if(IsNewCandle() && pendingOrderCount<MaxPendingOrder) OpenOrders(); What I want to ask does the second code structure more efficient then the first one?
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Luandre Ezra Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/73864646 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Hi I have EA with code structure like this, void OnTick() { resetCounterVar(); //there's for loop CloseOrders(); //there's for loop UpdateAllOpenOrders(); //there's for loop SetSLTP(); //there's for loop CheckPendOrder(); //there's for loop if(IsNewCandle() && pendingOrderCount<MaxPendingOrder) OpenOrders(); } I want to make the for loop instead for every function into like this, for(int i = OrdersTotal() - 1; i >= 0; i--) { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol() == Symbol() { resetCounterVar(); CloseOrders(); UpdateAllOpenOrders(); SetSLTP(); CheckPendOrder(); if(IsNewCandle() && pendingOrderCount<MaxPendingOrder) OpenOrders(); What I want to ask does the second code structure more efficient then the first one?

Cancel quote

Checking account access…