-
Of course, in FX. Other instruments, maybe.
-
request.tp=price-1; request.sl=price+1;
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 at 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)
-
-
Of course, in FX. Other instruments, maybe.
-
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 at 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)
-
Hi William,
Thanks for the response but as I was debugging my code it seems that the the parameters I entered didn't work. I had an error concerning the TP value being lower than the price, I think (4756). How would you place a SELL order TP/SL in MQL5?
Hi William,
Thanks for the response but as I was debugging my code it seems that the the parameters I entered didn't work. I had an error concerning the TP value being lower than the price, I think (4756). How would you place a SELL order TP/SL in MQL5?
Look at the documentation please.
I would suggest you to use CTrade from the standard library instead of using the raw trading functions.
Look at the documentation please.
I would suggest you to use CTrade from the standard library instead of using the raw trading functions.
DO you know which one is the alternate the action TRADE_ACTION_DEAL of type ORDER_TYPE_SELL.
I tried trade.Sell with those parameters:
trade.Sell(volume,_Symbol,price,NULL,price-0.5,NULL);
But it triggered instant sells (which isn't actually what I'm looking for.
Thanks for the help!
DO you know which one is the alternate the action TRADE_ACTION_DEAL of type ORDER_TYPE_SELL.
I tried trade.Sell with those parameters:
But it triggered instant sells (which isn't actually what I'm looking for.
Thanks for the help!
trade.Sell() is exactly using ORDER_TYPE_SELL which results in the TRADE_ACTION_DEAL.
How could I know what you are looking for ? If not instant sell, then what ?
trade.Sell() is exactly using ORDER_TYPE_SELL which results in the TRADE_ACTION_DEAL.
How could I know what you are looking for ? If not instant sell, then what ?
It trigger an instant sell and not an order in which the take profit is lower than the initaI order price. It doesn't trigger the inverse an ORDER_TYPE_BUY or maybe are my parameters wrong but I don't see the stop limit appear either the initial price.
Here's what I got when sending the order:
CTrade::OrderSend: instant sell 0.10 XAUUSD at 1976.67 tp: 1976.17 [requote (1976.59/1976.67)]
requote 1976.61 / 1976.69 / 1976.61 (instant sell 0.1 XAUUSD at 1976.69 tp: 1976.19)
requote 1976.61 / 1976.69 (instant sell 0.1 XAUUSD at 1976.69 tp: 1976.19)
It trigger an instant sell and not an order in which the take profit is lower than the initaI order price. It doesn't trigger the inverse an ORDER_TYPE_BUY or maybe are my parameters wrong but I don't see the stop limit appear either the initial price.
Here's what I got when sending the order:
CTrade::OrderSend: instant sell 0.10 XAUUSD at 1976.67 tp: 1976.17 [requote (1976.59/1976.67)]
requote 1976.61 / 1976.69 / 1976.61 (instant sell 0.1 XAUUSD at 1976.69 tp: 1976.19)
requote 1976.61 / 1976.69 (instant sell 0.1 XAUUSD at 1976.69 tp: 1976.19)
Inverse an ORDER_TYPE_BUY ? That doesn't make sense. You can't inverse an order. At best you can inverse a position if you are using a netting account, on an hedging account you will just open a new position.
If you want a SL/TP then either add them while opening a position, or modify an existing position to add/change them. You also have the option to close a position, it will send the needed order according to the position selected.
In all cases a SL/TP is not a STOP LIMIT order.
Please inform you how it works : https://www.mql5.com/en/articles/211
- www.mql5.com
Inverse an ORDER_TYPE_BUY ? That doesn't make sense. You can't inverse an order. At best you can inverse a position if you are using a netting account, on an hedging account you will just open a new position.
If you want a SL/TP then either add them while opening a position, or modify an existing position to add/change them. You also have the option to close a position, it will send the needed order according to the position selected.
In all cases a SL/TP is not a STOP LIMIT order.
Please inform you how it works : https://www.mql5.com/en/articles/211
Those parameters works perfectly for going long (it could be replace as suggest with a cTrade class, but I didn't found the function to call from it). What function could I use for creating the exact same strategy but for going short.
MqlTradeRequest request={}; request.action=TRADE_ACTION_DEAL; // immediate order execution request.symbol=_Symbol; // symbol request.volume=volume; // volume in 0.1 lots request.tp=takeProfit; // Take Profit is not specified request.price=price; // prICE request.type=ORDER_TYPE_BUY; // order type MqlTradeResult result={}; OrderSend(request,result)
Inverse an ORDER_TYPE_BUY ? That doesn't make sense. You can't inverse an order. At best you can inverse a position if you are using a netting account, on an hedging account you will just open a new position.
If you want a SL/TP then either add them while opening a position, or modify an existing position to add/change them. You also have the option to close a position, it will send the needed order according to the position selected.
In all cases a SL/TP is not a STOP LIMIT order.
Please inform you how it works : https://www.mql5.com/en/articles/211
its working fine with the broker but it doesn't work when testing in mt5 only
Inconsiderate language removed by moderator. Please address people properly.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is it possible to trade the short way in mql5. I want to make profit while the chart is going down.
Thanks.