I would like to start by thanking you for this amazing library, it makes life very easy for novice users like myself. I am not a professional programmer, but just about manage to understand, tweak and debug some code a bit.
I am using your sample code from "Test_Hedge_Properties" as a function in an EA that I am testing, and found that after closing all (2) positions, when I call the function
"Update_Hedge_Info", after 1st ticket is closed, the variable that counts the number of positions, "hdg_number_of_pos_total" updates from (2) to (1).
However, after the second ticket closes, the variable still shows (1), it does not update to (0).
I am not sure if I have coded it right, but your kind input and expertise will be greatly appreciated.
Im using hedge_info.Margin() to calculate the current margin in my EA.
I wonder about the following (*) line inside CHedgePositionInfo::AveragePrice inside the "switch(curr_quote_type) ... case QUOTE_TYPE_CROSS:".
Im using EURCHF and major_symbol is USDEUR. As USDEUR is not supported by 99,9% of all forex brokers but at most a user defined cross, the following SymbolSelect command leads to an error message while backtesting. Maybe its a broker issue but in my case this leads to an abrupt abort of the strategy tester because the active symbol is now USDEUR and not the pair I initially started the strategy tester on (EURCHF).
if(SymbolSelect(major_symbol,true)) // (*)
So what helped in my case is removing the USDEUR from the market watch at the end of CHedgePositionInfo::AveragePrice by:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi Denis,
I would like to start by thanking you for this amazing library, it makes life very easy for novice users like myself. I am not a professional programmer, but just about manage to understand, tweak and debug some code a bit.
I am using your sample code from "Test_Hedge_Properties" as a function in an EA that I am testing, and found that after closing all (2) positions, when I call the function
"Update_Hedge_Info", after 1st ticket is closed, the variable that counts the number of positions, "hdg_number_of_pos_total" updates from (2) to (1).
However, after the second ticket closes, the variable still shows (1), it does not update to (0).
I am not sure if I have coded it right, but your kind input and expertise will be greatly appreciated.
I am attaching the EA and screenshot.
Thank you and regards.
Im using hedge_info.Margin() to calculate the current margin in my EA.
I wonder about the following (*) line inside CHedgePositionInfo::AveragePrice inside the "switch(curr_quote_type) ... case QUOTE_TYPE_CROSS:".
Im using EURCHF and major_symbol is USDEUR. As USDEUR is not supported by 99,9% of all forex brokers but at most a user defined cross, the following SymbolSelect command leads to an error message while backtesting. Maybe its a broker issue but in my case this leads to an abrupt abort of the strategy tester because the active symbol is now USDEUR and not the pair I initially started the strategy tester on (EURCHF).
So what helped in my case is removing the USDEUR from the market watch at the end of CHedgePositionInfo::AveragePrice by: