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

[amibroker] Re: Help (TJ?) initial or initialize variable



PureBytes Links

Trading Reference Links


Hello, 

thanks for the code.

I think that you solved the variable "type" problem (that means your
"range" variable is not accepted in standard CCI function), but
unfortunately nothing about my first target that is to "count bars
since last buy/sell" and put this figure into CCI. 

My target is:

CCI(range)

where 

a) range=10 if buy/sell signals are less than 10 periods/bars "old" and
b) range= "number of bars"*K  (K=factor) if buy/sell signals appeared
more that 10 periods/bars.

the main problem to solve is the inizialization because to generate
buy/sell signals I need CCI, but to calculate CCI i need buy/sell.
So I'm not able to code it without having an initialization error.

In any case thank you very much,

Hans

--- In amibroker@xxxxxxxxxxxxxxx, "Stephane Carrasset"
<nenapacwanfr@xxxx> wrote:
> 
> Better
> 
> SetBarsRequired(100,100);
> range= int(MFI(14));
> mean=MA(Avg,range);//1,2
> array=Avg;
> result = 0;
> 
> 
> 
>    for( i = 0 ; i < BarCount; i++ )
>    {
> if(i<range[i])
> result[i]=Null;
> else
> {
>       result[ i ] = 0;
>       // the mean is not 'moving' over the range (outside the loop)
>       tm = mean[ i ]; 
>       for( j = 0; j < range[i]; j++ )
>       {
>         result[ i ] = result[ i ] + abs( array[ i - j ] - tm );
>       }
>     
>     result[ i ] = result[ i ] / range[i]; 
>   }
> }
> 
> CCIx = (Avg - mean) / (0.015 * result);//5,6,7
> Plot(CCIx,"CCIx",colorGreen,styleLine);
> Plot(CCI(14),"CCI",colorRed,styleLine);
> Plot(Range,"Range",colorBlue,styleLine|styleOwnScale);
> 
>  
> 
> 
> 
> > 
> > hope it helps
> > change the range with any variable positive and not null period 
> > 
> > and //  the afl cci
> > 
> > 
> > range= 20;//MFI(14);
> > mean=MA(Avg,range);//1,2
> > array=Avg;
> > result = 0;
> > 
> > 
> > 
> >    for( i = 0 ; i < BarCount; i++ )
> >    {
> > if(i<range[i])
> > result[i]=Null;
> > else
> > {
> >       result[ i ] = 0;
> >       // the mean is not 'moving' over the range (outside the loop)
> >       tm = mean[ i ]; 
> >       for( j = 0; j < range[i]; j++ )
> >       {
> >         result[ i ] = result[ i ] + abs( array[ i - j ] - tm );
> >       }
> >     
> >     result[ i ] = result[ i ] / range[i]; 
> >   }
> > }
> > 
> > CCIx = (Avg - mean) / (0.015 * result);//5,6,7
> > Plot(CCIx,"CCIx",colorGreen,styleLine);
> > Plot(CCI(range),"CCI",colorRed,styleLine);
> > 
> >  
> > > 
> > > could anyone help? Maybe TJ?
> > > 
> > > Thanks in advance
> > > Hans
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Hans" <hansib@xxxx> wrote:
> > > > 
> > > > Hello,
> > > > 
> > > > I need some help.
> > > > 
> > > > My goal is to have a CCI with variable period so that bars 
> since 
> > buy
> > > > or sell that exceeds 10 are the new CCI period.
> > > > 
> > > > I have coded this:
> > > > 
> > > > p4=10;
> > > > 
> > > > bs=BarsSince(Buy OR Sell);
> > > > pp=Max(bs,p4);
> > > > CC=CCI(pp);
> > > > 
> > > > Buy=Cover=Cross(Cc,-100);
> > > > Sell=Short=Cross(100,Cc);
> > > > 
> > > > **********
> > > > problems are initialization of arrays.
> > > > how can i consider buy/sell before calculation, and at the same 
> > time
> > > > to make calculations i need buy/sell.
> > > > 
> > > > Thanks for any help.
> > > > 
> > > > Hans





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

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