On a five digit broker (5 digits/3 on JPY), a PIP is 10 points. On a four digit broker, a PIP equals a point.
This is MT4, why not use the Predefined Variables Digits?double PipPoint=0; double Digit=MarketInfo(Symbol(),MODE_DIGITS); if(Digit==1||Digit==2||Digit==3){PipPoint=Point*10;} if(Digit==1||Digit==2){PipPoint=Point*100;} if(Digit==4||Digit==5){PipPoint=Point*10;} return(PipPoint);
Simplified return Digits % 2 = 0 ? Point : 10* Point;
-
double TPBuy=Ask+TakeProfit*Pips(); double TPSell=Bid-TakeProfit*Pips(); double SLBuy=Ask-StopLoss*Pips(); double SLSell=Bid+StopLoss*Pips();
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)
-
-
double FinalPrice=1.0/(Price1*Price2); if(FinalPrice)
False is zero, non-zero is true. Always true.
-
int Buy=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"Scalper8",MagicNumber,Expire,clrBlue); bool SelectBuy=OrderSelect(Buy,SELECT_BY_POS,MODE_TRADES);
A ticket is not a position index.
-
int Buy=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"Scalper8",MagicNumber,Expire,clrBlue); bool SelectBuy=OrderSelect(Buy,SELECT_BY_POS,MODE_TRADES); if(Buy>0) { bool BuyMod=OrderModify(Buy,OrderOpenPrice(),SLBuy,TPBuy,0,clrNONE);
There is no need to open an order and then set the stops. Simplify your code - do it in one step. TP/SL on OrderSend has been fine for years.
Build 500 № 9 (2013)
Is OrderSend() function now able to send ECN trades (with SL and TP) by itself? - MQL4 programming forum (2013)
OP_BUY the same on Instant Execution and Market Execution? - MQL4 programming forum #2 (2014)
Need help me mql4 guru add take profit to this EA - MQL4 programming forum #8 (2017) - Scalper8: Below is my code, sell order won't open (if statement) is the same as buy.
if(CountSymbol(Symbol())<1) { int Buy=OrderSend(… } if(CountSymbol(Symbol())<1) { int Sell=OrderSend(…
If the count is zero, you open a buy. The count is now one and you won't ever open a sell. Why does this confuse you?
On a five digit broker (5 digits/3 on JPY), a PIP is 10 points. On a four digit broker, a PIP equals a point.
This is MT4, why not use the Predefined Variables Digits?Simplified -
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)
-
-
False is zero, non-zero is true. Always true.
-
A ticket is not a position index.
-
There is no need to open an order and then set the stops. Simplify your code - do it in one step. TP/SL on OrderSend has been fine for years.
Build 500 № 9 (2013)
Is OrderSend() function now able to send ECN trades (with SL and TP) by itself? - MQL4 programming forum (2013)
OP_BUY the same on Instant Execution and Market Execution? - MQL4 programming forum #2 (2014)
Need help me mql4 guru add take profit to this EA - MQL4 programming forum #8 (2017) -
If the count is zero, you open a buy. The count is now one and you won't ever open a sell. Why does this confuse you?
double FinalPrice=1.0/(Price1*Price2); if(FinalPrice)
I'm confused, is it incorrect? Should I change it?
int Buy=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"Scalper8",MagicNumber,Expire,clrBlue); bool SelectBuy=OrderSelect(Buy,SELECT_BY_POS,MODE_TRADES); if(Buy>0) { bool BuyMod=OrderModify(Buy,OrderOpenPrice(),SLBuy,TPBuy,0,clrNONE);
I'm using the following to avoid send error 130
On a five digit broker (5 digits/3 on JPY), a PIP is 10 points. On a four digit broker, a PIP equals a point.
This is MT4, why not use the Predefined Variables Digits?Simplified -
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)
-
-
False is zero, non-zero is true. Always true.
-
A ticket is not a position index.
-
There is no need to open an order and then set the stops. Simplify your code - do it in one step. TP/SL on OrderSend has been fine for years.
Build 500 № 9 (2013)
Is OrderSend() function now able to send ECN trades (with SL and TP) by itself? - MQL4 programming forum (2013)
OP_BUY the same on Instant Execution and Market Execution? - MQL4 programming forum #2 (2014)
Need help me mql4 guru add take profit to this EA - MQL4 programming forum #8 (2017) -
If the count is zero, you open a buy. The count is now one and you won't ever open a sell. Why does this confuse you?
if(CountSymbol(Symbol())<1) { int Buy=OrderSend(… } if(CountSymbol(Symbol())<1) { int Sell=OrderSend(…
Thank you for the heads up minor mistakes..
if(FinalPrice) { if(CountSymbol(Symbol())<1) { int Buy=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"Scalper8",MagicNumber,Expire,clrBlue); bool SelectBuy=OrderSelect(Buy,SELECT_BY_POS,MODE_TRADES); if(Buy>0) { bool BuyMod=OrderModify(Buy,OrderOpenPrice(),SLBuy,TPBuy,0,clrNONE); } } if(FinalPrice) { if(CountSymbol(Symbol())<2) { int Sell=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,0,0,"Scalper8",MagicNumber,Expire,clrRed); bool SelectSell=OrderSelect(Sell,SELECT_BY_POS,MODE_TRADES); if(Sell>0) { bool SellMod=OrderModify(Sell,OrderOpenPrice(),SLSell,TPSell,0,clrNONE); } } } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Below is my code, sell order won't open (if statement) is the same as buy. I would like to arbitrage buy & sell. Are my Price1 & Price2 functions correct for arbitrage?
Your help will be appreciated!