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

[amibroker] Re: What am I doing wrong here?



PureBytes Links

Trading Reference Links

Gerard
I'm not totally clear as to what you want, but if this describes 
what you are after then the following AFL will do this.
Description - If we treat your 2 conditions as Cond1 and Cond2, is 
what you want this? If cond1 and cond2 are up - colorgreen, if cond1 
and cond2 are down - colorred, if previous bar was colorgreen and 
either cond turns down - colorred, if previous bar was colorred and 
either condition turns up - colorgreen.  If this is what you want 
then try

down = MACD()<Signal() AND MA(C,5)<MA(MA(C,5),7);
up = MACD()>Signal() AND MA(C,5)>MA(MA(C,5),7);
Color = IIf(down,colorRed,IIf(Up,colorGreen, IIf(BarsSince(up)
>BarsSince(down),colorGreen,colorRed))); 
Plot(10,"ribbon",Color, styleOwnScale|styleArea|styleNoLabel, -0.5, 
100 );

This type of code will give you increased whipsaws as either 
condition changing changes color of ribbon.  More informative is to 
perhaps introduce a third intermediate state where the 2 conditions 
don't agree.  This would enable you to enter positions when both 
conditions are in agreement, but exit if either condition changes.

down = MACD()<Signal() AND MA(C,5)<MA(MA(C,5),7);
up = MACD()>Signal() AND MA(C,5)>MA(MA(C,5),7);
Color = IIf(down,colorRed,IIf(Up,colorGreen, colorYellow)); 
Plot(10,"ribbon",Color, styleOwnScale|styleArea|styleNoLabel, -0.5, 
100 );

Even more informative is to "stack the ribbons".  By plotting 
successive ribbons at increased widths, we can stack the ribbons so 
as to see the state of each Cond separately and then the overall 
state. The 3 ribbons are separated by a black "separator" line 
(cosmetic only).

// cond1 ribbon
Plot(5,"Cond1", IIf( MACD()<Signal(), colorRed, colorGreen
),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot(6,"",1,styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

// Cond2 ribbon
Plot(11,"Cond2", IIf( MA(C,5)<MA(MA(C,5),7),
colorRed, colorGreen), styleOwnScale|styleArea|styleNoLabel, -0.5, 
100 );
Plot(12,"",1,styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

// overall ribbon
down = MACD()<Signal() AND MA(C,5)<MA(MA(C,5),7);
up = MACD()>Signal() AND MA(C,5)>MA(MA(C,5),7);
Color = IIf(down,colorRed,IIf(Up,colorGreen, colorYellow)); 
Plot(20,"Overall Ribbon",Color, 
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); 

Hope this helps
Andrew

--- In amibroker@xxxxxxxxxxxxxxx, "gerard_carey" <gcfinance@xxxx> 
wrote:
> Thanks for your efforts,
> Unfortunately the plot is still not agreeing with the intention of 
> the formula.
> eg. Sometimes the macd will cross up thru the signal line but the 
> plot color will not change to green until the MA crosses a few 
bars 
> later.
> I'm going crosseyed and crossbrained.
> Think I'll give it a rest for a while.
> Thanks again and Regds
> Gerard
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mr Valley" <valleymj@xxxx> 
wrote:
> try this
>  
> /* MA Test */
> MA5 = MA(C,5);
> 
> MA7 = MA5 < MA(MA5,7);
> 
> xx = IIf(MA5 < MA(MA5,7), MA5, MA7);
>  
> Plot(12.5,"ribbon", IIf( MACD()<Signal() OR xx , colorRed,
> colorGreen ),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
> 
> Mr Valley
>  
> -----Original Message-----
> From: gerard_carey [mailto:gcfinance@x...]
> Sent: Monday, December 01, 2003 8:41 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: What am I doing wrong here?
> > 
> > 
> >   Hi Graham,
> > 
> >   In its 'current' form it is a trend indicator based on the 
MACD 
> that
> >   plots along the bottom of the pane. Green for an uptrend when 
the
> >   MACD is above its Signal line, or red when it is below.
> >   I wish to include it in the built 'Price' indicator, no 
problems
> >   there.
> >   I wish to include a further condition;
> >   MA(C,5)<MA(MA(C,5),7)
> >   so that either of the conditions would trigger the colour 
change.
> >   Thats my problem.
> > 
> >   I hope this clarifies the situation.
> >   Thanks and Regds
> >   Gerard
> > 
> >   --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> 
wrote:
> > 
> >   Gerard, what are you trying to accomplish?
> > 
> >   The plot gives me a plot with red and green areas.
> > 
> >   Cheers,
> >   Graham
> >   http://groups.msn.com/ASXShareTrading
> >   http://groups.msn.com/FMSAustralia
> > 
> >   -----Original Message-----
> >   From: Gerard Carey [mailto:gcfinance@x...]
> >   Sent: Tuesday, 2 December 2003 10:49 AM
> >   To: AB Yahoo group
> >   Subject: [amibroker] What am I doing wrong here?
> > 
> > 
> >   I'm trying to add the moving average condition, MA(C,5)<MA(MA
> >   (C,5),7), to
> >   the following formula.
> >   >
> >   > Plot(2.5,"ribbon", IIf( MACD()<Signal(), colorRed, colorGreen
> >   > ),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
> >   >
> >   > My efforts, one of which follows are so far to no avail. Plot
> >   (2.5,"ribbon",
> >   > IIf( MACD()<Signal() OR MA(C,5)<MA(MA(C,5),7), colorRed,
> >   colorGreen),
> >   > styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
> >   >
> >   > What am I doing wrong here?
> >   > I'd appreciate any help
> >   > Regds Gerard
> >   >
> >   > --
> >   > http://www.fastmail.fm - mmm... Fastmail...
> >   >
> >   > ------------------------ Yahoo! Groups Sponsor --------------
---
> ----
> >   ~--> Buy
> >   > Ink Cartridges or Refill Kits for your HP, Epson, Canon or 
> Lexmark
> >   Printer
> >   > at MyInks.com. Free s/h on orders $50 or more to the US & 
> Canada.
> >   > http://www.c1tracking.com/l.asp?cid=5511
> >   > http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
> >   > -------------------------------------------------------------
---
> ----
> >   -~->
> >   >
> >   > Send BUG REPORTS to bugs@xxxx
> >   > Send SUGGESTIONS to suggest@xxxx
> >   > -----------------------------------------
> >   > Post AmiQuote-related messages ONLY to: 
amiquote@xxxxxxxxxxxxxxx
> >   > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> >   > --------------------------------------------
> >   > Check group FAQ at:
> >   > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >   >
> >   > Your use of Yahoo! Groups is subject to
> >   http://docs.yahoo.com/info/terms/
> > 
> > 
> >         Yahoo! Groups Sponsor
> > 
> > 
> > 
> >   Send BUG REPORTS to bugs@xxxx
> >   Send SUGGESTIONS to suggest@xxxx
> >   -----------------------------------------
> >   Post AmiQuote-related messages ONLY to: 
amiquote@xxxxxxxxxxxxxxx
> >   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> >   --------------------------------------------
> >   Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > 
> >   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
> Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/