cheesybites12:
Hi everyone
I am kinda new to programming and am currently trying to code my own EA.
when im tried to backtest my EA using the ordersend() function, the EA starts to execute too many new orders and thus ccausing the EA to overload and thus getting the error 148.
According to my understanding, the ordersend() is programmed to execute a single trade rather than multiple trades. Could the problem lie in my trading condition before entering a new new trade??
Thanks for all the help!
If you only want one trade just call OrderSend() once, don't call it again and again for each tick . . . before you call it are you checking to see if you already have an open Order ?
Hi everyone
I am kinda new to programming and am currently trying to code my own EA.
when im tried to backtest my EA using the ordersend() function, the EA starts to execute too many new orders and thus ccausing the EA to overload and thus getting the error 148.
According to my understanding, the ordersend() is programmed to execute a single trade rather than multiple trades. Could the problem lie in my trading condition before entering a new new trade??
Thanks for all the help!
// Trading condition double rhigh = iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, TradingPeriod, 0)); double rlow = iLow(Symbol(), Period(), iLowest(Symbol(), Period(), MODE_LOW, TradingPeriod, 0)); double ahigh = iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, TradingPeriod1, 0)); double alow = iLow(Symbol(), Period(), iLowest(Symbol(), Period(), MODE_LOW, TradingPeriod1, 0)); // Enter Long position if(Bid >= rhigh || Bid >= ahigh ) { OrderSend(Symbol(), OP_BUYLIMIT, LotSize, rhigh, Slippage, StopLoss, 0, "EAName", MagicNumber, 0, Green); } else if (Ask <= rlow || Bid >= alow) { OrderSend(Symbol(),OP_SELLSTOP, LotSize, rlow, Slippage, StopLoss1, 0, "EAName", MagicNumber, 0, Red); }
this is my trading condition. as long as it breaks a 20 day high, enter a position. however when i run it, all it does is just entering a new position the moment the EA starts.
cheesybites12:
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
<CODE REMOVED>
this is my trading condition. as long as it breaks a 20 day high, enter a position. however when i run it, all it does is just entering a new position the moment the EA starts.
Play videoPlease edit your post.
For large amounts of code, attach it.
- RaptorUK already toll you to check first before opening another. When "it breaks a 20 day high, enter a position." The next tick you enter a position. The next tick you enter a position...
oh sorry okay i just edited my post.
I now understand why William and Simon's posts appear so caustic at times
// Trading condition double rhigh = iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, TradingPeriod, 0)); double rlow = iLow(Symbol(), Period(), iLowest(Symbol(), Period(), MODE_LOW, TradingPeriod, 0)); double ahigh = iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, TradingPeriod1, 0)); double alow = iLow(Symbol(), Period(), iLowest(Symbol(), Period(), MODE_LOW, TradingPeriod1, 0)); // Enter Long position if(Bid >= rhigh || Bid >= ahigh ) { OrderSend(Symbol(), OP_BUYLIMIT, LotSize, rhigh, Slippage, StopLoss, 0, "EAName", MagicNumber, 0, Green); } else if (Ask <= rlow || Bid >= alow) { OrderSend(Symbol(),OP_SELLSTOP, LotSize, rlow, Slippage, StopLoss1, 0, "EAName", MagicNumber, 0, Red); }
Without any clue about the difference between TradingPeriod and TradingPeriod1, do you really expect that anyone will be able to pinpoint your problem?
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
I am kinda new to programming and am currently trying to code my own EA.
when im tried to backtest my EA using the ordersend() function, the EA starts to execute too many new orders and thus ccausing the EA to overload and thus getting the error 148.
According to my understanding, the ordersend() is programmed to execute a single trade rather than multiple trades. Could the problem lie in my trading condition before entering a new new trade??
Thanks for all the help!