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

[amibroker] cci divergence afl



PureBytes Links

Trading Reference Links

here is my crack at it. it plots bullish divergence with $ and bearish divergence with #
pl let me know if you find any issues with it as i am trying to test it.
Pl note. it looks ahead by 1 day to determine the turning points.


_SECTION_BEGIN( "CCI_Divergence" );
array = CCI();
Color = colorBlue;
Plot( array, "", colorDefault, styleLine | styleThick | styleNoLabel);
Plot( array, "", Color, styleHistogram );
_SECTION_END();

Change = MA( abs( 100 * ( array - Ref( array, -1 ) ) / array ), 14 );
/*
adjz = Param( "Zig", 10, 0, 15.0, .1 );
adjc = Param( "Back", 0, 0, BarCount, 1 );
CAdj = Ref( array, -adjc );
Graph1 = CAdj;
Zigzag = Zig( array, LastValue( Change ) );*/
//Plot( Zigzag, "Zigzag", colorBlack, styleNoTitle | styleLine );
//Peakshape=IIf(Peak(array, LastValue(Change),1),shapeStar,shapeNone);
//Peakvalue=Peak(array, LastValue(Change),1);

//PlotShapes(Peakshape,colorRed);
firstVisibleBar = Status( "firstvisiblebar" );
lastVisibleBar = Status( "lastvisiblebar" );

CCITurningdown = array > Ref( array, -1 ) AND array > Ref( array, 1 );
CCITurningup = array < Ref( array, -1 ) AND array < Ref( array, 1 );

CCIpeak = IIf( array > 0 AND CCITurningdown, shapeStar, shapeNone );
CCItrough = IIf( array < 0 AND CCITurningup, shapeSquare, shapeNone );
//PlotShapes(CCIpeak,colorRed);
//PlotShapes(CCItrough,colorRed);


Look4Shorts = EMA( C, 9 ) < EMA( C, 20 );
Look4Longs = EMA( C, 9 ) > EMA( C, 20 );

CCIBearishdivergence = Look4Shorts AND ( array > ValueWhen( CCItrough, array, 1 ) ) AND ( C < ValueWhen( CCItrough, C, 1 ) );
CCIBullishishdivergence = Look4Longs AND ( array < ValueWhen( CCIpeak, array, 1 ) ) AND ( C > ValueWhen( CCIpeak, C, 1 ) );



//PlotShapes(IIf(ValueWhen(CCItrough,C,1)>C AND ValueWhen(CCItrough,CCItrough,1)<array,shapeCircle,shapeNone),colorOrange);
/*

CCI Divergence Occurs when the c < valuewhen(ccirough) and cci >last ccitrough.

*/

_TRACE( NumToStr( ValueWhen( CCItrough, array, 1 ) ) );

for ( b = firstVisibleBar;( ( b < lastVisibleBar ) AND ( b < BarCount ) ) ;b++ )
{

    if ( CCIBearishdivergence[b] == 1 )
    {
        PlotText( "#", b, array[b], colorRed );
    }

    if ( CCIBullishishdivergence[b] == 1 )
    {
        PlotText( "$", b, array[b], colorGreen );
    }

//_TRACE("valie of peak" + NumToStr(Peakvalue[b]));


}



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

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