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
It is not correct to use the == condition for variables of type double. It is recommended to compare like this:
It is not correct to use the == condition for variables of type double. It is recommended to compare like this:
Quite reasonable, and most importantly a sensible approach. But it seems to me that at least the first line should have looked like this:
I get these messages in the log from time to time
2010.06.15 14:48:09 MemoryException 4915200 bytes not available
I don't know what to do ?
I get these messages in the log from time to time
2010.06.15 14:48:09 MemoryException 4915200 bytes not available
I don't know what to do ?
It is not correct to use the == condition for variables of type double. It is recommended to compare like this:
Not enough op. memory. Check the size of the dynamic arrays, most likely an attempt to allocate more memory than is available.
That's not the point of the question. If I understood it correctly, the operator return must always be placed at the end of the user function
I think the answer about == was essentially. There really should be a return(...) somewhere in a function of type double. Not necessarily at the end. Using == operator in if() return(); may cause false output if you have the LotStep type 0.1000000000000000001. In this case none of the returns will work and the function returns nothing. Although in your case the return probably does not like NormalizeDouble inside. In your version that works, fix the end to return(NormilizeDouble(lot,2)) and see if it works. I'm curious about it myself.
I think the answer about == was essentially. There really should be a return(...) somewhere in a function of type double. Not necessarily at the end. Using == operator in if() return(); may cause false output if you have the LotStep type 0.1000000000000000001. In this case none of the returns will work and the function returns nothing. Although in your case the return probably does not like NormalizeDouble inside. In your version that works, fix the end to return(NormilizeDouble(lot,2)) and see if it works. I'm curious about it myself.
There must be return(...) at the end, but it may not come to it (if one of the If conditions works)...
: Renat
The mistake is that you forgot about the margin currency in your calculations. Balance = 100 USD and margin requirement = 100 EUR (119 USD).
That's why the operation cannot be performed - everything is correct.
I want to get back to my question about correct margin calculation. As Renat noticed in my calculations, LotRqdMgn (margin required to buy 1 lot) does not take into account the price of the currency. I remember having seen this table
Identifier
Description
Formula
SYMBOL_CALC_MODE_FOREX
Forex mode - calculation of profit and margin for Forex
Margin: Lots*Contract_Size/Leverage
Profit: (close_price-open_price)*Contract_Size*Lots
SYMBOL_CALC_MODE_FUTURES
Futuresmode - calculation of margin and profit for futures
Margin: Lots *InitialMargin*Percentage/100
Profit: (close_price-open_price)*TickPrice/TickSize*Lots
SYMBOL_CALC_MODE_CFD
CFD mode - calculation of margin and profit for CFD
Margin: Lots *ContractSize*MarketPrice*Percentage/100
Profit: (close_price-open_price)*Contract_Size*Lots
SYMBOL_CALC_MODE_CFDINDEX
CFD index mode - calculation of margin and profit for CFD by indexes
Margin: (Lots*ContractSize*MarketPrice)*TickPrice/TickSize
Profit: (close_price-open_price)*Contract_Size*Lots
SYMBOL_CALC_MODE_CFDLEVERAGE
CFD Leverage mode - calculation of margin and profit for CFD at leverage trading
Margin: (Lots*ContractSize*MarketPrice*Percentage)/Leverage
Profit: (close_price-open_price)*Contract_Size*Lots
So it turns out that there is an error in the table: instead of Lots*Contract_Size/Leverage, it must be Price*Lots*Contract_Size/Leverage.