EA Opening trades per bar open
MasterSye, for now it seems that checking the “Evaluate rule on bar open only” works as I wanted. My strategy was, let just say it would be same for any other indicator too, that condition would be true if, for instance short MA would cross down over longer MA, that would mean open short. But during building the candle, there would happen short spike, which would cause crossover up, so then long trade would open, althought after completing the candle, there would be obvious that there is start of downtrend. So I want to open trade based on completing candle, which would most probably not end just in its extreme… but if I would open trade during the building candle, then trade would be triggered excately from that extreme, which was just a spike, not more or less average price during the candle.
Hi Zoki. So if i’m not mistaken, your strategy is to open a trade after close of the bar/candle. This means you can use IsBarOpen function to make sure that only one trade is opened per bar, unless of course that you made a condition where 2 trades or more should be opened once you have a confirmation to enter the market. If you prefer that your strategy analyzes the previous bar before with the confirmation of MA crossover or any indicator for that matter, then you should use the default shift = 1. This will prevent your EA to open trades during a candle formation.
Hi MasterSye. Hmm, it seems that for my needs, if I check “Evaluate rule on bar open only”, it does same as maybe IsBarOpen would do. What happened before I used this, was, for instance, I had TP 5 pips and SL 5 pips and I wanted only one trade to execute during the candle formation, but then if the price was volatile and made 50 pips inside that candle, my trade was opened again many times, before that candle was completed, hitting sometimes TP, simetimes SL, etc., opening new trade every time when old trade was closed, what happened also in not best situation too, what caused then (beside spreads) many losses inside that candle too.
I use also shift = 1 comparing to shift = 0, (to check the slope of indicators mostly) and it seems problem is solved in similar way, if I use “Evaluate rule on bar open only”. But that’s something I would need to check again, if it would open multiple trades inside one candle, without using “Evaluate rule on bar open only” or IsBarOpen, in case of using shift 1, shift 0.
Hello Zoki. That is why you need to use IsBarOpen is True to prevent multiple trades opening at the same time in the same bar. Evaluate rule on bar open only is used for back testing in the strategy tester. That is what I know. If you’re evaluating your strategy on the current candle instead of the previous one, there is a possibility that trades would open multiple times. Same thing happened to me even when I have IsBarOpen condition in my rules. Perhaps you should use shift 1 – meaning you should let your EA analyze your strategy starting from the previous candle, not the current one.
MasterSye, thank you for advices. I will certain at least try IsBarOpen, when I move from strategy tester into real time trading, or at least I will know where is problem, when I will get multiple trades inside current candle (what I thought I got under control in strategy tester). Thank you for now.