Hello Ken,
Try this.
I hope this solves your problem , 
_SECTION_BEGIN("TEMA");
P =ParamField("ValueChart",-1);
Periods =Param("Periods", 500, 2, 6000, 1, 10 );
Plot( TEMA( P, Periods ),"Tema", ParamColor("Tema",colorRed),  8  
|styleOwnScale);
 
_SECTION_BEGIN("WMA");
P2 =ParamField("ValueChart",-1);
Periods2 =Param("Periods2", 50, 2, 6000, 1, 10 );
Plot( WMA( P2, Periods ), "Wma", ParamColor("Wma",colorOrange), 8  
|styleOwnScale) ;
_SECTION_END
();
 
UpTrend = WMA( P2, Periods ) > TEMA( P2, Periods2 ); 
DnTrend = WMA ( P2, Periods )< TEMA( P2, Periods2 );
Colors = IIf(UpTrend, colorPaleGreen, IIf(DnTrend, colorRose, colorLightGrey));
Plot(1, "", Colors, styleArea |styleOwnScale |   styleNoLabel, 0, 10);
// this will plot Ribbon .
Thank you

--- In [email protected], Ken H <sfehe...@...> wrote:
>
> 
> Hi
>  
> Can anyone help me with this code sourced from the AFL Library.  
>  
> I am trying to modify it so as to obtain a visual indication of the primary 
> trend (determined by the MA crossover).  When this occurs I would like 
> the background colour to change.
>  
> Many thanks
>  
> Ken
>  
>  
> _SECTION_BEGIN("VChart ");
> //// Vchart
> //This was converted from code created for TradeStation by Mark W. Helweg of 
> ValueCharts. com 
> //Code posted on Amibroker AFL Library
> VarNumbars = Param("Number of Bars",150,2,1000, 1);
> 
> LRange = 0;
> VarP = round(VarNumBars/ 13);
> if (VarNumBars > 8) 
> {
> VarA=HHV(H,VarP) -LLV(L,VarP) ;
> VarR1 = IIf(VarA==0 AND VarP==1,abs( C-Ref(C,- Varp)),VarA) ;
> VarB=Ref(HHV( H,VarP),- VarP+1)-Ref( LLV(L,VarP) ,-VarP);
> VarR2 = IIf(VarB==0 AND VARP==1,abs( Ref(C,-VarP) -Ref(C,-Varp* 2) ),VarB);
> VarC=Ref(HHV( H,VarP),- VarP*2)-Ref( LLV(L,VarP) ,-VarP*2) ;
> VarR3 = IIf(VarC == 0 AND VarP==1,abs( Ref(C,-Varp* 2)-Ref(C, -Varp*3)) 
> ,VarC); 
> VarD = Ref(HHV(H,VarP) ,-VarP*3) -Ref(LLV( L,VarP),- VarP*3);
> VarR4 = IIf(VarD == 0 AND VarP==1,abs( Ref(C,-Varp* 3)-Ref(C, -Varp*4)) 
> ,VarD); 
> VarE = Ref(HHV(H,VarP) ,-VarP*4) -Ref(LLV( L,VarP),- VarP*4);
> VarR5 = IIf(VarE == 0 AND VarP==1,abs( Ref(C,-Varp* 4)-Ref(C, -Varp*5)) 
> ,VarE); 
> LRange=((VarR1+ VarR2+VarR3+ VarR4+VarR5) /5)*.2;
> };
> CDelta = abs(C - Ref(C,-1));
> if (VarNumBars <=7)
> {
> Var0 = IIf(CDelta > (H-L) OR H==L,CDelta, (H-L));
> LRange = MA(Var0,5)*0.2; }
> MidBarAverage = MA( (H+L)/2,VarNumbars) ;
> VOpen = (Open- MidBarAverage) /LRange;
> VHigh = (High-MidBarAverage )/LRange;
> VLow = (Low-MidBarAverage) /LRange; 
> VClose = (Close-MidBarAverage)/LRange; 
> PlotOHLC(VOpen, VHigh,VLow, VClose,"ValueChart",colorBlack, styleBar | 
> styleThick ,-12,12);
> Title= Name() + " " + WriteVal( DateTime(), formatDateTime )+
> "\nVOpen " + VOpen + "\n"+ " VHigh "+ VHigh + "\n"+ " VLow " + Vlow + "\n"+ " 
> VClose " + VClose;
> Plot( 9,"",colorBlue, styleLine, 1);
> Plot( -9,"",colorBlue| styleLine + 8, 1);
> Plot( 0,"",colorLightGrey, styleLine, 1);
>  
> _SECTION_BEGIN("TEMA");
> P = ParamField("ValueChart",-1);
> Periods = Param("Periods", 500, 2, 6000, 1, 10 );
> Plot( TEMA( P, Periods ),_DEFAULT_NAME(), colorRed, styleThick + 8 ); 
>  
> _SECTION_BEGIN("WMA");
> P = ParamField("ValueChart",-1);
> Periods = Param("Periods", 50, 2, 6000, 1, 10 );
> Plot( WMA( P, Periods ), _DEFAULT_NAME(), colorRed, styleThick + 8 ) ; 
> _SECTION_END();
>  
> UpTrend = WMA > TEMA; DnTrend = WMA < TEMA; 
> Colors = IIf(UpTrend, colorPaleGreen, IIf(DnTrend, colorRose, 
> colorLightGrey)); 
> Plot(1, "", Colors, styleOwnScale | styleArea | styleNoLabel, 0, 1, 0, -1);
>


Reply via email to