- When you post code please use the CODE button (Alt-S)!
(For large amounts of code, attach it.) Please edit your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Can't be done because 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. Only then can you calculate lot size.
- In MT4 code:
- 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.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers. - You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
- Use a GUI EA like mine (for MT4): Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6
- In MT4 code:
- When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Can't be done because 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. Only then can you calculate lot size.
- In MT4 code:
- 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.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers. - You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
- Use a GUI EA like mine (for MT4): Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6
- In MT4 code:
Thanks for your comment. Sorry for the code format, I edited it.
So you say that I cannot calculate lot based on the euro amount? Because when I used for example Plus500, I needed to type the amount in euro to trade, for example 100€, and not Lot! And then I set the stoploss to 10€ and takeprofit to 5€.
And it is not really clear that what is the stoploss and takeprofit in the OrderSend() method. I know it is called Level, but what is it actually, what do I need to set there? I guess not 5€ and 10€, I think I need to calculate them somehow if I want the result to be 5€ for takeprofit and 10€ for stoploss.
I can't believe that it is so hard to calculate the lot and the other two based on the result I want in euro.
What you say makes no sense.
- How can the risk for a 1 lot trade with a 10 pip SL be the same as a 1 lot trade with a 1000 pip SL? They can't! Risk depends on the stop size and lots.
- What does it mean to set a SL to 10? SL is a price level not an amount.
- If you place your SL and then set lot size so your risk is 10, then your trade risk is 10 not 100.
- It's not hard. Risk depends on stop size and lot size. You must fix two to calculate the third.
- 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 a little bit new in this language, but I have the basics.
I want to trade EUR/USD, and my account is in EUR. I have 1000 EUR in my account.
What I want: open a position with stop loss and take profit.
I want to place an order with 100 euro, and I want to set the stop loss to 10 euros, and set the take profit to 5 euros. But as I see the OrderSend method requires lots for placing the order, and levels for stop loss and take profit.
And my problem is: how to calculate these values based on the euro amounts I want to set?
I searched for some lot-pip-etc calculation on the web, but after all what I tried did not work. This is how I wanted to calculate:
And are the stoploss and takeprofit levels also lots? Or are they different units?