Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 537
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
Help me figure out why the indicator isn't rendering. I want to eventually create something like ZigZag.
Please put the code in correctly:
I already did it for you in your post.
Please insert the code correctly:
I have already done it for you in your post.
Good day!
Where can I get a robot for MT4 to set SL and TP after opening a position?
Good day!
Where can I get a robot for MT4 to set SL and TP after opening a position?
Can you tell me how to determine in the code whether this instrument has a swap at the end of the day?
Can you tell me how to determine in the code whether this instrument has a swap at the end of the day?
To look at swaps at the end of the day...
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_SHORT) - swap short positions
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_LONG) - swap of long positions
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_MODE) - model for calculating swap
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_ROLLOVER3DAY)- day of the week for calculation of triple swap
To look at the swaps at the end of the day...
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_SHORT) - swap short positions
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_LONG) - swap of long positions
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_MODE) - model for calculating swap
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_ROLLOVER3DAY)- day of the week for calculation of triple swap
By SYMBOL_SWAP_MODE reference For SymbolInfoInteger() function. In global variables, set int ssm = SymbolInfoInteger(Symbol(),SYMBOL_SWAP_MODE); In the code: Print("ssm = ",ssm); The result both on FC with no swap and on FC with swap = 0 (here is the question). I want to know: will there be swap or not, so that I can decide accordingly.
By SYMBOL_SWAP_MODE reference For SymbolInfoInteger() function. In global variables set int ssm = SymbolInfoInteger(Symbol(),SYMBOL_SWAP_MODE); In the code: Print("ssm = ",ssm); The result both on DC with no swap and on DC with swap = 0 (here is the question). I would like to know whether there will be a swap or not, so that I can make an appropriate decision.
Some variables from the market environment, similar to those in MT5, are not always correctly populated in MT4. Therefore, we have to use MarketInfo in MT4. And the type of calculation of swaps for MT4 is, in the overwhelming majority of cases, points. That is why we get 0. So, if you request information through MarketInfo (we have to use this old method more often in MT4), you will get the value corresponding to the reference:
MODE_SWAPTYPE
26
Method for calculation of swaps. 0 - in points; 1 - in instrument base currency; 2 - in percents; 3 - in collateral currency.
Some variables from the market environment, similar to those in MT5, are not always correctly populated in MT4. That is why we have to use MarketInfo in MT4 in the old fashioned way. And the type of calculation of swaps for MT4 is, in the overwhelming majority of cases, points. That is why we get 0. So, if we request information through MarketInfo (we have to use this old method more often in MT4), we will get just the value corresponding to the reference:
MODE_SWAPTYPE
26
Method for calculation of swaps. 0 - in points; 1 - in instrument base currency; 2 - in percentage; 3 - in collateral currency.
SWAP - as I understand it, is a dealing centre procedure which consists of the following: if there are open orders at the end of the day, they are closed and new orders are opened instead. Otherwise, the dealing desk does not close/open orders, but charges SWAP (+/-). I am trying to determine: will SWAP be charged, or will orders be closed/open? Applied:
double ssm_l = MarketInfo(Symbol(), MODE_SWAPLONG );
double ssm_s = MarketInfo(Symbol(), MODE_SWAPSHORT);
Print("ssm_s = ",ssm_s);
and it turned out that there are some numeric values in CA, where SWAP is charged, and in CA, where SWAP is not charged. So it's impossible to determine whether SWAP is charged or not.
SWAP - as I understand it, the dealing centre's procedure is as follows: if at the end of the day there are open orders, they are closed and new orders are opened instead. Otherwise, the dealing centre does not close/open orders, but charges SWAP (+/-). I am trying to determine: will SWAP be charged, or will orders be closed/open?
This method of swap calculation is called rollover. In MT4 there is no way to know about it programmatically. Only indirectly, after the midnight shift with working market orders has taken place. There are a lot of such small, but rather unpleasant problems in MT4. In MT5 there are a little less, but they still exist.
Applied:
double ssm_l = MarketInfo(Symbol(), MODE_SWAPLONG );
double ssm_s = MarketInfo(Symbol(), MODE_SWAPSHORT);
Print("ssm_s = ",ssm_s);
and it turned out that there are some numeric values in CA, where SWAP is charged, and in CA, where SWAP is not charged. So we can't decide if SWAP is charged or not at brokerage companies.
These are swap values in pips. You will need to convert them to the deposit currency proceeding from the market order volume. Then we will get the real swap size.