Sure. Here it is (Only the offending part):
<CODE DELETED>
The Comment "Down" actually gets displayed on the chart, so I know that the logic and criteria is fine, but the OrderSend gets totally ignored. Not even an error message in the Journal.
Please read some other posts before posting . . .
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
Please accept my apologies. I hope I am doing it right this time:
if (MovAvg2 >= OBLine2) if (MovAvg1 <= OBLine1) { Lots=MathRound(AccountBalance()/100000); if(Lots<0.01) Lots=0.01; Tally=1; Total=OrdersTotal(); if(Total>0) for(i=Total-1; i>=0; i--) if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) if(OrderSymbol()==Symbol()) Tally=Tally+1; Lots=Lots*Tally; Comment("Down"); OrderSend(Symbol(),OP_SELL,Lots,Bid,30,0,0,NULL,0,0,Red); Total=OrdersTotal(); if(Total>0) for(i=Total-1; i>=0; i--) if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) if(OrderType()==OP_BUY) if(OrderSymbol()==Symbol()) OrderClose(OrderTicket(),OrderLots(),Bid,30,Blue); }
The Comment "Down" actually gets displayed on the chart, so I know that the logic and criteria is fine, but the OrderSend gets totally ignored. Not even an error message in the Journal.
Why aren't you checking if the OrderSend() worked ? and if it didn't why not print the error and any associated useful variables ?
Read this: What are Function return values ? How do I use them ?
Hi,
I have two demo accounts with the same service provider running the exact same EA on both of them. Only difference is the time frame (5min & 1min). On the 5min the OrderSend() executes without any problem. On the other instance, the MT4 running the 1min charts, it does not execute at all. Not even an error message in the Journal. I added a Comment() statement directly above the instruction to verify that the code is executed up to this point, but the OrderSend() somehow gets totally ignored. For clarity I just want to reiterate that the code on both MT4 instances is EXACTLY the same . Why is this happening ?
Thanks,
Sjarko.
Same Symbol() not checking for magicnumber
Total=OrdersTotal(); if(Total>0) for(i=Total-1; i>=0; i--) if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) if(OrderSymbol()==Symbol()) Tally=Tally+1;
So on 1 minute without trades done there Tally=Tally+ 1 ;
Hi deVries. Thanks for the help. I am not too concerned about the value of Tally for now, as it does not really affect my strategy much. I decided I am going to reinstall MT4 (this instance) as the other MT4 instance is working (almost) fine with the exact same code. What is not working is the following code that is supposed to close all open trades in the other direction (in this code, all the Long trades).
Total=OrdersTotal(); if(Total>0) for(i=Total-1; i>=0; i--) if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) if(OrderType()==OP_BUY) if(OrderSymbol()==Symbol()) OrderClose(OrderTicket(),OrderLots(),Bid,30,Blue);
Maybe you guys can tell me why this is not working ? Is there a better way to do it ?
Thanks.
Hi deVries. Thanks for the help. I am not too concerned about the value of Tally for now, as it does not really affect my strategy much. I decided I am going to reinstall MT4 (this instance) as the other MT4 instance is working (almost) fine with the exact same code. What is not working is the following code that is supposed to close all open trades in the other direction (in this code, all the Long trades).
Maybe you guys can tell me why this is not working ? Is there a better way to do it ?
Thanks.
i told you already the problem
Same Symbol() not checking for magicnumber
So on 1 minute without trades done there Tally=Tally+ 1 ;
I have removed all the code except the OrderSend code and the exception handling. Still nothing, no message, not even in the Journal. I am going to totaly remove this installation of MT4 and re-install. I hope this will fix the problem.
Maybe you guys can tell me why this is not working ? Is there a better way to do it ?
![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
Hi,
I have two demo accounts with the same service provider running the exact same EA on both of them. Only difference is the time frame (5min & 1min). On the 5min the OrderSend() executes without any problem. On the other instance, the MT4 running the 1min charts, it does not execute at all. Not even an error message in the Journal. I added a Comment() statement directly above the instruction to verify that the code is executed up to this point, but the OrderSend() somehow gets totally ignored. For clarity I just want to reiterate that the code on both MT4 instances is EXACTLY the same. Why is this happening ?
Thanks,
Sjarko.