i am trying to make an EA for auto risk calculation but still not successful.
i am trying to calculate risk from Stoploss value in pip.
Example my stoploss is 10pip & i want to take the risk of 5% of my total Account balance. it should calculate from these two parameters...
Here is my code i tried but not worked for me.
it would be really grateful if anyone have the code for the EA & help me out for the correct formula.Thanks
double tickSize = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_SIZE); double tickValue = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE); double valueToRisk = risk / 100 * capital; double tickCount = sldistance / tickSize; double lots = valueToRisk / (tickCount * tickValue);
double tickSize = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_SIZE); double tickValue = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE); double valueToRisk = risk / 100 * capital; double tickCount = sldistance / tickSize;
i want to calculate risk from stoploss pips & risk perecentage value.
i want to calculate risk from stoploss pips & risk perecentage value.
- votes: 20
- 2015.12.01
- Vasyl Nosal
- www.mql5.com
i want to calculate risk from stoploss pips & risk perecentage value.
I know, it's exactly the code I gave you.
I was supposing you can adapt the code yourself, not ?
i want to calculate risk from stoploss pips & risk perecentage value.
based on the code of Alain:
double tickSize = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_SIZE); double tickValue = SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE); double valueToRisk = risk / 100 * capital; double tickCount = sldistance / tickSize; double lots = valueToRisk / (tickCount * tickValue); //-- double tickValueSize = tickValue * _Point / tickSize; double spread = (double)SymbolInfoInteger(_Symbol,SYMBOL_SPREAD); double stoploss = valueToRisk / (lots * tickValueSize) - spread;
try this..
https://www.mql5.com/en/code/13593
I know, it's exactly the code I gave you.
I was supposing you can adapt the code yourself, not ?
yes i solved the issue i had. the only issue was to get the Exact PIP Value (1 PIP= How much $).
Thanks your code was helpful :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i am trying to make an EA for auto risk calculation but still not successful.
i am trying to calculate risk from Stoploss value in pip.
Example my stoploss is 10pip & i want to take the risk of 5% of my total Account balance. it should calculate from these two parameters...
Here is my code i tried but not worked for me.
it would be really grateful if anyone have the code for the EA & help me out for the correct formula.Thanks