[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

 

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));
}

But the estimated swap and the real one are different. It's not that the bid price will never be the same again, it's not the ten thousandths.

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

 
vasya_vasya писал(а) >>

I multiply this value by Bid,

*MarketInfo(OrderSymbol(),MODE_BID)

What's that for?

 
Roger >> :

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))

 
Roger писал(а) >>

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.

 
vasya_vasya писал(а) >>

Nowhere have I found a description of what the value returns

For some reason it seemed to me that all calculations are in the currency of the deposit.
 
Roger писал(а) >>
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

 
vasya_vasya писал(а) >>

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.

 
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
 

To put it crudely:

double HighestBar(int start, int end)
{
double maxBar;
for (int i= start; i< end; i++)
if( maxBar<High[ i]) maxBar=High[ i];
return( maxBar);
}