- pending ticket cannot executed.
- Script don't work - need help
- Simple "Script"
use extern instead
extern double lots =0.1;
Is not a good practise changing the input parameters because once changed you cannot reset the value until the EA is restarted.
input double inplots =0.1; input int stoploss= 30; input int takeprofit= 40; input int magic1=302; input int slippage= 3; input double lotfactor= 0.50; input int totalorders=8; input int EnterHour =4; double lots = inplots; //+------------------------------------------------------------------+ void openbuy() { OrderSend(Symbol(), OP_BUY,lots,Ask, slippage, Ask-stoploss*Point,Ask+takeprofit*Point,"Buy Trade",magic1,0,Blue); lots+=lotfactor; } void openbuystop() { int ticket, expiration; double point; //---- point=MarketInfo(Symbol(),MODE_POINT); expiration=NULL; double price = Ask+50*Point; //---- while(true) { ticket= OrderSend(Symbol(), OP_BUYSTOP,lots,price,0, 0,price+takeprofit*Point,"BuyStop Trade",magic1,expiration,Green); if(ticket<=0)Print("Error = ", GetLastError()); else{Print("ticket = ", ticket); break; } //---- 10 seconds wait Sleep(10000); } lots+=lotfactor; } void opensell() { OrderSend(Symbol(), OP_SELL,lots,Bid-50*Point, slippage, Bid+stoploss*Point,Bid-takeprofit*Point,"Sell Trade",magic1,Red); lots+=lotfactor; } void opensellstop() { int ticket, expiration; double point; //---- point=MarketInfo(Symbol(),MODE_POINT); expiration=NULL; double price = Bid-50*Point; //---- while(true) { ticket= OrderSend(Symbol(), OP_SELLSTOP,lots,price,0, 0,price-takeprofit*Point,"SellStop Trade",magic1,expiration,Pink); if(ticket<=0)Print("Error = ", GetLastError()); else{Print("ticket = ", ticket); break; } //---- 10 seconds wait Sleep(10000); } lots+=lotfactor; }
Is not a good practise changing the input parameters because once changed you cannot reset the value until the EA is restarted.
OrderSend(Symbol(), OP_BUY,lots,Ask, slippage, Ask-stoploss*Point,Ask+takeprofit*Point,"Buy Trade",magic1,0,Blue);
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