[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 188
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
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: