please help with this afl

#1
Dear seniors
I need color changing of the line in this afl
When uptrend color green
when downtrend color red
AFL is below


_SECTION_BEGIN("ZIG-ZAG");
Z=Param("zig",1,0,10,0.1);
Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), ParamColor("Zig-zag color", colorOrange ), ParamStyle("Zig-zag style") );

Buy = Cover = Zig(C,z)>Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)>Ref(Zig(C,z),-1);
Sell = Short = Zig(C,z)<Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)<Ref(Zig(C,z),-1);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
AlertIf( Buy, "SOUND E:\\Windows\\Media\\notify.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND E:\\Windows\\Media\\chord.wav", "Audio alert", 2 );

Filter = Buy OR Sell;

PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorGreen, 0,BuyPrice, 0);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorRed, 0,SellPrice, 0);

dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "BUY\n"+C[ i ], i, BuyPrice-dist,colorWhite, colorGreen );
if( Sell ) PlotText( "SELL\n"+C[ i ], i, SellPrice+dist,colorWhite, colorRed );
//if( Short ) PlotText( "Short\n@" + C[ i ], i, H[ i ]+dist, colorRed, colorYellow );
//if( Cover ) PlotText( "Cover\n@" + C[ i ], i, L[ i ]-dist,colorGreen );
}

Thanks in advance
 

ocil

Well-Known Member
#2
Beware :- Zig repaint the signal. Be careful...
Dear seniors
I need color changing of the line in this afl
When uptrend color green
when downtrend color red
AFL is below


_SECTION_BEGIN("ZIG-ZAG");
Z=Param("zig",1,0,10,0.1);
Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), ParamColor("Zig-zag color", colorOrange ), ParamStyle("Zig-zag style") );

Buy = Cover = Zig(C,z)>Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)>Ref(Zig(C,z),-1);
Sell = Short = Zig(C,z)<Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)<Ref(Zig(C,z),-1);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
AlertIf( Buy, "SOUND E:\\Windows\\Media\\notify.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND E:\\Windows\\Media\\chord.wav", "Audio alert", 2 );

Filter = Buy OR Sell;

PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorGreen, 0,BuyPrice, 0);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorRed, 0,SellPrice, 0);

dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "BUY\n"+C[ i ], i, BuyPrice-dist,colorWhite, colorGreen );
if( Sell ) PlotText( "SELL\n"+C[ i ], i, SellPrice+dist,colorWhite, colorRed );
//if( Short ) PlotText( "Short\n@" + C[ i ], i, H[ i ]+dist, colorRed, colorYellow );
//if( Cover ) PlotText( "Cover\n@" + C[ i ], i, L[ i ]-dist,colorGreen );
}

Thanks in advance
 
#3
I don't know what the purpose you have. Maybe you are using it to test the strength of another system, but....

It seems that the formula references FUTURE quotes.
If you backtest this system you may receive outstanding results
that CAN NOT be reproduced in real trading.
But here:
Code:
Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), IIf ( z1 > Ref ( z1 , -1 ), colorGreen, colorRed ) , ParamStyle("Zig-zag style") );
Simple.