Is is possible to automatically to add a study on the trendline?

Hi, guys

I know there are ways to detect the study crossover for multiple symbols with the use of Scan loke the link. I have to manully draw a trendline.How can I atuomaticlly add a study on the trendline I create with Linearry? Thanks.

[(AmiBroker Knowledge Base » How to detect the study crossover for multiple symbols with use of SCAN)]

You can draw a trendline using Plot() function or MoveTo/LineTo programmatically. Just use GOOGLE, it answers all questions. Type "AmiBroker trendline" into google.

1 Like
_SECTION_BEGIN("Pattern Recognition with Shading");


//Pattern Recognition graph with shading

/*TRENDLINES BREAKOUT*/


x = Cum(1);

per = Param("Percent",3,1,5,1);

s1=L;

s11=H;

pS = TroughBars( s1, per, 1 ) == 0;

endt= LastValue(ValueWhen( pS, x, 1 ));

startt=LastValue(ValueWhen( pS, x, 2 ));

endS = LastValue(ValueWhen( pS, s1, 1 ) );

startS = LastValue( ValueWhen( pS, s1, 2 ));

dtS =endt-startt;

aS = (endS-startS)/dtS;

bS = endS;

trendlineS = aS * ( x -endt ) + bS;

 

pR = PeakBars( s11, per, 1 ) == 0;

endt1= LastValue(ValueWhen( pR, x, 1 ));

startt1=LastValue(ValueWhen( pR, x, 2 ));

endR = LastValue(ValueWhen( pR, s11, 1 ) );

startR = LastValue( ValueWhen( pR, s11, 2 ));

DTR=ENDT1-STARTT1;

aR = (endR-startR)/dtR;

bR = endR;

trendlineR = aR * ( x -endt1 ) + bR;

BEGIN=Min(STARTT,STARTT1);

TRS = IIf(x>BEGIN-10,trendlineS,-1e10);

TRR = IIf(x>BEGIN-10,trendlineR,-1e10);

 

Condcolor=(Cross(C,trendlineR) AND X>ENDT1) OR (Cross(trendlineS,C) AND

X>ENDT);

BarColor=IIf(Condcolor,7,1);

Plot(C,"Close",BarColor,styleCandle); 

Plot(TRS,"Support",colorDarkGrey,styleLine);

Plot(TRR,"Resist",colorDarkGrey,styleLine);

/////////////////////////////////////

// Shading // 

////////////////////////////////////

fill=Param("style",2,1,2,1);

style=IIf(fill==1,styleHistogram,IIf(fill==2,styleArea,Null));

x=IIf(trs > trr,trr,trs);

Plot(x,"",colorLightGrey,style);

Plot(trr,"",colorLightGrey,style);

////////////////////////////////////////////

// Pattern Recognition in title bar // 

///////////////////////////////////////////


Lowline=Ends-starts;

Highline=endr-startr;

Wedge=IIf(Highline <0 AND Lowline > 0,1,0);

DecendingTriangle=IIf(Highline < 0 AND Lowline==0,1,0);

AscendingTriangle=IIf(Highline==0 AND Lowline > 0,1,0);

DownChannel=IIf(Highline<0 AND Lowline<0,1,0);

UpChannel=IIf(Highline>0 AND Lowline>0,1,0);

BroadeningWedge=IIf(Highline > 0 AND Lowline < 0,1,0);

///////////////////////////////////

// Bullish or Bearish breakout //

//////////////////////////////////

BullishBreakout=Cross(C,trendlineR);

BearishBreakout=Cross(trendlineS,C);

 

Title=Name()+ WriteIf(wedge==1," Wedge","")+WriteIf(DecendingTriangle==1," Decending Triangle","")+WriteIf(AscendingTriangle==1,"Ascending Triangle","")/*+WriteVal(Lowline)*/+WriteIf(DownChannel==1," Downward Sloping Channel","")+WriteIf(UpChannel==1," Upward Sloping Channel","")+WriteIf(broadeningWedge==1," Broadening Wedge","")+"\n"+EncodeColor(colorGreen)+WriteIf(bullishbreakout,"Bullish Breakout",EncodeColor(colorRed)+WriteIf(bearishbreakout,"Bearish Breakout",""))/*+WriteVal(highline)*/; 

/////////////////////////////////////

// Automatic Analysis //

////////////////////////////////////

Filter=AscendingTriangle OR DecendingTriangle OR Wedge OR DownChannel OR UpChannel OR BroadeningWedge OR Bullishbreakout OR bearishbreakout;

AddTextColumn(WriteIf(bullishbreakout,"bullish Breakout",""),"BullBreak"); 

AddTextColumn(WriteIf(bearishBreakout,"Bearish Breakout",""),"BearBreak"); 

AddTextColumn(WriteIf(ascendingtriangle,"Ascending Triangle",WriteIf(decendingtriangle,"Decending Triangle",WriteIf(Wedge,"Wedge",WriteIf(DownChannel,"Down Channel",WriteIf(UpChannel,"Up Channel",WriteIf(BroadeningWedge,"Broadening Wedge","")))))),"Pattern");

AddColumn(C,"Close");

Buy=BullishBreakout;
Sell= BearishBreakout;
 
_SECTION_END();


3 Likes

Try this afl out, I'm not the author to this code, this was shared to me by some one else.

Good luck my friend

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.