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

[amibroker] Loop ... a little problem !



PureBytes Links

Trading Reference Links

I am a novice programmer AFL, I searched in the old posts a reply to my problem with the loop intraday, but I have not found anything, so I try to ask:

My system works on a 5 minutes bar chart, the loop that I created makes the calculation of variables 'avrg1' and 'dvst1' each bar.
But I wish that were not calculated each bar, but every day, so that

avrg1[1] refers to day 1 of chart at time 163000
avrg1[2] refers to day 2 of chart at time 163000
avrg1[3] refers to day 3 of chart at time 163000
....
dvst1[1] refers to day 1 of chart at time 163000
dvst1[2] refers to day 2 of chart at time 163000
dvst1[3] refers to day 3 of chart at time 163000
....
	
thanks for the reply,

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); 

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,O,1);

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

for( i = 1; 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=Param("kappa1", 0.20, 0, 1, 0.05 );
kappa2=Param("kappa2", -0.90, -1, 0, 0.05 );

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

BuyPrice=O;
SellPrice=O;
ShortPrice=O;
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 ) ) ));


 



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

**** 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/