AFL help needed to plot lines

casoni

Well-Known Member
#33
Hello everyone,

Finally we have the code ,

Many Many Thanks to Edward Pottasch , for taking out his precious time and coded this concept

Here's the code
this code looks into future , but Buy,short decission is based on Peak / trough levels , and they get plotted, after they are confirmed . [ so Signals will not change ]

* Buy/short signals are pending






//=======================================================

SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1),1,50,1);
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1),1,50,1);

function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}

pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);


SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,null,null,0,0,1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>rightStrength,ColorRGB(0,100,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>rightStrength,ColorRGB(255,0,0),colorWhite),0,H,10);

pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1));
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1));
pkHigh0=ValueWhen(pk,H,0);
trLow0=ValueWhen(Tr,L,0);

upGap=Cross(C,pkHigh1) AND pkHigh1<trLow0;
dnGap=Cross(trLow1,C) AND trLow1>pkHigh0;

gapBaseUp=ValueWhen(upGap,pkHigh1);
gapBaseDn=ValueWhen(dnGap,trLow1);
gapExtrUp=ValueWhen(upGap,trLow0);
gapExtrDn=ValueWhen(dnGap,pkHigh0);

upGapArea=Flip(upGap,dnGap);
dnGapArea=Flip(dnGap,upGap);

gapBase=IIf(upGapArea,gapBaseUp,gapBaseDn);
gapExtr=IIf(upGapArea,gapExtrUp,gapExtrDn);

Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1);
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1);
Plot(gapBase,"",colorlightgrey,styledashed,Null,Null,0,2,1);
Plot(gapExtr,"",colorlightgrey,styledashed,Null,Null,0,2,1);
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(gapExtr>gapBase,colorseaGreen,colorOrange),styleCloud|styleNoRescale,Null,Null,0,-1,1);


strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
Title = EncodeColor(colorWhite)+ "Gap _ST style by Edward.P" + " - " + Name() + " - "+ "" + fullName() + " " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +" - " + Date() + " # "+strWeekday +
StrFormat("\nOp %g, Hi %g, Lo %g, Cl %g, Vol %g", O, H, L, C, V)+
"\nRight Bars: " + rightStrength +
"\nLeft Bars : " + leftStrength;

//============================================

Kindly post your views

Thank you
 
#34
Thanks Casoni for the code.

There are some errors, Error 16 Too many arguments
in line and col
31 - 95
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,Null,Null,0,0,1);
54 - 44
Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1);
55 - 42
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1);
56 - 58
Plot(gapBase,"",colorLightGrey,styleDashed,Null,Null,0,2,1);
57 - 58
Plot(gapExtr,"",colorLightGrey,styleDashed,Null,Null,0,2,1);
58 - 113
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(gapExtr>gapBase,colorSeaGreen,colorOrange),styleCloud|styleNoRescale,Null,Null,0,-1,1);

How to remove these errors.
Thanks
 

amitrandive

Well-Known Member
#35
Hello everyone,

Finally we have the code ,

Many Many Thanks to Edward Pottasch , for taking out his precious time and coded this concept

Here's the code
this code looks into future , but Buy,short decission is based on Peak / trough levels , and they get plotted, after they are confirmed . [ so Signals will not change ]

* Buy/short signals are pending






//=======================================================

SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1),1,50,1);
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1),1,50,1);

function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}

pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);
.
.
//============================================

Kindly post your views

Thank you
Casoni,Mastermind,Raghuveer

Hats off to all of you !!!
:clapping::clapping::clapping:
 

laotze

Active Member
#36
Hello everyone,

Finally we have the code ,

Many Many Thanks to Edward Pottasch , for taking out his precious time and coded this concept

Here's the code
this code looks into future , but Buy,short decission is based on Peak / trough levels , and they get plotted, after they are confirmed . [ so Signals will not change ]

* Buy/short signals are pending






//=======================================================

SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1),1,50,1);
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1),1,50,1);

function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}

pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);


SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,null,null,0,0,1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>rightStrength,ColorRGB(0,100,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>rightStrength,ColorRGB(255,0,0),colorWhite),0,H,10);

pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1));
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1));
pkHigh0=ValueWhen(pk,H,0);
trLow0=ValueWhen(Tr,L,0);

upGap=Cross(C,pkHigh1) AND pkHigh1<trLow0;
dnGap=Cross(trLow1,C) AND trLow1>pkHigh0;

gapBaseUp=ValueWhen(upGap,pkHigh1);
gapBaseDn=ValueWhen(dnGap,trLow1);
gapExtrUp=ValueWhen(upGap,trLow0);
gapExtrDn=ValueWhen(dnGap,pkHigh0);

upGapArea=Flip(upGap,dnGap);
dnGapArea=Flip(dnGap,upGap);

gapBase=IIf(upGapArea,gapBaseUp,gapBaseDn);
gapExtr=IIf(upGapArea,gapExtrUp,gapExtrDn);

Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1);
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1);
Plot(gapBase,"",colorlightgrey,styledashed,Null,Null,0,2,1);
Plot(gapExtr,"",colorlightgrey,styledashed,Null,Null,0,2,1);
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(gapExtr>gapBase,colorseaGreen,colorOrange),styleCloud|styleNoRescale,Null,Null,0,-1,1);


strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
Title = EncodeColor(colorWhite)+ "Gap _ST style by Edward.P" + " - " + Name() + " - "+ "" + fullName() + " " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +" - " + Date() + " # "+strWeekday +
StrFormat("\nOp %g, Hi %g, Lo %g, Cl %g, Vol %g", O, H, L, C, V)+
"\nRight Bars: " + rightStrength +
"\nLeft Bars : " + leftStrength;

//============================================

Kindly post your views

Thank you

Nice contribution to forum......:clap::clap::clap:
 

rrrajguru

Well-Known Member
#37
@ Casoni

Bro, thanks for your contribution.

I am using Ami 5.50 and getting below error. Is it possible to change the code a little, so that i can use it in ami ver 5.50 ?





Thanks.
 
#39
plot as this



actually the last part of the plot is supported in higher version of ami

rgds and thanx
Thanks bro

Beside that line, the following lines are also showing error.

Code:
Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1); 
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1); 
Plot(gapBase,"",colorlightgrey,styledashed,Null,Null,0,2,1); 
Plot(gapExtr,"",colorlightgrey,styledashed,Null,Null,0,2,1); 
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(ga pExtr>gapBase,colorseaGreen,colorOrange),styleClou d|styleNoRescale,Null,Null,0,-1,1);
Please suggest some solution for this also.

Thanks
 
Last edited:

mastermind007

Well-Known Member
#40
Casoni,Mastermind,Raghuveer

Hats off to all of you !!!
:clapping::clapping::clapping:
Casoni has done most of the work so he deserves the credit....
 

Similar threads