Calculation-problem with Lotsize: mql4, local version 082
-
Hello,
Content: see attachments:
I have the problem to calcultate the lotsize of the next buy pending order. The ea start a buy now order. If the order is excecute the block 14 check the profit. If the profit of the last open order is more than -x pips then block 14 will excecute with 'yes'.
Block 17 calculates: the number of buylots * an multipler. The result is 'bLot1'.
Block 18 calculates: the result of block 17 'bLot1' * the number of longcount are currently trade.
The result of block 18 will be giving to block 19 'Money Management - Formula Result' as Lotsize the the next buy pending.Example of the shall-calkulation of the Lotsize of block 19: 1 * 2 * 3 = 6 Lot; (this is ok).
Problem: The last opend order is not multiplied by the multipler. Only the result of block 17 is added to the following opened Pendings.
How can I calculate that a new opended pending order is calculated in the manner: (last oprend order lotsize) * (multiper) so that
Lotsize of pending order 1 is = 1
Lotsize of pending order 2 is = 2
Lotsize of pending order 3 is = 4
Lotsize of pending order 4 is = 8
and so on.
I will not use block 'buy pending order in a grid'regards and thanks in advanced,
Dieter......
Screenshot - Calculationproblem.gif
Calkulationproblem.xml -
Why do I feel that is can be easier. Here is almost the same thing: viewtopic.php?p=6259#p6259
And better don't use variables to organize lot size like this. I mean... what if the EA is restarted, all the temporary data will be lost and it will start from 0. But if you get data from trades and orders directly, everything will be fine. Well, it depends.
Also, if possible don't use those Trade statistics. When they are used, special mechanism is turned on, and this causes the whole EA to work slowed on backtest. -
Thanks,
If the variables that calculate the lotsize can be lost, if the ea will be restart. How can I optimize the lotsize in this example http://prntscr.com/3nnjy3 ? The lotmultipler (*2) of the last trade is fixed?
The optimization is to improve the lotmultipler (*2).Dieter
-
You can always define some Constant and use it inside the project everywhere. All Constants are input parameters for the EA that can be optimized... they are global variables actually, but think of them as constants. If it's a numeric with value 2 and name MyConstant, use *MyConstant instead of *2.