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

Re: [amibroker] candle color, price and macd


  • Date: Thu, 24 Dec 2009 15:11:56 +0100
  • From: reinsley <reinsley@xxxxxxxx>
  • Subject: Re: [amibroker] candle color, price and macd

PureBytes Links

Trading Reference Links

It works fine under 5.29.2
I re-post the code but I don't know v4.80

Maybe try to load the buil-in MACD v4.80 and see the code

Best regards

// Macd Rising Falling Two Colors
// adapted by reinsley
// blank bars show no cross signal

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

mm = MACD( r1, r2 );
ms = Signal( r1, r2, r3 );
mh = mm - ms;
mcol = IIf( mh > Ref( mh, -1 ), IIf( mh > 0, 27, 27 ), IIf( mh > 0, 32, 
32 ) );// 27 43 11 32

Plot( mm, StrFormat( _SECTION_NAME() + "(%g,%g)", r1 , r2 ), 29, 4 );
Plot( ms, " Signal" + _PARAM_VALUES(), 32 );
Plot( mh, "MACDHistogram", mcol, 6 | styleNoTitle | 4096 );//32768|
Plot( mh, "MACDHistogram", mcol, 5 | styleNoTitle | 4096 ); //32768|

lastbar0 = Ref( mh, 0 ) > Ref( mh, - 1 )AND mh >= 0 ;
lastbar1 = Ref( mh, - 1 ) < Ref( mh, - 2 )AND mh >= 0 ;
lastbar2 = Ref( mh, - 2 ) < Ref( mh, - 3 )AND mh >= 0 ;
lastbar3 = Ref( mh, - 3 ) < Ref( mh, - 4 )AND mh >= 0 ;

signocrossup = IIf( lastbar0 AND lastbar1 AND lastbar2 AND lastbar3 ,
                     1, 0 );
barcolorup = IIf( signocrossup, 2, 1 );

lastbardn0 = Ref( mh, 0 ) < Ref( mh, - 1 )AND mh <= 0 ;
lastbardn1 = Ref( mh, - 1 ) > Ref( mh, - 2 )AND mh <= 0 ;
lastbardn2 = Ref( mh, - 2 ) > Ref( mh, - 3 )AND mh <= 0 ;
lastbardn3 = Ref( mh, - 3 ) > Ref( mh, - 4 )AND mh <= 0 ;

signocrossdown = IIf( lastbardn0 AND lastbardn1 AND lastbardn2 AND
                       lastbardn3 , 1, 0 );
barcolordn = IIf( signocrossdown, 2, 1 );

Graph2BarColor = IIf ( signocrossup, barcolorup, IIf( signocrossdown,
                        barcolordn, mcol ) );

//11 mauve //27 green //43 bright green //32 red



Le 24/12/2009 14:19, Asis Ghosh a écrit :
> // Macd Rising Falling Two Colors
> // adapted by reinsley
> // blank bars show no cross signal
>
> r1 = Param( "Fast avg", 12, 2, 200, 1 );
> r2 = Param( "Slow avg", 26, 2, 200, 1 );
> r3 = Param( "Signal avg", 9, 2, 200, 1 );
>
> mm = MACD(r1, r2);
> ms = Signal(r1, r2, r3);
> mh = mm-ms;
> mcol= IIf(mh>Ref(mh,-1),IIf(mh > 0,27,27),IIf(mh > 0,32,32));// 27 43 11 32
>
> Plot(mm,StrFormat(_SECTION_NAME()+"(%g,%g)", r1 ,r2),29,4);
> Plot(ms," Signal" + _PARAM_VALUES(),32);
> Plot(mh,"MACDHistogram",mcol,6|styleNoTitle|4096);//32768|
> Plot(mh,"MACDHistogram",mcol,5|styleNoTitle|4096); //32768|
>
> lastbar0 = Ref( mh, 0 ) > Ref( mh, - 1 )AND mh >= 0 ;
> lastbar1 = Ref( mh, - 1 ) < Ref( mh, - 2 )AND mh >= 0 ;
> lastbar2 = Ref( mh, - 2 ) < Ref( mh, - 3 )AND mh >= 0 ;
> lastbar3 = Ref( mh, - 3 ) < Ref( mh, - 4 )AND mh >= 0 ;
>
> signocrossup = IIf( lastbar0 AND lastbar1 AND lastbar2 AND lastbar3 ,
> 1, 0 );
> barcolorup = IIf( signocrossup, 2, 1 );
>
> lastbardn0 = Ref( mh, 0 ) < Ref( mh, - 1 )AND mh <= 0 ;
> lastbardn1 = Ref( mh, - 1 ) > Ref( mh, - 2 )AND mh <= 0 ;
> lastbardn2 = Ref( mh, - 2 ) > Ref( mh, - 3 )AND mh <= 0 ;
> lastbardn3 = Ref( mh, - 3 ) > Ref( mh, - 4 )AND mh <= 0 ;
>
> signocrossdown = IIf( lastbardn0 AND lastbardn1 AND lastbardn2 AND
> lastbardn3 , 1, 0 );
> barcolordn = IIf( signocrossdown, 2, 1 );
>
> Graph2BarColor = IIf ( signocrossup, barcolorup, IIf( signocrossdown,
> barcolordn, mcol ) );
>
> //11 mauve //27 green //43 bright green //32 red


-- 
Best regards


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

**** 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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/