[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 599

 
alsu:
write down what you get and what messages you print in the log



I have shown where it should go in, but it did not go in, what fractals should punch. i also attach in the archive code and output in the test txt-file (i changed it, added mine, but the problem still remains). i just honestly do not even know what variables to monitor (and there's a picture of the location

)

Files:
ik.zip  4 kb
 

I took the function GetLot (in the file) from another EA. In my old EA there is no error in itself, but in my EA it generates

'(' - function definition unexpected C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (106, 15)
'Free' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (112, 28)
'Risk' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (112, 33)
'Free' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (115, 17)

What's the problem?

Files:
 
Why do you all love archivers so much? Do you have 100500 lines of code in your source code?!
 

griha:

I took the function GetLot (in the file) from another EA. In my old EA there is no error in itself, but in my EA it generates

'(' - function definition unexpected C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (106, 15)
'Free' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (112, 28)
'Risk' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (112, 33)
'Free' - variable not defined C:\Program Files\BCS Trade Station\experts\ SovetnikStochastic.mq4 (115, 17)

What's the problem?

There is an extra curly bracket in the code of the start function before the first If that's why there are errors. To make it easier to read the brackets, you should always try to put them both first, and then write everything you need in them. Better yet, you should put them on a new line with an offset, so that separate blocks are not mixed up (for example, as in the code given on the previous page)

P.S.:

I think lot calculation by this formula

 double Lot     =MathFloor(Free*Risk/100/One_Lot/Step)*Step;    // откидываем лишние знаки после запятой, оставляем 2 знака
will not work correctly for 0.1 lot with a step more than 0.01, maybe I missed something, but then the lot will always equal 0 ( MathFloor (900*2/100/1324/0.02=0.67975831) = 0, so 0*Step=0)...
 

I can't figure out how to calculate something like OrderProfitPips( ) for a selected order if the pair is arbitrary. I.e. profit in pips, not in account currency.

I need exactly pips - to analyze effectiveness of multicurrency trading at different pairs. I need four-digit pips (or appropriately two-digit, if the pair is in yen). Consider that the account currency is USD, and the contract size is 100 000 units.

If the pair is EURUSD, everything is simple:

pips = OrderProfit( ) / ( OrderLots( ) * 10. );


If the pair is AUDCHF, it is a bit more complicated. If the account were a franc account, the formula would be exactly the same. But the account is a franc account, i.e. OrderProfit() returns in dollars. So my profit should be converted into francs:

pips = USDCHF * OrderProfit( ) / ( OrderLots( ) * 10. );

Right?

 
Mathemat:

I cannot figure out how to calculate something like OrderProfitPips( ) for the selected order if the pair is arbitrary. I.e. profit in pips, not in account currency.

I need exactly pips - to analyze effectiveness of multicurrency trading at different pairs. I need four-digit pips (or appropriately two-digit, if the pair is in yen). Consider that the account currency is USD, and the contract size is 100 000 units.

If the currency pair is EURUSD, everything is simple:

pips = OrderProfit( ) / ( OrderLots( ) * 10. );


If the pair is AUDCHF, it is a little more complicated. If the account was a franc account, the formula would be exactly the same. But the account is a dollar account, i.e. OrderProfit() returns in dollars. So my profit should be converted into francs:

pips = USDCHF * OrderProfit( ) / ( OrderLots( ) * 10. );

Right?


Did you read http://www.fxtrademaker.com/fx_calculation.htm? Or is it http://thismatter.com/money/forex/leverage-margin-pips.htm?

As far as I understood, PipProfit = USDprofit/lot/Point for EURUSD. For reverse-quoted pairs we need to take the difference between opening and current price and multiply by Digits: Pips = OrderOpenPrice()-Bid*Digits_coefficient; where
Digits_coefficient = MathPow(10,Digits);


 

Yes there seems to be a use for both links. Thank you.

P.S. I decided to count not in pips but in account currency. The pips of Yen crosses are too disproportionate to the usual ones. And I wanted to add them up (conventionally, of course)...

 
Mathemat:

Yes there seems to be a use for both links. Thank you.

P.S. I decided to count not in pips, but in account currency. Too incommensurable are the pips figures of yen crosses with the usual ones. And I wanted to add them up (conditionally, of course)...


Pips are pips, how can they be disproportionate? How is a 20 pip profit on EURUSD different from a 20 pip profit on JPY? You must be counting wrong... But it really is easier to calculate in the currency of the account.

 
evillive: Pips is pips, how can they be incommensurable?

Well, on your link (second) everything is visible:

You buy 100,000 units of EUR/JPY = 164.09 and sell when EUR/JPY = 164.10, and USD/JPY = 121.35.

Profit in JPY pips = 164.10 - 164.09 = .01 yen = 1 pip (Remember the yen exception: 1 JPY pip = .01 yen.)

Total Profit in JPY pips = 1 x 100,000 = 100,000 pips.
Total Profit in Yen = 100,000 pips/100= 1,000 Yen.

Because you only have the quote for USD/JPY = 121.35, to get profit in USD, you divide by the quote currency's conversion rate:

Total Profit in USD = 1,000/121.35 = 8.24 USD.

If you only have this quote, JPY/USD = 0.00824, which is equivalent to the above value, you use the following formula to convert pips in yen to domestic currency:

Total Profit in USD = 1,000 x 0.00824 = 8.24 USD.

A profit of 8.24 USD (equal to 0.824 pips on 1 EURUSD lot, for example) is equivalent to 100 thousand yen pips in this example!

P.S. I feel like a complete novice...

 
Mathemat:

Well, your link (the second one) shows it all:

A profit of 8.24 USD (equal to 0.824 pips on 1 EURUSD lot) is equivalent to one hundred thousand yen pips!


You're reading it wrong. For pairs with a reverse quote, take the difference between opening and current price and multiply by the multiplier obtained from Digits ( Pips = (Bid -OrderOpenPrice())*Digits_coefficient; ) , which gives (80.60-80.45=0.15) * MathPow(10,Digits) = 15 pips, where

Digits_coefficient  = MathPow(10,Digits);

Couldn't be simpler, could it?

P.S.: Although no, it could be simpler ))))

 Pips = (Bid - OrderOpenPrice())/Point; //ордер лонг
 Pips = (OrderOpenPrice() - Ask)/Point; //ордер шорт

And this expression is true for ALL currency pairs!

Reason: