- RSI cross sound alert request
- Problem: multiple firing of orders within bars
- Closing trade before end of candle it entered
Please attach a proper code file with the ".mq4" extension and not just a standard text file with code in them.
- Don't rename extensions.
- Where is your new bar test? How are "you trying?"
- You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
No free help (2017)
Hi all, thanks for the comments.
I have added this line into the OnTick -
if (!IsNewBar()) return; // This EA only runs at the start of each bar
and that is using this function
Now, if I dont add those 2 bits of code, it will run as I want it to but it fires on each Pip when the criteria is met. But as soon as I add those 2 bits of code it, runs but no trades are fired. I have attached the script, hopefully I have done it right, sorry but new to all this so its my first postbool IsNewBar() { static datetime currentTime = 0; // Will retain last value between calls bool result = (currentTime!=Time[0]); // returns true at each new bar if (result) currentTime = Time[0]; // Update current at a new bar return(result); }
It should be the .mq4 file, not the .ex4
double BarValueBulls = High[0] - Open[0]; // Get size of bar for longs double BarValueBears = Open[0] - Low[0]; // Get size of bar for shorts
Now you are processing the first tick of a new bar. Therefor, High[0] equals Open[0] equals Low[0]. Why does no trades surprise you?
Please EDIT your post and use the CODE button when you post code.
Now you are processing the first tick of a new bar. Therefor, High[0] equals Open[0] equals Low[0]. Why does no trades surprise you?
Thanks for the feedback William, I have fixed the issue by adding this
int ticket=0; if (bullisheng && last5barsbear) if(OrdersTotal()==0) ticket = OrderSend(Symbol(),OP_BUY, 0.02,Ask,3,StopForLongs,LimitForLongs,"",0,0,Red); if (bearisheng && last5barsbull) if(OrdersTotal()==0) ticket = OrderSend(Symbol(),OP_SELL,0.02,Bid,3,StopForShorts,LimitForShorts,"",0,0,Blue);
Now you are processing the first tick of a new bar. Therefor, High[0] equals Open[0] equals Low[0]. Why does no trades surprise you?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use