up for Mike, if you have ... a lot of time !

thanks
angio

--- In [email protected], "Angio" <angio1...@...> wrote:
>
> 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 ); 
> 
> 
> which is the way ? 
> 
> UseCustomBacktestProc ?
> 
> 
> thanks for any reply
> 
> Angio
>


Reply via email to