Profiles please advise, according to the help of mql5 language there is no function iHighest how to calculate the maximum high for N period? ... I have tried copyHigh and fmax, but only for a certain period and not that of course, help
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.
Trying to calculate swaps, but it's not working
Here is the code that outputs the swaps of the last 20 trades.
for ( int j=OrdersHistoryTotal( )-1; j>=OrdersHistoryTotal( )-21; j--) {
OrderSelect(j, SELECT_BY_POS, MODE_HISTORY);
if(OrderType()==OP_BUY)
Alert(OrderSymbol()+" ЛОТ = "+OrderLots()+" РЕАЛЬНЫЙ СВОП = "+OrderSwap()+" РАСЧЕТНЫЙ СВОП "+MarketInfo(OrderSymbol(),MODE_SWAPLONG)*MarketInfo(OrderSymbol(),MODE_BID)*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE));
if(OrderType()==OP_SELL)
Alert(OrderSymbol()+" ЛОТ = "+OrderLots()+" РЕАЛЬНЫЙ СВОП = "+OrderSwap()+" РАСЧЕТНЫЙ СВОП "+MarketInfo(OrderSymbol(),MODE_SWAPSHORT)*MarketInfo(OrderSymbol(),MODE_BID)*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE));
}
For some reason the difference is a multiple of 10.
That is, the calculated swap is 10 times higher than the real one.
I cannot even guess what is wrong here.
MarketInfo(OrderSymbol(),MODE_SWAPTYPE) returns one, then
"Method for calculating swaps 1 - in the instrument's base currency;"
I take the swap value in pips, which returns
MarketInfo(OrderSymbol(),MODE_SWAPLONG)
I multiply this value by Bid,
*MarketInfo(OrderSymbol(),MODE_BID)
then to the size of lot
*OrderLots()
and multiplying by the value of one point in the deposit currency from one lot
*MarketInfo(OrderSymbol(),MODE_TICKVALUE)
The values returned are:
EURGBP LOT = 0.46000000 REAL SWAP = -1.31000000 ESTIMATED SWAP -13.05244609
Please tell me how to do this))
double MA1,MA2;
MA1=iMA(....,0);
MA2=iMA(....,3);
if (MA1-MA2>Point)//MA looks up
if (MA1-MA2,-Point)//MA looks down
I multiply this value by Bid,
*MarketInfo(OrderSymbol(),MODE_BID)
What's that for?
Please tell me how to do this))
double MA1,MA2;
MA1=iMA(....,0);
MA2=iMA(....,3);
if (MA1-MA2>Point)//MA looks up
if (MA1-MA2,-Point)//MA is looking down
Thank you very much))
What is this for?
I couldn't find a description of what it returns
MarketInfo(OrderSymbol(),MODE_SWAPLONG)
I made a conclusion that this is EUR point size in EURGBP quotation , so I multiplied it by BID to get how much it is in GBP
The point is that
MarketInfo(OrderSymbol(),MODE_TICKVALUE)
Returns point value per lot just for GBP in EURGBP quote, not for EUR.
Nowhere have I found a description of what the value returns
For some reason I kept thinking that all calculations were in the currency of the deposit.
Function MarketInfo(OrderSymbol(),MODE_SWAPSHORT)
Returns an integer value of -2, the same as for all other orders. Hence I assume that this is the value of points.
Let's assume this is the value of swap expressed in pips of our deposit currency.
Deposit currency = USD
Multiply
MarketInfo(OrderSymbol(),MODE_SWAPSHORT)
By number of lots
*OrderLots()
Also multiply by the value of one pip of our deposit currency per lot
*10
Get
SWAP = -9.20000000
Instead of
REAL SWAP = -1.31000000
Function MarketInfo(OrderSymbol(),MODE_SWAPSHORT)
Returns an integer value of -2, the same as for all other orders. Hence, I assume this is the value of pips.
For EURGBP it returns 0 (this is Alpari) for shorts and -0.68 for long and this is exactly in dollars.
To put it crudely: