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

[amibroker] Beginer question on Automatic Analysis



PureBytes Links

Trading Reference Links

Working with the following code:   Yellow I added

 

_SECTION_BEGIN("MACD");

//Added arrows on 9/1/05 DW

//Added Alerts on 9/5/05 DW

r1 = Param( "Fast avg", 12, 2, 200, 1 );

r2 = Param( "Slow avg", 26, 2, 200, 1 );

r3 = Param( "Signal avg", 9, 2, 200, 1 );

Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );

Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );

Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorBlack ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );

Buy=Cross( ml, sl );

Sell = Cross( sl, ml );

PlotShapes( shapeUpArrow * Buy, colorGreen );

PlotShapes( shapeDownArrow* Sell, colorRed );

AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Sell", 2 );

AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Buy", 2 );

AlertIf( Sell, "", "Sell", 4 );

AlertIf( Buy, "", "Buy", 4 );

 

 

if( Status("action") == actionCommentary )

{

Buy=Cross( ml, sl );

Sell = Cross( sl, ml );

 

 

printf("\nMACD Value: " + WriteVal( ml )+

", Signal Line: " + WriteVal( sl ));

 

printf("\n\nThe MACD can provide buy/sell indications in three ways, signal line crossovers, overbought/oversold conditions, and divergences.\n");

 

 

printf("\n\nCrossovers:\n");

printf("\nCurrently the MACD is "+

WriteIf(MACD() > Signal(),"bullish","bearish")+

" since it is trading "+

WriteIf(MACD() > Signal(),"above","below")+

" its signal line.");

 

 

printf("\nThe MACD crossed "+

WriteIf(MACD() > Signal(),"above","below")+

" its signal line "+

WriteVal( Min( BarsSince( Cross( MACD(), Signal() )), BarsSince( Cross( Signal(), MACD()))), 0.0)+

" period(s) ago.");

 

bars=SelectedValue(Min( BarsSince( Cross( MACD(), Signal() )), BarsSince( Cross( Signal(), MACD())) ));

 

prevclose=Ref(Close,-bars);

 

printf("\nSince the MACD crossed its moving average, "+

Name()+"'s price has "+

WriteIf(Close>prevclose,"increased ","decreased ")+

WriteVal(100*(Close-prevclose)/prevclose) + "%");

 

printf("\nAnd has ranged from a high of "+

WriteVal(HHV(High,bars+1),6.3)+

" to a low of "+

WriteVal(LLV(Low,bars+1),6.3));

 

printf("\n\nOverbought/Oversold:");

Osc = OscP( 12, 26 );

Osc1 = Ref( Osc, -1 );

Osc5 = Ref( Osc, -5 );

 

printf("\n"+WriteIf( Osc <= -3 AND ( Osc - Osc5 ) == -Sum( abs( Osc - Osc1 ), 5 ),

"The MACD is in an oversold range. Prices may continue to move lower for some time.  Wait for prices to move higher before considering any long positions.",

WriteIf( Osc >= 3 AND ( Osc - Osc5 ) ==  Sum( abs( Osc - Osc1 ), 5 ),

"The MACD is in an overbought range.  Prices may continue to move higher for some time.  Wait for prices to move lower before considering any short positions.",

"The MACD is not in an Overbought/Oversold range.")));

 

printf("\n\nDivergence:\n");

temp = Trough(Low, 2, 1) < 0.96 * Ref( Trough(Low, 2, 1), -1) AND ValueWhen( Trough(Low, 2, 1) != Ref( Trough(Low, 2, 1), -1 ), MACD(), 1 ) >= 0.90 * ValueWhen( Trough( Low, 2, 1) != Ref( Trough( Low, 2, 1), -1 ), MACD(), 2 ) AND MACD() < 0;

 

temp2= Peak(  High,2, 1) > 1.04 * Ref( Peak( High, 2, 1), -1) AND ValueWhen( Peak( High, 2, 1) != Ref( Peak( High, 2, 1), -1 ), MACD(), 1 ) <= 0.90 * ValueWhen( Peak(  High, 2, 1) != Ref( Peak(  High, 2, 1), -1 ), MACD(), 2 ) AND MACD() > 0;

 

printf(WriteIf( HHV( temp, 5 ) == 1,"A bullish divergence occurred " + WriteVal( BarsSince( temp ), 1.0 ) +

" period(s) ago. Wait for upward price movement for confirmation before considering any long positions.",

WriteIf( HHV( temp2,5) == 1,

"A bearish divergence occurred " +

WriteVal( BarsSince( temp2 ), 1.0 ) +

" period(s) ago.  Wait for downward price movement for confirmation before considering any short positions.",

"There have been no divergence signals within the last 5 periods." ) ));

 

printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");

}

 

 

Code works great as an indicator and shows the buy sell arrows where I want them.  The trouble is when I do an Automatic Analysis using this code.  I am getting only EOD signals and I guess I was expecting a scan and alert in the output window each time I got a arrow on my 5 minute interval chart as an indicator.  Question I am using the standard edition.  Does it only scan EOD or every minute as the setting allows. Scan Results only show eod.   My research leads me to believe you can do a automatic scan every minute (box is checked).  Can you point me in the correct direction.  I am missing a key concept here.   Perhaps it is resetting the flags?   Again as an indicator it works great and arrows show on Intraday view of the charts. 

 

As a beginner – and because this software is very robust – I am taking it very slow and building on what I have learned – therefore I am enjoying the learning process and this helps prevents frustration.  Thanks. 

 

Scan Results using the above code (guess I was expecting signals on the minute. 

Ticker   Trade    Date      Close   

mot       Buy       12/23/1993         12.19

mot       Sell       2/2/1994             13.66

mot       Buy       2/16/1994           14.11

mot       Sell       2/28/1994           13.79

mot       Buy       3/2/1994             14.32

mot       Sell       3/7/1994             14.16

mot       Buy       3/8/1994             14.40

mot       Buy       4/21/2005           15.89

mot       Sell       6/15/2005           18.10

mot       Buy       6/23/2005           18.87

mot       Sell       6/24/2005           18.55

mot       Buy       7/12/2005           19.27

mot       Sell       8/10/2005           21.39

mot       Buy       8/31/2005           21.88

 

 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS