Every "n"bars issue.
-
I need to check conditions: "if trade, every "n" bars", but it´s very imprecise, some times put the arrow in the trade candle and some times put it 4 candles before.
However it close trades every "n" bars very accurate. What I´m doing wrong?
https://fxdreema.com/shared/OiafPDcne

-
I'm not sure if I understand what you mean, but remember that you have put the "every n bar" blocks AFTER the "if trade" block. This means the EA doesn't actually count every bar because there is the condition.
Try switching the "every bar" counter to top position? -
I´m looking to change Variables at first bear bar (with ID 1) after trade. I need to wait two candles to check the candle close on ID 1 and ID 2.
I tried it with counters, flags, candleCount... and it doesn´t work. I understand than candles close it´s not accurate, but two candles more or less is too much, I´m doing something wrong.
-
Hmm, how about playing with a variable of your own, something like this:
On each bar:
- Modify variable beardetector to 0 when trade opens
- If last candle (ID1) open is above last candle (ID1) close (thats a bear) -> Modify variable beardetector to 1
- You can also reset the beardetector to 0 when last candle is bullish, same logic
Now you can just check if beardetector is 1 and continue from there.
-
The EA must buy after a bearish row, and here is the problem, because "when trade opens" the candle ID 1 is bearish on all trades.
I need to check every candle close after trade, not before. Seems easy to put a counter but with candle counters is not accurate.
In the example on the top you can see how the counter with "If trade, every 3 bars, Draw arrow. Sometimes draw in the trade candle, sometimes in the next...Your help is much appreciated.
-
You can also use a simple variable to count the bear row.
For example, if you are seeking for 3 bears:On each bar:
Condition: Last candle open is higher than close
if true -> modify variable RowCounter to RowCounter +1
if false -> modify variable RowCounter to 0Now you can make condition: RowCounter is above or equals 3
-> buy -> to reset, modify variable RowCounter to 0built example: https://fxdreema.com/shared/17r2DukKd
-
The block "Bears in a row" works fine to open trades. But when I need to count candles in a trade It´s inaccurate. With this example the EA must close trades every 10 bars or at third bullish bar after a trade:
https://fxdreema.com/shared/ED03ge53b
But it doesn´t works.
-
I think the "every n bars" counts in a way you dont mean it.
If you mean to close every trade at some maximum age, you could just use the "close trades" block's age filter.
For example close every trade older than 10 hours, "close trades" with filter "Filter trades by age" 10*60=600 minutes. -
https://fxdreema.com/shared/cH6baD7Id
Thanks Roar, now is working fine, with check age. But now I need to get "current time frame" to change the Variables. For example I have a 10 min expiration in a 1 min timeframe, if the EA start in a 5 min timeframe, multiply by 5 the variable "mins to close".
Is this possible with a block or need a custom code?
Thanks.
-
I haven't done anything like that, so cannot give any definite help

Well, in the formula block, you could choose left operand as market properties - timeframe, and multiply it with some variable in right operand. I don't know if the timeframe is just a minute value, though.. Could be worth a try
-
-
Wow, that went better than expected

You are welcome!