Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1128
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
Hello, I have a strange behavior of the system function OrderCalcProfit, I have a feeling that the volume parameter is ignored in the calculation, i.e. the profit value is always calculated for the volume 1.0
I am trying to check it in the tester for different currency pairs on different demo accounts.
1. Calculation is correct for 1.0, see calc_profi101.png.
2. The second and any subsequent calls of the function return a profit result based on a volume of 1.0, the value of volume is ignored, see a screenshot (calc_profit02.png) - passed volume 0.5, but the result is still the same as for 1.0
Can you tell me what the problem might be. Thanks
Hello, I have a strange behavior of the system function OrderCalcProfit, I have a feeling that the volume parameter is ignored in the calculation, i.e. the profit size is always calculated for the volume 1.0
I am trying to check it in the tester for different currency pairs on different demo accounts.
1. Calculation is correct for 1.0, see calc_profi101.png.
2. The second and any subsequent calls of the function return a profit result based on a volume of 1.0, the value of volume is ignored, see a screenshot (calc_profit02.png) - passed volume 0.5, but the result is still the same as for 1.0
Can you tell me what the problem might be. Thanks
I think the answer is in the help:
"... profit
[out] Variable that will hold the calculated profit value if the function succeeds. The value of the profit estimate depends on many factors and can change as the market environment changes. ... "
Added: although this is only a guess.
Hello, I have a strange behavior of the system function OrderCalcProfit, I have a feeling that the volume parameter is ignored in the calculation, i.e. the profit is always calculated for the volume 1.0
I am trying to check it in the tester for different currency pairs on different demo accounts.
1. Calculation is correct for 1.0, see calc_profi101.png.
2. The second and any subsequent calls of the function return a profit result based on a volume of 1.0, the value of volume is ignored, see a screenshot (calc_profit02.png) - passed volume 0.5, but the result is still the same as for 1.0
Can you tell me what the problem might be. Thanks
Here's the test examiner - everything works correctly:
and the result:
Can you give me a hint. Is it possible and how can I programmatically find out the language of the terminal in use?
I determine this either the Russian terminal language or if another - the output is in English.
Added: thought I saved all the languages from the TERMINAL_LANGUAGE enumeration - but can't find it. Must have lost ...
Good day everyone, can someone help to add here that at SL it would not just be a rollover but also add a lot or more. And when TP is triggered it would return one lot.
1. I categorically advise against using functions which select a position by a character. Use a function that selects a position by an index in a list.
2. To know how a position was closed, theENUM_DEAL_REASON enumeration must be viewed in OnTradeTransaction.
Example with ENUM_DEAL_REASON:
Stop Loss Take Profit
CodeBase | 2017.07.13 07:42 |Vladimir Karputov| EAs | MetaTrader 5
Is it possible to enter account login details into a third-party programme and manage the account and, you know, open/close positions?
Or is it only through a robot that is installed on the account?
I'm transferring indicators from MQL4 to MQL5, question about buffers and "plots". The indicator has 2 buffers and 1 plot:
#property indicator_buffers 2
#property indicator_plots 1
SetIndexBuffer(0,Array1,INDICATOR_CALCULATIONS);
SetIndexBuffer(1,Array2,INDICATOR_DATA);
If the first buffer is used for calculations, etc., and the second one should be plotted, then
first, is it necessary to set DRAW_NONE for the first buffer if it is already set to INDICATOR_CALCULATIONS in the SetIndexBuffer() function ?
PlotIndexSetInteger(?,PLOT_DRAW_TYPE,DRAW_NONE);
second, what index should I set in PlotIndexSetInteger() instead of question mark (?) if only second buffer should be drawn?
PlotIndexSetInteger(?,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);
Third, if I use two styles of DRAW_HISTOGRAM type, I may set colour for each of them and get histogram like in the Volumes indicator, where green and red bars alternate, but if I use DRAW_HISTOGRAM2, may I set two colours for one bar too or only one colour is set for this style?
I'm transferring indicators from MQL4 to MQL5, question about buffers and "plots". The indicator has 2 buffers and 1 plot:
#property indicator_buffers 2
#property indicator_plots 1
SetIndexBuffer(0,Array1,INDICATOR_CALCULATIONS);
SetIndexBuffer(1,Array2,INDICATOR_DATA);
If the first buffer is used for calculations, etc., and the second one should be plotted, then
first, is it necessary to set DRAW_NONE for the first buffer if it is already set to INDICATOR_CALCULATIONS in the SetIndexBuffer() function ?
PlotIndexSetInteger(?,PLOT_DRAW_TYPE,DRAW_NONE);
second, what index should I set in PlotIndexSetInteger() instead of question mark (?) if only second buffer should be drawn?
PlotIndexSetInteger(?,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);
Third, if I use two styles of DRAW_HISTOGRAM type, I may set colour for each of them and get histogram like in the Volumes indicator, where green and red bars alternate, but if I use DRAW_HISTOGRAM 2, may I set two colours for one bar too or only one colour is set for this style?
Why are you being so hard on yourself? What's the problem with setting the buffers you want to display first, and then the auxiliary buffers?
For DRAW_HISTOGRAМ2 3 buffers are defined and the sequence is mandatory, 2 value buffers first, followed by a colour buffer. But there is a difference between DRAW_HISTOGRAM and DRAW_HISTOGRAM2 in that DRAW_HISTOGRAM is drawn from zero to the value in the buffer, while DRAW_HISTOGRAM2 is drawn from the value of one buffer to the value of another buffer.