Lots=(AccountBalance()*RiskPercentage/100)/(StopLoss*nTickValue);
Lots=MathRound(Lots/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP);
}
Lots=(AccountBalance()*RiskPercentage/100)/(StopLoss*nTickValue);
Lots=MathRound(Lots/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP);
}
Hi Alain,
Thank you for the message, how would you calculate it?
That is the usual formula for the lot size calculation
Position size = ((account value x risk per trade) / pips risked)/ pip value per standard lot
I just used different brakets
Position size = (account value x risk per trade) / (pips risked * pip value per standard lot)
- Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
- Do NOT use TickValue by itself - DeltaPerLot
- You must normalize lots
properly and check against min and max.
- You must also check FreeMargin to avoid stop out
- Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
- Do NOT use TickValue by itself - DeltaPerLot
- You must normalize lots
properly and check against min and max.
- You must also check FreeMargin to avoid stop out
Thanks whroeder1
- OSL is calculated considering the StopLoss value in pips so identical to (|OrderOpenPrice - OrderStopLoss|)
- Why not use TickValue? That is already considering the account currency and would make it easier to calculate
- Lots=MathRound(Lots/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP); that is the normalization. You're right I could check the min and max size and I would do that in a EA
- Yes free margin is a good idea, improvement for the next version :)
Thanks whroeder1
- Why not use TickValue? That is already considering the account currency and would make it easier to calculate
Is there a way to make this trade exactly how you have it all set up but instead of setting a pip value for the STOP you set a % movement your willing to let the currency move by?
so say my intention is to risk 1% of my account on the EURUSD moving a max of 0.5% against me.
Hope that makes sense :)
Hi nice script, im just learning and what i want to do seems simple (in my head) and your script is almost there...
Is there a way to make this trade exactly how you have it all set up but instead of setting a pip value for the STOP you set a % movement your willing to let the currency move by?
so say my intention is to risk 1% of my account on the EURUSD moving a max of 0.5% against me.
Hope that makes sense :)
It makes sense but it doesn't :)
Do I understand well if I say, the open price is 100%, assume 1.06158, stop a buy when the price is at 99.5% (1.05627) or stop a sell if the price is 100.5% (1.06688)?
If that's the case it should be quite easy for you to achieve with some simple maths
Hi, I don't know how to code. But can you teach me how to code it so that it base it's SL at x1.5 ATR and TP at x1 ATR?
Hi Marvz,
It is not easy to just teach that if you don't have coding basics, I would suggest to start from the basics first
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
OpenOrder (With Risk Management, TP and SL):
Author: MQL4AutoTrading