Suppose I am on 15 minutes timeframe. My sample code would look like this...
buy=cross(H,level and atr(1)>7;
I need the value of atr() for backtesting purpose at the moment the High crosses` Ref(hhv(H,7),-1) as in the example above but amibroker gives me the value of atr() at the end of period which in this case is 15 minutes candle. How to get the running value of the indicator as in this example for backtesting purpose? I have no idea how to handle this case, If you experts would guide me which path I should follow, it would have been very helpful to me
You are right, I made a stupid mistake in the code, but after I corrected it , still does not work. I checked it on bar reply in amibroker on 15 minutes interval. I put 1 minute step interval on bar reply on 15 minutes candle to visualise when it trigers the buy signal. What happens is my 15 minutes High crosses up the level , and at this moment ATR is below value of 7 and there is no signal (as it should be) but after a couple of minutes later (on the same 15 minutes candle), ATR reaches the value of 7 or more and the High is above the level and only then it trigers the buy signal. The problem is that buy signal is not trigered at the same time. Two conditions must be met simultaniously and they are not. Is there a way to do it in amibroker?
My present question corresponds to the problem above. The point is that live quotes on 15 minutes interval change ATR value every tick while 15 minutes candle is forming. I would like to use this running (changing) value of ATR from 15 minutes interval in backtest.
When I usally do the backtest i have value of atr from 15 minutes interval after every 15 minutes. I dont have running (changing) value of atr while the 15 minutes candle is forming. So my question is... is it possible to retrieve that runing value of ATR or any other indicator for backtest? If so, how can it be done?
As a general rule, your backtest should use the shortest periodicity for which you need to check any value or indicator. For example, if you use 1 minute periodicity, you can easily calculate the ATR on full 15 minute bars using TimeFrameSet() or TimeFrameCompress(), and you could also calculate the running 15 minute ATR value at the end of each 1 minute bar. However, calculating running indicators in this way is often computationally expensive, so it's typically better to use the indicator value from the end of the previous, fully-formed bar.
In your specific example, it would appear that you don't really need to calculate a proper ATR, but rather just the difference between Max(highest since last full bar, previous full bar close) and Min(lowest since last full bar, previous full bar close).
Thank you Tomasz and mradtke for the response. Reffering to mradtke last post. I was thinking about what you said about calculating the diffrence between Max(highest since last full bar, previous close and Min(lowest since last full bar, previous full bar close). I think this is what I want, this is the solution for me. I have general idea how to use that for the runing value of indicators . But please could you please elaborate on this a bit ? If you could describe it in your words how you would do it. How would you get use of Max(highest since last full bar, previous full bar close and Min(lowest since last full bar, previous full bar close) to calculate runing value od of ndicator from 15 minutes interwal while being on 1 minute interval?
Any hint would help me since I stiill learn afl and I have a long way to get there.
Thanks for the solution and for the formula. I understand that all I have to do in the future is substitute ATR calculation at the end of the formula for any other indicator calculation (whatever indicator I will use). This solution, formula for calculating the running value of indicator is what I need.
One more question comes to my mind. We assume that I will have to go down to 1 minute interval to recalculate the running value of 15 minute indicator, but why we are not talking about going down to 1 tick interval. In my opinion the recalculation of the running value of indicators would be more accurate if we did that.I have version of amibroker which allows me to have min interval as 1 tick . That problem bothers me as well.
I think you are overdoing and overthinking things @argentarius
Newbies have tendency to make things more complex that they are.
There is an advantage in using higher timeframes and NOT using "running" values.
The advantage that I am talking about is noise suppression. Market is noisy. And acting upon noise will give you WORSE results, not better ones.
Running values are NOT more accurate. They are LESS accurate. They are noisier. By doing what you are trying to do you are neglecting the advantage of noise suppression offered by higher intervals. There is a reason (exactly that what I am talking about - noise suppression) why people with engineering background like John Ehlers use entire bar average (H+L)/2 or (H+L+C)/3 instead of Close price as input of their indicators. That makes sense and this exactly reverse of what you are trying to do.