[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Sliding Window



PureBytes Links

Trading Reference Links

I would add in this formula a sliding window that auto-optimizes in real-time mode the values of kappa1 and kappa2 in according to the best ProfitFactor of previous 100 days. In practice ... an automatic Walk Foreward .

Invest = 100000;
SetOption( "InitialEquity",Invest);
SetOption( "MaxOpenPositions",1); 
PositionSize=Invest;   
ApplyStop(0,0,0,0);
ApplyStop(1,0,0,0);
ApplyStop(2,0,0,0);
SetTradeDelays(0,0,0,0);
SetBarsRequired( 10000, 10000); 

TimeFrameSet(in5Minute);

Timeopen=TimeNum()==090000;
Timeclose=TimeNum()==173000 ;
Time1630=TimeNum()==163000 ;

O_OGGI=ValueWhen(Timeopen,O,1);
C_OGGI=ValueWhen(Timeclose,C,1);
T_1630=ValueWhen(Time1630,C,1);

Yield1=((T_1630/O_OGGI)-1)*100;
alpha=0.02;

for( i = 100; i < BarCount; i++ )
{
avrg1[0]=yield1[0];
avrg1[i]=(1-alpha)*avrg1[i-1]+alpha*yield1[i];
dvst1[0]=yield1[0];
dvst1[i]=sqrt((1-alpha)*dvst1[i-1]^2+alpha*(yield1[i]-avrg1[i])^2);
}

Input1=IIf((Yield1>2*dvst1),1,IIf((Yield1<-2*dvst1),-1,(Yield1/(2*dvst1))));

kappa1=Optimize("kappa1", 0.45, 0, 1, 0.05);
kappa2=Optimize("kappa2", -0.95, -1, 0, 0.05 );

Buy=Time1630 AND Input1 >= kappa1;
Sell=Timeopen;
Short=Time1630 AND Input1 <= kappa2;
Cover=Timeclose;

BuyPrice=C;
SellPrice=O;
ShortPrice=C;
CoverPrice=C;

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

PlotShapes( shapeUpArrow* Buy , colorBlue ,0,L);
PlotShapes( shapeHollowUpArrow* Cover ,colorBlue ,0,L);
PlotShapes( shapeHollowDownArrow* Sell,colorRed ,0,H);
PlotShapes( shapeDownArrow* Short, colorRed ,0, H); 

Plot(C,"",colorBlack,styleCandle);
_N(Title = StrFormat("{{NAME}} - ANG Last_H System - {{INTERVAL}} {{DATE}} - Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

eq=Param("equity",1,0,1,1);
equi=IIf(eq==0,Null,Equity( ));
Cover1=Flip(Cover,Short);
Short1=Flip(Short,Cover);
Buy1=Flip(Buy,Sell);
Sell1=Flip(Sell,Buy);
Plot( Equi-Invest,"\n\Equity",IIf(Buy1,colorPaleTurquoise,IIf(Short1,colorRose,colorLightGrey)), styleArea+styleLeftAxisScale);
dr = Equi- Highest(Equi);
Plot(dr, "Drawdown", colorDarkRed, styleArea+styleLeftAxisScale );
Maxdr=LLV(dr,100000);
Plot( Maxdr , "Max Drawdown", colorDarkRed, styleLine+styleLeftAxisScale ); 


Herman, I have read in the previous messages that you are an expert in these things, which is the way ? 

UseCustomBacktestProc ?


thanks for any reply

Angio








------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/