Simple Coding Help - No Promise.

BELOW CODE NOT WORKING PLZ SOLVE THIS PROBLEM


SetChartOptions(0,chartShowArrows|chartShowDates);
bk=ParamColor( "Bk col",ColorRGB(85,90,60));
SetChartBkColor(bk);

amount = Param("Sensitivity", 0.5, 0.1, 2, 0.1 );

array = C ;
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );

tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
PU = tr + 0.01 * abs(tr)*amount;
PD = pk - 0.01 * abs(pk)*amount;

ZZT = IIf( array >= PU AND zz0 > zz1, 1,
IIf( array <= PD AND zz0 < zz1, -1, 0 ) );

ZZT = ValueWhen( ZZT != 0, ZZT );

Buy_Valid_=zzt>0;
Sell_Valid_=zzt<0;
Buy_Valid = ExRem(Buy_Valid_,Sell_Valid_);
Sell_Valid = ExRem(Sell_Valid_,Buy_Valid_);
Plot(Ref(Buy_valid,0),"",ColorRGB(0,0,100),styleHi stogram|styleDashed|styleOwnScale|styleNoLabel,0,0 ,0,-1);
Plot(Ref(Sell_valid,0),"",ColorRGB(100,0,0),styleH istogram|styleDashed|styleOwnScale|styleNoLabel,0, 0,0,-1);

Candlecol=IIf(BarsSince(Buy_Valid)<BarsSince(Sell_ Valid) AND BarsSince(Buy_Valid)!=0,5,
IIf(BarsSince(Buy_Valid)>BarsSince(Sell_Valid) AND BarsSince(Sell_Valid)!=0,4,1));
cc1=IIf(Buy_valid,colorYellow,IIf(Sell_valid,color Black,Candlecol));
SetBarFillColor(Cc1);
Plot(C,"Cas-S_D-Zone",Cc1,64,0,0,0,0);

pk=BarsSince(Buy_Valid)<BarsSince(Sell_Valid) ;//AND BarsSince(Buy_Valid)!=0;//Zz>Ref(zz,-1);
tr=BarsSince(Buy_Valid)>BarsSince(Sell_Valid) ;//AND BarsSince(Sell_Valid)!=0;//Zz<Ref(zz,-1);

Ll=LowestSince(sell_valid,L,1);
hH=HighestSince(Buy_Valid,H,1);
Llm=LowestSince(sell_valid,Min(O,C),1);
hHm=HighestSince(Buy_Valid,Max(O,C),1);

xx=Cum(1);
NoLines = Param("No of Lines",5,1,10,1);

Col2=ParamColor( "Res Color", colorRed );
Col1=ParamColor( "Sup Color", colorGreen );

for( i = 1; i < NoLines+1 ; i++ )
{
scol=ColorBlend(Col1,2,0.1*i);
rcol=ColorBlend(Col2,2,0.1*i);

px1 = LastValue(ValueWhen(Buy_valid,Cum(1),i)) ;
py1 = LastValue(ValueWhen(Buy_valid,Ll,i)) ;
pz1 = LineArray(px1, py1, (BarCount-1), py1);
Plot(pz1,"",scol,32);

tx1 = LastValue(ValueWhen(sell_valid,Cum(1),i)) ;
ty1 = LastValue(ValueWhen(sell_valid,Hh,i)) ;
tz1 = LineArray(tx1, ty1, (BarCount-1), ty1);
Plot(tz1,"",rcol,32);

px1m = LastValue(ValueWhen(Buy_valid,Cum(1),i)) ;
py1m = LastValue(ValueWhen(Buy_valid,Llm,i)) ;
pz1m = LineArray(px1m, py1m, (BarCount-1), py1m);
PlotOHLC(pz1,pz1,pz1m,pz1m,"",scol,styleCloud|styl eNoLabel,0,0,0,-i-nolines);

tx1m = LastValue(ValueWhen(sell_valid,Cum(1),i)) ;
ty1m = LastValue(ValueWhen(sell_valid,Hhm,i)) ;
tz1m = LineArray(tx1m, ty1m, (BarCount-1), ty1m);
PlotOHLC(tz1,tz1,tz1m,tz1m,"",rcol,styleCloud|styl eNoLabel,0,0,0,-i-nolines);
}

for( j = 0; j < BarCount; j++ )
{
if( Buy_valid [j]) PlotText( "Tr\n"+Ll[ j ], j, Ll[j], colorPaleGreen );
if( Sell_valid[j] ) PlotText( "Pk\n"+Hh[ j ], j, Hh[j], colorRose);
}


experts in afl please give correct afl for this.
anjanbm
 

amitrandive

Well-Known Member
BELOW CODE NOT WORKING PLZ SOLVE THIS PROBLEM


SetChartOptions(0,chartShowArrows|chartShowDates);
bk=ParamColor( "Bk col",ColorRGB(85,90,60));
SetChartBkColor(bk);

amount = Param("Sensitivity", 0.5, 0.1, 2, 0.1 );

array = C ;
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );

.
.
.
experts in afl please give correct afl for this.
anjanbm
Code is working perfectly.
Just remove the extra spaces where not required.
 
amitrandive,
Thanks for your reply, I am not getting black and yellow candle in my ami.
I am getting like this.


not getting like the one below afl

anjanbm
 

amitrandive

Well-Known Member
amitrandive,
Thanks for your reply, I am not getting black and yellow candle in my ami.
I am getting like this.


not getting like the one below afl

anjanbm
Please check your settings.
There is also a setting for background colour.

The black candle may not be visible due to the black background
I am getting the same chart image as the one you have posted below.

 
Hai Seniors and experts
Can any coder help to make AFL in which --
when MACD signal line crosses zero line from below it turns into bright green
and also a up bright green arrow is shown as buy signal .

Similarly when MACD signal line crosses zero line from above it turns in to red and also a down red arrow is shown as sell signal .
That will be a great help .
thanks a lot in advance.
 

amitrandive

Well-Known Member
Hai Seniors and experts
Can any coder help to make AFL in which --
when MACD signal line crosses zero line from below it turns into bright green
and also a up bright green arrow is shown as buy signal .

Similarly when MACD signal line crosses zero line from above it turns in to red and also a down red arrow is shown as sell signal .
That will be a great help .
thanks a lot in advance.
http://www.wis estockt rader.com/indicators/1100-coloured-macd
(Remove spaces)
 

amsin21

Well-Known Member
I am looking for help to code the below criteria. Aiming to keep the chart screen less clutter.

Defaults

Up candle = Green
Down candle = Red
EMA 3 = Teal
EMA 15 = DarkOrange
Cross candle = Cyan

EMA parameters should be able to toggle (hidden) from the screen itself.

Criteria

1) EMA3 cross EMA15
2) When ever cross happens, cross candle color changes

Experts please.

Regards
Code:
ea = EMA (C,3);
eb = EMA (C,15);
SetBarFillColor( IIf( ea > eb, colorGreen, colorRed ) );
Plot( C, "Price", IIf( ea > eb, colorGreen, colorRed ), styleCandle );
Plot( ea, "ema3", colorTeal, styleThick ); 
Plot( ea, "ema3", colorDarkOrange, styleThick ); 



Buy = ea > eb ;
Sell = ea < eb;

PlotShapes(Buy*shapeUpArrow,colorblue,0,L,-33);
PlotShapes(Sell*shapeDownArrow,colorRed,0,L,-33);
Thanks Nehal for the AFL. As said I want the color change of the candle instead of plotting the up/down arrows. Also the parameters (like show/hide EMAs, incase reqd) should be able to change from the screen. This takes away the need of EMAs and arrows off the chart, keeping it simple.
Please any experts. Only MA cross candle color needs to be changed.
 

Similar threads