Please edit your post - use the CODE button (Alt-S)!
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
tp1 = openPositionPrice + stopLoss; tp2 = openPositionPrice + stopLoss*2; tp3 = openPositionPrice + stopLoss*3; tp1 = openPositionPrice - stopLoss; tp2 = openPositionPrice - stopLoss*2; tp3 = openPositionPrice - stopLoss*3;
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
-
trade.PositionClosePartial(ticket,volume/3.0,2);
You can't just use OrderLots()/3 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot.
- 4Show Investments: It takes too much partial profit numerous amounts of times.
Of course it does. You compute your TP based on the SL. Which is why the first works. When you close the first, you move the SL to BE. The next tick your computed TP2 is wrong. Remember the original values, do not recompute them.

- 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 have this script that is supposed to be used for risk management on my trading account. However, I have an issue taking profit. The script calculates the tp levels of 1:1,1:2, and 1:3 once a stop loss has been inputed by the user. My first tp level works flawlessy and using the same structure my tp2 should work the same way. It takes too much partial profit numerous amounts of times. During testing even when changing the lot size it doesn't calculate the right volume of trade to close anymore. Has anyone else been having this issue?\
Here is my code: