Dealing with multiple time-frames in Amibroker for backtests.

#1
Hi all,

I want to generate the signal on an hourly bar , but the trailing stops should run on 1-minute bars since trailing stop on hourly bar wouldn't work in real time.

Settings are as follows:

Generate signal on hourly bars and trailing stop loss at 0.3% with no fixed target.
I don't know how to trail stop loss on 1-minute bar basis.


Can anyone help me with this? Thanks!:)
 
#2
When you select "stops exit intraday" in the backtester settings it exits at the exact stop you requested. I'm assuming you are using applystop function.
 
#3
When you select "stops exit intraday" in the backtester settings it exits at the exact stop you requested. I'm assuming you are using applystop function.
Thanks for your reply.

Yes, those are my settings but it kind of looks into future since the exit will be 0.3% down from the HIGH of the next bar. There is a lot of fluctuation in between where in real time the stop will get triggered as opposed to getting triggered at 0.3% down from the HIGH of the hourly bar.

I am not very good with Amibroker. I don't know whether the stop gets triggered as I think or it runs on 1minute bar since I have 1minute bars as base-time interval in database settings.

I need clarification on this.
 

travi

Well-Known Member
#4
Thanks for your reply.

Yes, those are my settings but it kind of looks into future since the exit will be 0.3% down from the HIGH of the next bar. There is a lot of fluctuation in between where in real time the stop will get triggered as opposed to getting triggered at 0.3% down from the HIGH of the hourly bar.

I am not very good with Amibroker. I don't know whether the stop gets triggered as I think or it runs on 1minute bar since I have 1minute bars as base-time interval in database settings.

I need clarification on this.
Pertaining to the TF, Analysis (Scan or Explore) uses the TF defined in periodicity under general in the analysis settings regardless of what your base TF is for DB.

I suggest you check that TF and change it to hourly or whatever TF you're logic is supposed to work on.
By default its Daily.
 
#5
Pertaining to the TF, Analysis (Scan or Explore) uses the TF defined in periodicity under general in the analysis settings regardless of what your base TF is for DB.

I suggest you check that TF and change it to hourly or whatever TF you're logic is supposed to work on.
By default its Daily.
Thanks @Travi,
I want to generate signal on hourly bars, but backtest it on 1-minute bars.
Is it possible??
 
#6
yes try this in any time frame for hourly signal

PHP:
 SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

x=TimeFrameGetPrice("C", inhourly, -1);
y=TimeFrameGetPrice("C", inhourly, -1);
x = EMA(x,3);//hourly crossover
y = EMA(y,8);//hourly crossover
Plot(x,"",colorRed,styleLine);
Plot(y,"",colorDarkGreen,styleLine);
 
Buy=Cross(x,y);
Sell=Cross(y,x);
Short=Sell;
Cover=Buy;

Buy=ExRem(Buy,Sell);    Sell=ExRem(Sell,Buy); 
Short=ExRem(Short,Cover);  Cover=ExRem(Cover,Short);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorGreen, 0,Low,-10);  
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed, 0,High,-10); 
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorGreen, 0,Low,-10);  
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,High,-10);
 
Last edited:

Similar threads