I am not good at reading other people's code, so my attempt may not be good.
I see you are not testing for errors when you place the order, only when you modify it. Modifying orders can be a little tricky. It's easy to overlook something.
I see this line:
bool modifyResult = OrderModify(ticket, OrderOpenPrice(), OrderStopLoss(), upperBand, 0, Blue);
But where did you get OrderOpenPrice()? I think you need this first:
if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) == true) {EnterPrice = OrderOpenPrice();}
Then you have EnterPrice. Without that, I think you have nothing the EA can use.
I also see this line:
int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, slippage, 0, 0, "Bollinger Band Buy Order", magicNumber, 0, Blue);Never use Ask for OP_BUY orders. Use Bid.
Also, instead of modifying the order later, why not just set Stoploss and Takeprofit right out of the bat?
int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, slippage, OrderStopLoss(), upperBand, "Bollinger Band Buy Order", magicNumber, 0, Blue);And where is OrderStopLoss() anyway? Not in the code you submitted. You need to check if it is calculating the Stoploss price correctly.
Oh, I see. It's the internal function. Again, I think you need to call OrderSelect() first. Either way, we know it's 0 because that is what you specified in the OrderSend command. Why not just set it to 0 then.
I hope this helps somehow.
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi Everyone,
Im trying to make a simple EA, working on bollinger band.
After after several attempts, I alaways have this error message :
"Tester: exchange rate cannot be calculated";
"Tester: margin exchange rate cannot be calculated"
But when I use it on forex, it seems to work without error.
Can i help please ??