Count++
I am assuming (which is always a bad idea) that Count is initilised to 0 before the program is called which is on every tick (new piece of chart data) so the variable Count will always be 1.
Use varable declaration just after function declaration otherwises you are likely to get "already defined varable errors.
the counter is just fine. its defined as global before start() (so not defined as 0 every tick). and the alert message also is counting properly.
my problem is just that orders dont get listet in trades.
OrderSend(Symbol(),OP_BUY,0.1,Bid,3,Bid-15*Point,Bid+15*Point);
- You open buys at the Ask and sells at the Bid.
- Test return codes and print errors so you know why
if(!OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-15*Point,Bid+15*Point)) Alert("orderSend failed ",GetLastError());
- On a 5 digit broker you must adjust tp, sl, and slippage. a sl of 1.5 pips won't work on most brokers. MarketInfo(Symbol(), MODE_STOPLEVEL)*Point is 30 (3.0 pips on IBFX)
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- On ECN brokers you must open the order without a tp/sl and then modify it.
the counter is just fine. its defined as global before start() (so not defined as 0 every tick). and the alert message also is counting properly.
my problem is just that orders dont get listet in trades.
Thanks - saves me testing it!
@ WHRoeder
thanks, I changed the asks and bids. Added the print errors. but still nothing.
no errors are displayed and no trades either.
I did some manual trades so its not FxPro.
I even tried the most simple Adviser but still no trades although alerts are shown.
int start() { //---- int Ticket = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-20*Point,Bid+20*Point); if (Ticket < 0) // Success :) { Alert ("Opened order Buy ",Ticket); return; // Exit start() } //---- return(0); }
Hi,
if ticket < 0 means there was an error. I assume you are on a 5 digits broker where Bid-20*Point is to close to the current market. It would be only 2Pips away from the current price. you should reread WHRoeder's post, and implement the 3/5 Digits adjustment.
Okay, yes I'm using a 5 digits broker. now I added the adjustment to my code.
after running it I get the common error 4109 "Trade not allowed" which I tried to solve by allowing "live trades" in the EA options, but this error still shows up.
I read about the 4109 problem here and some say that it might be because of the too close tp's and sl's, but shouldn't this return the error 130?
AlyxO:
which I tried to solve by allowing "live trades" in the EA options, but this error still shows up.
Thanks a bunch guys.
I dont know what caused the problem but after restarting my computer it was solved.
So now my orders are showing up in trades.
thanks again
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I'm new to MQL4 and do have a problem with the execution of an Expert Advisor.
While the Expert is running I'm getting the alerts I assigned to the OrderSends, but the orders don't show up in the Trading window in FxPro, which means the Expert doesn't do anything at all.
Thanks in advance.
Here is the code: