-
mrequest.sl = latest_price.ask - 0.05; mrequest.tp = latest_price.ask + 0.10; mrequest.price = latest_price.ask;
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 (OANDA) shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
-
if(!is_bought) { if(short_ma_value[0] > short_ma_value[1] > short_ma_value[2]) { ⋮ if(OrderSend(mrequest, mresult)) ⋮ } } if(mresult.retcode == 10009 || mresult.retcode == 10008) //Request is
Why are you looking at mresult if you haven't opened an order?
1-What do you mean by "bid/OrderClosePrice"? I'm not sure I understood it right.
Does the " mrequest.tp" or " mrequest.sl", get triggered when the ask or bid price reaches it, or when the last deal price hit it?
Honestly I'm trading shares, the broker's spread is very low, rarely more than 4 times the minimun currency unit, but knowledge is always power.
This code is mostly from the tutorial that I followed.
Does the code below sends an order?
if(OrderSend(mrequest, mresult)
In other words, do functions inside the if statement get "fully" called?
Why do you use double for maxSpread? Is a float not enough? Why?
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I followed this tutorial
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners - MQL5 Articles
But I made things a little different and stupid just to test, but still, I can't send order, why? GetError function keeps returning error:4753 (position not found).
Eeverything seems to be ok with my code.