Hello I have written this piece of code into my EA but it's not working kindly help me correct the bug and make it function well:
Below are the the conditions under which the function should follow:
Every time a multiple of "n_op" successive loss-making operations is reached, the EA increases both the lot and the TP. If e.g. n_op=5 and we have just closed the fourth trade at a loss, the fifth trade will have tp and lot as follows set Y = (number of subsequent losing operations +1) / n_op. When Y is an integer we apply the lot and TP change to the trade we are opening, holding and using the Y value as follows lot: lot_start + lot_incr x Y tp: opening quota + take_profit x take_profit_multiplier x Y.
Belo is also my written code though not working. Help me solve this as per the conditions. Thank you.
MODE_TRADES is used to search the open trades only, right?
from mt4 documentation...
OrderSelectpool=MODE_TRADES
[in] Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values:
MODE_TRADES (default)- order selected from trading pool(opened and pending orders),
MODE_HISTORY - order selected from history pool (closed and canceled order).
pool=MODE_TRADES
[in] Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values:
MODE_TRADES (default)- order selected from trading pool(opened and pending orders),
MODE_HISTORY - order selected from history pool (closed and canceled order).
OrderSelect
pool=MODE_TRADES
[in] Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values:
MODE_TRADES (default)- order selected from trading pool(opened and pending orders),
MODE_HISTORY - order selected from history pool (closed and canceled order).
You mean I should use MODE_HISTORY instead
Your code will only report the total number of losses. if you want just the consecutive losses, then you will need to search for order by date first. And I suggest that you search codebase. There will be some scripts or codes in there that are already made to do what you want.
Ok thank you
Open or pending.
MT4:
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum #4 and #5 (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - «TICKET»
Rollover - «TICKET»>R/O - 1,000 EUR/USD @0.52 #«ticket» N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello I have written this piece of code into my EA but it's not working kindly help me correct the bug and make it function well:
Below are the the conditions under which the function should follow:
Every time a multiple of "n_op" successive loss-making operations is reached, the EA increases both the lot and the TP. If e.g. n_op=5 and we have just closed the fourth trade at a loss, the fifth trade will have tp and lot as follows set Y = (number of subsequent losing operations +1) / n_op. When Y is an integer we apply the lot and TP change to the trade we are opening, holding and using the Y value as follows lot: lot_start + lot_incr x Y tp: opening quota + take_profit x take_profit_multiplier x Y.
Belo is also my written code though not working. Help me solve this as per the conditions. Thank you.