You are correct, there are no style options similar to the PlotColor options
and a work around is required. Don't even pretend to understand why the
capability isn't there: I wasted a lot of time trying to make it work.
Often,the suggested solution results (with volatile indicators) in rather
choppy charts (Solution 3).   

Therefore, I typically made two changes (Preferred Solution 2):

1. The most continuous style(e.g. solid) is plotted first, followed by the
interrupted (e.g. dotted, dashed)line. This gives a less ragged appearance.

2. In the 2nd plot the Null condition is replaced by the plot value  (as
compared to Solution 3)

 

Realistically, the best solution (as usual) is the simplest one: Don't use
style changes and stick with using Plotcolor changes ((Preferred Solution 1)

 

The only rational for using style changes is when publishing in black and
white or printing out on a B/W printer. Even then by carefully selecting the
plotting colors one can often achieve very good results using PlotColor
conditions.  

Below the afl that demonstrates the three options for a MA and MASlope. Just
toggle between "Display Preferred Solution" and "Dual/Single Plot" to see
the differences.

 

Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 

{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );

       

PrefSol=ParamToggle("Display Preferred Solution","No|Yes",1);// Default:
manual

Dual_Single_Plot=ParamToggle("Dual|Single Plot","Dual|Single",0);// Default:
manual

//MA14Shift=Param("MA14Shift-PlotColor",0.00003,0,1,0.00001);//Forex values

MA14Shift=Param("MA14Shift-PlotColor",3,0,10,1)/100000;//Forex values

MASlopeShift=Param("MASlopeShift-PlotColor",3,0,10,1)/100000;//Forex values

MA14=MA(C,14);

MASlope= MA(C,14)-MA(Ref(C,-1),14);

PlotColor=IIf(MASlope<=0,colorGreen,4);

 

//========Preferred Solution 1:PlotColor only========================

if(PrefSol)

{

Plot(MA14+MA14Shift,"\nMA14 With PlotColor", PlotColor,
styleLeftAxisScale|styleThick); //typically the best solution

Plot(MASlope+MASlopeShift, "MASlope With PlotColor", PlotColor,
styleThick);//===========Different Styles===========

}

//========Preferred Solution 2: Continuous Lines; Preferred Solution: Less
discontinuity========================

Plot(IIf(MASlope> 0, MA14,Null ), "\nMA14 - MASlope Pos", PlotColor,
styleLeftAxisScale|styleThick);

Plot(IIf(MASlope> 0, MASlope, Null), "MASlope Pos", colorViolet,
styleThick);

Plot(0,"",1,5);

if(!Dual_Single_Plot) //Continuous Lines; 

{

Plot(IIf(MASlope<= 0, MA14, MA14), "\nMA14 - MASlope Neg", PlotColor,
styleLeftAxisScale|styleDashed); //Null replaced by value

Plot(IIf(MASlope<= 0, MASlope,MASlope), "MASlope Neg", colorBlue,
styleDashed); //Null replaced by value

}

//========Solution 3: Discontinous Lines========================

else  

{

Plot(IIf(MASlope<= 0, MA14, Null), "\nMA14 - MASlope Neg", PlotColor,
styleLeftAxisScale|styleDashed);

Plot(IIf(MASlope<= 0, MASlope, Null), "MASlope Neg", colorBlue,styleDashed);

}

 

 From: [email protected] [mailto:[email protected]] On
Behalf Of Mike
Sent: Sunday, December 06, 2009 7:35 PM
To: [email protected]
Subject: [amibroker] Re: How do you plot dashed and solid line on same
variable

 

  

Looks like Plot only accepts a scaler for the style argument. So, just split
the charting in two:

trix9 = Trix(9);
Plot(IIF(trix9 > 0, trix9, null), "Trix", colorGreen, styleThick);
Plot(IIF(trix9 <= 0, trix9, null), "Trix", colorRed, styleDashed);

Mike

--- In [email protected] <mailto:amibroker%40yahoogroups.com> ,
"Marty J" <prog...@...> wrote:
>
> I would like to plot a dashed line and solid line on the same variable.
> 
> For example if Trix(9) > 0 then styleThick 
> and if Trix(9) < 0 then StyleDashed 
> 
> 
> Thanks
>



Reply via email to