Questions from Beginners MQL5 MT5 MetaTrader 5 - page 828

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
/
/
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in the "ExtLot" variable, declared at global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
If at Stop Loss, we double the lot, if at Take Profit, we reset the lot size to its minimum value.
Note: in the Expert Advisor itself the calculation of Stop Loss and Take Profit is a little bit incorrect - but the code will be republished soon.
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in "ExtLot" variable declared on global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
If at Stop Loss, we double the lot, if at Take Profit, we reset the lot size to its minimum value.
Note: in the Expert Advisor is slightly incorrect calculation of Stop Loss and Take Profit - but soon republished code.
I calculate the number of profitable trades going in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
I calculate the number of profitable trades in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
You need to use a static variable in the lot counting function. Here's how it works:
Result:
0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2
You need to use a static variable in the lot counting function. Here's how it works:
Result:
I reset according to your example, but I can't get the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 but it should be1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
What is wrong?
I am zeroing according to your example, but I am not getting the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 and it turns out so1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
What's wrong?
So you still do not want to use OnTradeTransaction in a normal way? So, you prefer to request EXACTLY the entire trading history (since 1970)? Why?
So you don't want to work properly with OnTradeTransaction? So you prefer to request ABSOLUTELY ALL trading history (since 1970)? Why???
Found a reason, brackets.
What do you mean I don't want to, what doesOnTradeTransaction have to dowith my question ;)
Now, I see, two posts before my question, an example of the calculation.
Thank you.
Found the reason, brackets.
What do you mean I don't want to, what doesOnTradeTransaction have to dowith my question;)
Just asking for trading history
means requesting all, all, all of the history from that trading account since 1970. This is very sub-optimal:
Please share the functions that work with the trading history.
I need to get information about the date of last trade opening, closing, volume, financial result and its type (buy or sell).
If you have any similar functions, please share them.