Calculating stop loss from known values
Hello you can use Tickvalue in the base currency but you did not specify any language.
If it's MQL4 then
int SL=100; double stoploss=Ask+SL*_Point;
Points = ( [3% Risk] / [Volume] ) * [$ Per Point]
Stop Loss = [Ask Price] + ( Points * 0.00001)
First let me say that I have a number of different ways to calculate SL, none of which include volume. That's something I've never come across before.
I usually figure SL first based upon something like ATR, FIXED, price percent, high/low of last N bars, etc.
Now that I have a SL, I determine the lotSize. It's only at that point that I consider a Risk % — and that's based upon equity.
So, if I have $10,000, then 3% of that is $300. But if my equity increases to $11,000, then 3% is now $330.
So, on a long-term trend following system, I might have a SL of something like 2xATR(20). Then I figure the lotSize based upon that, my equity, and my max risk percent.
Try this, You can calculate the StopLoss Based on Risk, the order type, lotsize and Open y using theis function
You can check this will give you the Sl;
Print(CalcSTOPLOSS(ORDER_TYPE_SELL,1.35632,1000,9.16));
This is the function:
double CalcSTOPLOSS(ENUM_ORDER_TYPE type, double PositionOpen, double risk, double lot){ double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE); double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE); double lotstep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); double sl = 0; if (ticksize == 0 || ticksize == 0 || lotstep == 0){ Print(__FUNCTION__, " > lotsize cannot be calculateddd..."); return 0; } Print("Value of each tick ", tickvalue, " Size of each tick ", ticksize); double numberofticksneeded = risk / tickvalue; double tickneededbasedonlots =(numberofticksneeded * ticksize) / lot; tickneededbasedonlots = NormalizeDouble(tickneededbasedonlots,_Digits); switch(type) { //--- Buy operation case ORDER_TYPE_BUY: { PositionOpen = NormalizeDouble(PositionOpen,_Digits); sl = NormalizeDouble((PositionOpen - tickneededbasedonlots), _Digits); return(sl); } //--- Sell operation case ORDER_TYPE_SELL: { PositionOpen = NormalizeDouble(PositionOpen,_Digits); sl = NormalizeDouble((PositionOpen + tickneededbasedonlots), _Digits); return(sl); } break; } return sl; }
Hi all,
Sorry for the probably terrible title, end of the day couldn't think of anything better.
I'm in the process of setting up a spreadsheet and need a calculation for the stop loss (in points). The information I have is the $ per point, Ask Price, Risk % (%3 of equity in this case), trade volume and spread. Example data below;
Based on this information, I need to get, in points, a stop loss value which is ~$299 in loss value higher/lower than the ask price.
I thought I could get this to work using the following;
However this only seems to work where the $ Per Point is > 1.
I didn't think this would be terribly difficult until I started attempting it, no matter what I try I cannot seem to come up with the correct numbers. It's probably something really simple but anyone with an idea please let me know.