The StopLoss and TakeProfit values are too close to Market Price (Ask or Bid). You should set these at least the spread value from Market Price.
Okay so, code-wise, how would I do that?
For example with:
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-???, Ask+???, NULL, 0, 0, Green);
What should the ??? values be?
int spread=MarketInfo(Symbol(),MODE_SPREAD); double sl = NormalizedDouble(Ask-spread*Point,Digits); double tp = NormalizedDouble(Ask+spread*Point,Digits); int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, sl, tp, "Open Buy", 0, 0, Green);
Quick question about this annoyance.
See this line of code:
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
I keep getting the error message code 4109 (Which means trade is not allowed).
What is wrong with that line of code?
The code isn't the problem yet. The not allowing live trades is.
Go to:
TOOLS >> OPTIONS >> EXPERT ADVISORS >> and select the allow live trades. This will rid that error. If your bid or stop is incorrect you will get error 130 or 129 depending on the problem.
int spread=MarketInfo(Symbol(),MODE_SPREAD); double sl = NormalizedDouble(Ask-spread*Point,Digits); double tp = NormalizedDouble(Ask+spread*Point,Digits); int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, sl, tp, "Open Buy", 0, 0, Green);
With this code, it came up with compiling errors.
'NormalizedDouble' - function is not defined.
So, in the case of this code, how would I define NormalizedDouble?
Quick question about this annoyance.
See this line of code:
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
I keep getting the error message code 4109 (Which means trade is not allowed).
What is wrong with that line of code?
The code isn't the problem yet. The not allowing live trades is.
Go to:
TOOLS >> OPTIONS >> EXPERT ADVISORS >> and select the allow live trades. This will rid that error. If your bid or stop is incorrect you will get error 130 or 129 depending on the problem.
Interesting. I didn't know about this Tools >> Options >> Expert Advisors >> ...
I do now.
But that still didn't help.
I still kept getting the 4109 error message with my code (I originally posted above).
I think the problem may be in the following red part of code, but I'm not sure.
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
Another words, flawed StopLoss and TakeProfit.
What am I doing wrong? How can I fix this?
Sorry, a typo in the code. Normalize should not have been past tense. Try this:
int spread=MarketInfo(Symbol(),MODE_SPREAD); double sl = NormalizeDouble(Ask-spread*Point,Digits); double tp = NormalizeDouble(Ask+spread*Point,Digits); int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, sl, tp, "Open Buy", 0, 0, Green);
Quick question about this annoyance.
See this line of code:
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
I keep getting the error message code 4109 (Which means trade is not allowed).
What is wrong with that line of code?
The code isn't the problem yet. The not allowing live trades is.
Go to:
TOOLS >> OPTIONS >> EXPERT ADVISORS >> and select the allow live trades. This will rid that error. If your bid or stop is incorrect you will get error 130 or 129 depending on the problem.
Quick question about this annoyance.
See this line of code:
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
I keep getting the error message code 4109 (Which means trade is not allowed).
What is wrong with that line of code?
The code isn't the problem yet. The not allowing live trades is.
Go to:
TOOLS >> OPTIONS >> EXPERT ADVISORS >> and select the allow live trades. This will rid that error. If your bid or stop is incorrect you will get error 130 or 129 depending on the problem.
Interesting. I didn't know about this Tools >> Options >> Expert Advisors >> ...
I do now.
But that still didn't help.
I still kept getting the 4109 error message with my code (I originally posted above).
I think the problem may be in the following red part of code, but I'm not sure.
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-0.001, Ask+0.001, NULL, 0, 0, Green);
Another words, flawed StopLoss and TakeProfit.
What am I doing wrong? How can I fix this?
But then again, jyett77 you were right.
First I had to make sure my EA option allow live trades.
I did that, BUT (for some strange reason)...I also noticed on my chart, in the upper right hand corner, the EA name and smily face wasn't smiling; so something still seemed wrong.
So, I right-click on my chart --> Select Expert Advisors --> Click Properties.
And there I also selected Allow live trading
So, that takes care of that.
And now, as you also said before, the code wasn't the problem yet.
So now I will tackle the code.
I think we've almost got this problem tackled completely.
Sorry, a typo in the code. Normalize should not have been past tense. Try this:
int spread=MarketInfo(Symbol(),MODE_SPREAD); double sl = NormalizeDouble(Ask-spread*Point,Digits); double tp = NormalizeDouble(Ask+spread*Point,Digits); int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, sl, tp, "Open Buy", 0, 0, Green);
Yeah wackena, that code alone contains no compiling errors.
It looks good :)
I guess, as soon as the market opens Sunday, I will try it.
:) Perhaps this is the beginning of the code I'm looking for. :)
Yep, wackena, the code works.
Now, I can customize and tweak.
Thanks. And thank you all.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Quick question about this annoyance.
See this line of code:
I keep getting the error message code 4109 (Which means trade is not allowed).
What is wrong with that line of code?