Marbo: I tried something like this but I don't really understand what I am doing here...
In code (MT4):
Risk depends on your initial stop loss, lot size, and the value of the
pair.
You place the stop where it needs to be - where the reason for the trade
is no longer valid. E.g. trading a support bounce the stop goes below the
support.
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.)
My broker charges a fixed $7 per roundturn. They don't have other commissions for EUR accounts. I only see the commission in Euro on my account but it's just always the $7 commission converted into Euro. Therefore I am sure to pay $7 for every roundturn in all currency pairs.
I tested it on different forex-symbols and unfortunately the result was always way too high for my predefined risk.
Edit: You wrote slInPoints. Do you mean this as an example?
In my first posting you can see that I use the DeltaPerLot which I saw in one of your codes years ago. So my problem is not to calculate the lotsize in general. My problem is to include the commission which is $7 per roundturn into the calculation. I have an entry and a stoploss. This I use to calculate the lotsize. And that works perfect. It's just about the commission. I don't know how to include it into the calculation. If I could convert it into pips/points, I could just add it to the MathAbs(OrderOpenPrice-OrderStopLoss). But exactly this is my problem.
By SLInPoints I mean SL in points, not SL as price difference. I’m sure you know what is “point”. In your example it will be 300 points (I assume this is 5 digit symbol).
By SLInPoints I mean SL in points, not SL as price difference. I’m sure you know what is “point”. In your example it will be 300 points (I assume this is 5 digit symbol).
Oh, sorry! I wasn’t sure about ‘points’. But now I know where the error could be. I just have to find out how to convert 0.0030 to 300 and to make sure that it works on 3 digit yen pairs too.
According to @whroeder1 I will include the DeltaPerLot function just to verify that I use the correct ticksize.
In my first posting you can see that I use the DeltaPerLot which I saw in one of your codes years ago. So my problem is not to calculate the lotsize in general. My problem is to include the commission which is $7 per roundturn into the calculation.
What part of "Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice -
OrderStopLoss| * DeltaPerLot +
CommissionPerLot)" was unclear?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Because I have a EUR account I changed it to:
But unfortunately that doesn't work correct. The calculated lotsize is too high for the 1% risk.
- You place the stop where it needs to be - where the reason for the trade
is no longer valid. E.g. trading a support bounce the stop goes below the
support.
-
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 and verify that
MODE_TICKVALUE is returning a value in your deposit currency, as promised
by the documentation, or whether it is returning a value in the instrument's
base currency.
-
You must normalize lots properly
and check against min
and max.
-
You must also check FreeMargin to avoid stop out
Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
@Marcin Madrzak
My broker charges a fixed $7 per roundturn. They don't have other commissions for EUR accounts. I only see the commission in Euro on my account but it's just always the $7 commission converted into Euro. Therefore I am sure to pay $7 for every roundturn in all currency pairs.
I tested it on different forex-symbols and unfortunately the result was always way too high for my predefined risk.
Edit: You wrote slInPoints. Do you mean this as an example?
@whroeder1
In my first posting you can see that I use the DeltaPerLot which I saw in one of your codes years ago. So my problem is not to calculate the lotsize in general. My problem is to include the commission which is $7 per roundturn into the calculation. I have an entry and a stoploss. This I use to calculate the lotsize. And that works perfect. It's just about the commission. I don't know how to include it into the calculation. If I could convert it into pips/points, I could just add it to the MathAbs(OrderOpenPrice-OrderStopLoss). But exactly this is my problem.
@Marcin Madrzak
If you run this script, you can see that the lotsize is way too high.
- account balance = 1000
- risk = 1%
- stoploss = 30 pips
The lotsize-result is 1.61.
@Marbo
Oh, sorry! I wasn’t sure about ‘points’. But now I know where the error could be. I just have to find out how to convert 0.0030 to 300 and to make sure that it works on 3 digit yen pairs too.
According to @whroeder1 I will include the DeltaPerLot function just to verify that I use the correct ticksize.
@whroeder1
In my first posting you can see that I use the DeltaPerLot which I saw in one of your codes years ago. So my problem is not to calculate the lotsize in general. My problem is to include the commission which is $7 per roundturn into the calculation.
What part of "Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot)" was unclear?
What part of "Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot)" was unclear?
Stupid me... I have overlooked it... Sorry!
This calculation works perfect now. Thank you!
What part of "Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot)" was unclear?
Can i hire you to resolve a similar issue ? i want to add commission into my EA.