ruth26: Ive been using buy/sell scripts in my trading where you can set up the % of account balance you are willing to risk and how many pips will this % represent.
- You ask about code that you don't show. No mind readers here.
- You buy at the Ask and sell at the bid. For a sell the SL/TP is relative to the Ask.
-
- 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)
- 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
- See also my GUI at Indicators: Money Manager Graphic Tool - MQL5.community traders' Forum - Page 5
'Money Manager Graphic Tool' indicator by 'takycard'
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, fellow coders!
Recently Ive been using buy/sell scripts in my trading where you can set up the % of account balance you are willing to risk and how many pips will this % represent.
Code for this script where you input the variables -
Using this script pops up a window where you set the two forementioned variables ( % of account balance you are willing to risk (RiskPercent) and how much will it represent in pips (StopLoss) ).
Then there are these two scripts for buy and sell and their respective codes - for BUY script
and for SELL script -
So ideally, with this setup either of the two scripts should open a position where the stop loss is 10 pips and those 10 pips represent 5% of you account balance and likewise the take profit is 10 pips and those 10 pips represent 5% of your account balance as well... ideally..
But the problem is, eventhough most of the time both take profit and stop loss are indeed 10 pips, the lot size opened according to this stop loss/take profit isnt 5% of account balance as it should be.
For example: I had 3233,37€ in my trading account and opened a position with settings: risk 5% of balance/ 10pip stop loss/ 10pip take profit, to my knowledge the lot size of the upcoming position should have been 2.02 lot but instead it opened a position with the lot size of 1.39 lot which meant each side of the trade was worth about 127.67€ ( about 3.94% of account balance ) instead of 161.60€ ( representing the set 5% risk of account balance ).
This leaves me puzzled as to why did it open such lot size and I think the answer lies within the code but I cannot find out myself. According to my logic, it should work, in theory.
I would appreciate greatly if anyone was so kind and could point me in the right direction.
All kind of help is highly appreciated!
Best regards,
ruth