Ticket=OrderSend(NULL,OP_BUY,lots,Ask,10,NULL,BuyTP,NULL,Magic,NULL,clrBlue);
- Check your return codes (OrderSend) and find out why.
What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- NULL is not a valid SL, NULL is not a valid expiration. Use zero.
So, I found out that if i take out the "Ticket=" then it will make multiple trades, but won't close them unless it hits the TP, obviously. I copied the code you posted from another EA I have and had no problems with it in that EA, so there must be something where Ticket is keeping it from opening more trades but I can't find anything.
Another update. I used
if(OrderSelect(0,SELECT_BY_POS)) { Ticket=OrderTicket(); }
to set the ticket value instead of assigning it at the order placement. It appears that if the order is closed by
if(OpenTrade&&Position=="Buy"&&(Strength>=ExitBuySignalStrength||(BuyArrowExit&&ArrowUp!=0))) //Buy close Logic { OrderClose(Ticket,Lot,Bid,10000,clrGreen); OpenTrade=false; Position=""; } if(OpenTrade&&Position=="Sell"&&(Strength<=ExitSellSignalStrength||(SellArrowExit&&ArrowDown!=0)))//Sell close Logic { OrderClose(Ticket,Lot,Ask,10000,clrGreen); OpenTrade=false; Position=""; }
then it won't open any other orders for some reason.
More experiments done, even if it hits the TP line it won't open any other trades. So once the first trade is closed, the program is incapable of opening any other trades.
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.
It's use is always wrong
- SL/TP are market orders when triggered, they don't need to be normalized, only abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Only the open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
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
Here is the code
and here is a back test. All of the conditions are met but it won't open a trade. SellSignalStrength is set to 95.