trade.Buy(LotesUS30, Symbol(), 0, Ask - SL * MyPoint, Ask + TP * MyPoint, NULL); // Buy US30
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at 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, but average maximum spread = 134 (your broker will be similar).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, good afternoon, I hope everybody is fine
I show you the following code that I have been doing at my own pace, because i am new to this and i am learning.
Its objective is that: When I make a buy/sell by market, Stop Loss and Take Profit are already place by default
With the idea that it can save me the time of placing Stop Loss and Take Profit manually or by dragging/trailing on the charts
This is because the three assets that I trade are very volatile (US30, NAS100 and SPX500) in the time frame of M1, and those few seconds where the SL and TP is set, make the difference. The convenience of automatically placing SL and TP when executing the order by market, would be incredible. For this reason I need your valuable experience to help me get this up and running.
Graphically what you want is attached and the conditions are as follows:
1. When Buying/Selling by market manually US30, automatically place -12,5 pips of SL and +37,5 pips of TP (Regarding the price where y Bought/Sold)
2. When Buying/Selling by market manually NAS100, automatically place -8 pips of SL and +24 pips of TP (Regarding the price where y Bought/Sold)
3. When Buying/Selling by market manually SPX500, automatically place -1,5 pips of SL and +4,5 pips of TP (Regarding the price where y Bought/Sold)Thanks for your time!!