-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
if (OrderSend(NULL,1,1,Ask,10,0.0006 + Ask,Ask - 0.0020,NULL,0,0))
OrderSend does not return a boolean.
-
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).
-
-
static datetime disabled=0; datetime now=TimeCurrent(); if(now < disabled) return; if(OrderSend(…)>0){ disabled=now + 2*3600; …
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
OrderSend does not return a boolean.
-
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
I want a code that stop placing orders for x of time after place one in mql4.
void OnTick()
{
//---
if (OrdersTotal() < 1)
{
if(emafast(0) > emaslow(0)&& emafast(10) > emaslow(10) && emafast(0) > emafast(5)) //&& emafast(1) > emafast(2))
{
if(histogram(0)<-0.0001 ||histogram(1)<-0.0001 ||histogram(2)<-0.0001 ||histogram(3)<-0.0001 ||histogram(3)<-0.0001 )//||histogram(5)<-0.0001 ||histogram(6)<-0.0001 || histogram(7)<-0.0001 )//||histogram(8)<-0.0001 ||histogram(9)<-0.0001 ||histogram(10)<-0.0001 ||histogram(11)<-0.0001)
{
if(macd()>= signal())
{
if(ema20(0)>ema50(0) && ema20(1)<ema50(1))
{
if(OrderSend(NULL,0,1,Ask,10,Ask - 0.0006 ,0.0020 + Ask,NULL,0,0))
{
Sleep(14400000);
}
}
}
}
}
if(emafast(0) < emaslow(0)&& emafast(10) < emaslow(10) && emafast(0) < emafast(5) )//&& emafast(1) < emafast(2))
{
if(histogram(0)>0.0001 ||histogram(1)>0.0001 ||histogram(2)>0.0001 ||histogram(3)>0.0001 ||histogram(3)>0.0001 )//||histogram(5)>0.0001 ||histogram(6)>0.0001||histogram(7)>0.0001 )//||histogram(8)>0.0001 ||histogram(9)>0.0001 ||histogram(10)>0.0001 ||histogram(11)>0.0001)
{
if(macd()<= signal())
{
if(ema20(0)<ema50(0) && ema20(1)>ema50(1))
{
if (OrderSend(NULL,1,1,Ask,10,0.0006 + Ask,Ask - 0.0020,NULL,0,0))
{
Sleep(14400000);
}
}
}
}
}
}
}
as shown I tried sleep function but it does not work on backtesting. it there another way to do it ?