Trend Catching System

KelvinHand

Well-Known Member
#22
hi kelvinhand sir
u see NR7 setup make by our forum member angira, sir can u make afl for amibroker ,i try but i dont know how to make afl for found narrow range day & draw its high low level in chart
Thanks... i wait your reply
Navin.......
My Modified NR7 was posted here:
http://www.traderji.com/amibroker/74623-modified-nr4-nr7-id-indicator.html

I do not know whether is same as member angira


I don't know what you want to do.
If you want to use with Trend Catching System or other existing price chart
then DRAG n HOLD the script to the price chart, then DROP it like a BOMB.


Code:
_SECTION_BEGIN("NR_Setup");
/*
bgTop = ParamColor("BgTop",    colorBlack);
bgBot = ParamColor("BgBottom", colorBlack);
bgTitle = ParamColor("Title", colorGrey50);

SetChartBkGradientFill( bgTop ,bgBot, bgTitle);

Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
*/

//-- Function Declaration --------------------
function NR(n)
{
  R=H-L;
  NRx=False;
  
  for(i=n; i<BarCount; i++)
  {
      iSum=0;
      for(j=1; j<n; j++)
        if (R[i]<R[i-j]) iSum++;
      if (iSum== (n-1))
       NRx[i] = True;

   }
   return (NRx); 
}


/*********************************************************/
  TimeFrameSet( inDaily ); 
/**********************************************************/

R=H-L;

NR4=NR(4);
NR7=NR(7);
ID=Inside(); 

//Mixed of ID & NR7
ID_NR7 = Inside() * NR7;
ID_NR4 = Inside() * NR4;


Pure_NR7 = (NR7 AND NOT ID);
Pure_NR7_Count=0;

Pure_NR4 = (NR4 AND NOT NR7 AND NOT ID);
Pure_NR4_Count=0;

Pure_ID  = (ID AND NOT NR7 AND NOT NR4);
Pure_ID_Count=0;

Mix_ID_NR7  = ID_NR7;
Mix_ID_NR7_Count=0;

Mix_ID_NR4  = ID_NR4 AND NOT ID_NR7;
Mix_ID_NR4_Count=0;


for(i=1; i<BarCount; i++)
{
  Count=0;
  for(j=0; Pure_NR7[i-j]; j++) Count++;
  if (Count>0) Pure_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_NR4[i-j]; j++) Count++;
  if (Count>0) Pure_NR4_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_ID[i-j]; j++) Count++;
  if (Count>0) Pure_ID_Count[i]=Count; 

  Count=0;
  for(j=0; Mix_ID_NR7[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; ID_NR4[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR4_Count[i]=Count; 

 
}

/*********************************************************/
  TimeFrameRestore(); // restore time frame to original 
/**********************************************************/

Pure_NR7_Color = colorBrightGreen;
Pure_NR4_Color = colorLightOrange;
Pure_ID_Color  = colorYellow;
Mix_ID_NR7_Color = colorGreen;
Mix_ID_NR4_Color = colorGold;

switch(Status("action"))
{
  case actionIndicator:

	_N(Title = Title + 
  		WriteIf(Mix_ID_NR7, EncodeColor(Mix_ID_NR7_Color) + WriteIf(Mix_ID_NR7_Count>1, StrLeft(NumToStr(Mix_ID_NR7_Count), 4), "") + " IDNR7 ",
  		WriteIf(Mix_ID_NR4, EncodeColor(Mix_ID_NR4_Color) + WriteIf(Mix_ID_NR4_Count>1, StrLeft(NumToStr(Mix_ID_NR4_Count), 4), "") + " IDNR4 ",
  		WriteIf(Pure_NR7,   EncodeColor(Pure_NR7_Color)   + WriteIf(Pure_NR7_Count > 1,  StrLeft(NumToStr(Pure_NR7_Count), 4), "") + " NR7 ",
  		WriteIf(Pure_NR4,   EncodeColor(Pure_NR4_Color)   + WriteIf(Pure_NR4_Count > 1,  StrLeft(NumToStr(Pure_NR4_Count), 4), "") + " NR4 ",
  		WriteIf(Pure_ID,    EncodeColor(Pure_ID_Color)    + WriteIf(Pure_ID_Count > 1,   StrLeft(NumToStr(Pure_ID_Count), 4), "") + " InsideDay ", "")))))
	);


	/**** 
   	Plot Shapes 
 	****/


	//-- Plot NR4 & NR7 --
	Dist = L * 0.995;

	//-- Plot Pure NR7
	PlotShapes(Pure_NR7*shapeDigit7, 
           Pure_NR7_Color, 
           0, 
           Dist);

	//-- Plot Pure NR4
	PlotShapes(Pure_NR4*shapeDigit4, 
           Pure_NR4_Color, 
           0, 
           Dist);


	//-- Plot ID & Mix ID --
	Dist = H * 1.03;

	//-- Plot Pure ID
	PlotShapes(Pure_ID*shapeHollowCircle, 
				 Pure_ID_Color,  
           0, 
           Dist);


	// -- Plot Mix NR7 & ID 
	PlotShapes(Mix_ID_NR7*shapeStar, 
           Mix_ID_NR7_Color, 
           0, 
           Dist);

	// -- Plot Mix NR4 & ID 
	PlotShapes(Mix_ID_NR4*shapeStar, 
           Mix_ID_NR4_Color, 
           0, 
           Dist);

	break;


	case actionExplore:
	Buy    = Mix_ID_NR7 OR Pure_NR7 AND Volume > 50000 AND Close > 50; 
	Sell   = Mix_ID_NR4 OR Pure_NR4 AND Volume > 50000 AND Close > 50; 
	Filter = (Pure_NR7_Count > 0) OR (Pure_NR4_Count > 0) OR (Pure_ID_Count > 0);

	SetOption("NoDefaultColumns", True);
	AddColumn(DateTime(), "DATE", formatDateTime,colorDefault, colorDefault, 80);
	AddTextColumn(Name(), "SYMBOL", 77);
	
	AddColumn(IIf(Pure_ID_Count,  48 + Pure_ID_Count,  32), "INSIDE", formatChar, colorYellow, IIf(Pure_ID_Count, colorLightBlue, colorDefault));
	AddColumn(IIf(Pure_NR4_Count, 48 + Pure_NR4_Count, 32), "NR4",    formatChar, colorYellow, IIf(Pure_NR4_Count, colorBlue, colorDefault));
	AddColumn(IIf(Pure_NR7_Count, 48 + Pure_NR7_Count, 32), "NR7",    formatChar, colorYellow, IIf(Pure_NR7_Count, colorGreen, colorDefault));

  
  AddColumn(R, "Range", 6.2, colorDefault, colorDefault, 84);
  AddColumn(High, "High", 6.2, colorDefault, colorDefault, 120);
  AddColumn(Low,  "Low",  6.2, colorDefault, colorDefault, 120);
	break;      

}   

_SECTION_END();
 

KelvinHand

Well-Known Member
#23
All TimeFrames
Code:
_SECTION_BEGIN("NR Chart");
bgTop = ParamColor("BgTop",    colorBlack);
bgBot = ParamColor("BgBottom", colorBlack);
bgTitle = ParamColor("Title", colorGrey50);

SetChartBkGradientFill( bgTop ,bgBot, bgTitle);

Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));



//-- Function Declaration --------------------
function NR(n)
{
  R=H-L;
  NRx=False;
  
  for(i=n; i<BarCount; i++)
  {
      iSum=0;
      for(j=1; j<n; j++)
        if (R[i]<R[i-j]) iSum++;
      if (iSum== (n-1))
       NRx[i] = True;

   }
   return (NRx); 
}


/*********************************************************/
  //TimeFrameSet( inDaily ); 
/**********************************************************/

R=H-L;

NR4=NR(4);
NR7=NR(7);
ID=Inside(); 

//Mixed of ID & NR7
ID_NR7 = Inside() * NR7;
ID_NR4 = Inside() * NR4;


Pure_NR7 = (NR7 AND NOT ID);
Pure_NR7_Count=0;

Pure_NR4 = (NR4 AND NOT NR7 AND NOT ID);
Pure_NR4_Count=0;

Pure_ID  = (ID AND NOT NR7 AND NOT NR4);
Pure_ID_Count=0;

Mix_ID_NR7  = ID_NR7;
Mix_ID_NR7_Count=0;

Mix_ID_NR4  = ID_NR4 AND NOT ID_NR7;
Mix_ID_NR4_Count=0;


for(i=1; i<BarCount; i++)
{
  Count=0;
  for(j=0; Pure_NR7[i-j]; j++) Count++;
  if (Count>0) Pure_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_NR4[i-j]; j++) Count++;
  if (Count>0) Pure_NR4_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_ID[i-j]; j++) Count++;
  if (Count>0) Pure_ID_Count[i]=Count; 

  Count=0;
  for(j=0; Mix_ID_NR7[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; ID_NR4[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR4_Count[i]=Count; 

 
}

/*********************************************************/
  //TimeFrameRestore(); // restore time frame to original 
/**********************************************************/

Pure_NR7_Color = colorBrightGreen;
Pure_NR4_Color = colorLightOrange;
Pure_ID_Color  = colorYellow;
Mix_ID_NR7_Color = colorGreen;
Mix_ID_NR4_Color = colorGold;

switch(Status("action"))
{
  case actionIndicator:

	_N(Title = Title + 
  		WriteIf(Mix_ID_NR7, EncodeColor(Mix_ID_NR7_Color) + WriteIf(Mix_ID_NR7_Count>1, StrLeft(NumToStr(Mix_ID_NR7_Count), 4), "") + " IDNR7 ",
  		WriteIf(Mix_ID_NR4, EncodeColor(Mix_ID_NR4_Color) + WriteIf(Mix_ID_NR4_Count>1, StrLeft(NumToStr(Mix_ID_NR4_Count), 4), "") + " IDNR4 ",
  		WriteIf(Pure_NR7,   EncodeColor(Pure_NR7_Color)   + WriteIf(Pure_NR7_Count > 1,  StrLeft(NumToStr(Pure_NR7_Count), 4), "") + " NR7 ",
  		WriteIf(Pure_NR4,   EncodeColor(Pure_NR4_Color)   + WriteIf(Pure_NR4_Count > 1,  StrLeft(NumToStr(Pure_NR4_Count), 4), "") + " NR4 ",
  		WriteIf(Pure_ID,    EncodeColor(Pure_ID_Color)    + WriteIf(Pure_ID_Count > 1,   StrLeft(NumToStr(Pure_ID_Count), 4), "") + " InsideDay ", "")))))
	);


	/**** 
   	Plot Shapes 
 	****/


	//-- Plot NR4 & NR7 --
	Dist = L ;

	//-- Plot Pure NR7
	PlotShapes(Pure_NR7*shapeDigit7, 
           Pure_NR7_Color, 
           0, 
           Dist);

	//-- Plot Pure NR4
	PlotShapes(Pure_NR4*shapeDigit4, 
           Pure_NR4_Color, 
           0, 
           Dist);


	//-- Plot ID & Mix ID --
	Dist = H ;

	//-- Plot Pure ID
	PlotShapes(Pure_ID*shapeHollowCircle, 
				 Pure_ID_Color,  
           0, 
           Dist);


	// -- Plot Mix NR7 & ID 
	PlotShapes(Mix_ID_NR7*shapeStar, 
           Mix_ID_NR7_Color, 
           0, 
           Dist);

	// -- Plot Mix NR4 & ID 
	PlotShapes(Mix_ID_NR4*shapeStar, 
           Mix_ID_NR4_Color, 
           0, 
           Dist);

	break;


	case actionExplore:
	Buy    = Mix_ID_NR7 OR Pure_NR7 AND Volume > 50000 AND Close > 50; 
	Sell   = Mix_ID_NR4 OR Pure_NR4 AND Volume > 50000 AND Close > 50; 
	Filter = (Pure_NR7_Count > 0) OR (Pure_NR4_Count > 0) OR (Pure_ID_Count > 0);

	SetOption("NoDefaultColumns", True);
	AddColumn(DateTime(), "DATE", formatDateTime,colorDefault, colorDefault, 80);
	AddTextColumn(Name(), "SYMBOL", 77);
	
	AddColumn(IIf(Pure_ID_Count,  48 + Pure_ID_Count,  32), "INSIDE", formatChar, colorYellow, IIf(Pure_ID_Count, colorLightBlue, colorDefault));
	AddColumn(IIf(Pure_NR4_Count, 48 + Pure_NR4_Count, 32), "NR4",    formatChar, colorYellow, IIf(Pure_NR4_Count, colorBlue, colorDefault));
	AddColumn(IIf(Pure_NR7_Count, 48 + Pure_NR7_Count, 32), "NR7",    formatChar, colorYellow, IIf(Pure_NR7_Count, colorGreen, colorDefault));

  
  AddColumn(R, "Range", 6.2, colorDefault, colorDefault, 84);
  AddColumn(High, "High", 6.2, colorDefault, colorDefault, 120);
  AddColumn(Low,  "Low",  6.2, colorDefault, colorDefault, 120);
	break;      

}   

_SECTION_END();
 

suktam

Active Member
#24
My Modified NR7 was posted here:
http://www.traderji.com/amibroker/74623-modified-nr4-nr7-id-indicator.html

I do not know whether is same as member angira


I don't know what you want to do.
If you want to use with Trend Catching System or other existing price chart
then DRAG n HOLD the script to the price chart, then DROP it like a BOMB.


Code:
_SECTION_BEGIN("NR_Setup");
/*
bgTop = ParamColor("BgTop",    colorBlack);
bgBot = ParamColor("BgBottom", colorBlack);
bgTitle = ParamColor("Title", colorGrey50);

SetChartBkGradientFill( bgTop ,bgBot, bgTitle);

Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
*/

//-- Function Declaration --------------------
function NR(n)
{
  R=H-L;
  NRx=False;
  
  for(i=n; i<BarCount; i++)
  {
      iSum=0;
      for(j=1; j<n; j++)
        if (R[i]<R[i-j]) iSum++;
      if (iSum== (n-1))
       NRx[i] = True;

   }
   return (NRx); 
}


/*********************************************************/
  TimeFrameSet( inDaily ); 
/**********************************************************/

R=H-L;

NR4=NR(4);
NR7=NR(7);
ID=Inside(); 

//Mixed of ID & NR7
ID_NR7 = Inside() * NR7;
ID_NR4 = Inside() * NR4;


Pure_NR7 = (NR7 AND NOT ID);
Pure_NR7_Count=0;

Pure_NR4 = (NR4 AND NOT NR7 AND NOT ID);
Pure_NR4_Count=0;

Pure_ID  = (ID AND NOT NR7 AND NOT NR4);
Pure_ID_Count=0;

Mix_ID_NR7  = ID_NR7;
Mix_ID_NR7_Count=0;

Mix_ID_NR4  = ID_NR4 AND NOT ID_NR7;
Mix_ID_NR4_Count=0;


for(i=1; i<BarCount; i++)
{
  Count=0;
  for(j=0; Pure_NR7[i-j]; j++) Count++;
  if (Count>0) Pure_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_NR4[i-j]; j++) Count++;
  if (Count>0) Pure_NR4_Count[i]=Count; 

  Count=0;
  for(j=0; Pure_ID[i-j]; j++) Count++;
  if (Count>0) Pure_ID_Count[i]=Count; 

  Count=0;
  for(j=0; Mix_ID_NR7[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR7_Count[i]=Count; 

  Count=0;
  for(j=0; ID_NR4[i-j]; j++) Count++;
  if (Count>0) Mix_ID_NR4_Count[i]=Count; 

 
}

/*********************************************************/
  TimeFrameRestore(); // restore time frame to original 
/**********************************************************/

Pure_NR7_Color = colorBrightGreen;
Pure_NR4_Color = colorLightOrange;
Pure_ID_Color  = colorYellow;
Mix_ID_NR7_Color = colorGreen;
Mix_ID_NR4_Color = colorGold;

switch(Status("action"))
{
  case actionIndicator:

	_N(Title = Title + 
  		WriteIf(Mix_ID_NR7, EncodeColor(Mix_ID_NR7_Color) + WriteIf(Mix_ID_NR7_Count>1, StrLeft(NumToStr(Mix_ID_NR7_Count), 4), "") + " IDNR7 ",
  		WriteIf(Mix_ID_NR4, EncodeColor(Mix_ID_NR4_Color) + WriteIf(Mix_ID_NR4_Count>1, StrLeft(NumToStr(Mix_ID_NR4_Count), 4), "") + " IDNR4 ",
  		WriteIf(Pure_NR7,   EncodeColor(Pure_NR7_Color)   + WriteIf(Pure_NR7_Count > 1,  StrLeft(NumToStr(Pure_NR7_Count), 4), "") + " NR7 ",
  		WriteIf(Pure_NR4,   EncodeColor(Pure_NR4_Color)   + WriteIf(Pure_NR4_Count > 1,  StrLeft(NumToStr(Pure_NR4_Count), 4), "") + " NR4 ",
  		WriteIf(Pure_ID,    EncodeColor(Pure_ID_Color)    + WriteIf(Pure_ID_Count > 1,   StrLeft(NumToStr(Pure_ID_Count), 4), "") + " InsideDay ", "")))))
	);


	/**** 
   	Plot Shapes 
 	****/


	//-- Plot NR4 & NR7 --
	Dist = L * 0.995;

	//-- Plot Pure NR7
	PlotShapes(Pure_NR7*shapeDigit7, 
           Pure_NR7_Color, 
           0, 
           Dist);

	//-- Plot Pure NR4
	PlotShapes(Pure_NR4*shapeDigit4, 
           Pure_NR4_Color, 
           0, 
           Dist);


	//-- Plot ID & Mix ID --
	Dist = H * 1.03;

	//-- Plot Pure ID
	PlotShapes(Pure_ID*shapeHollowCircle, 
				 Pure_ID_Color,  
           0, 
           Dist);


	// -- Plot Mix NR7 & ID 
	PlotShapes(Mix_ID_NR7*shapeStar, 
           Mix_ID_NR7_Color, 
           0, 
           Dist);

	// -- Plot Mix NR4 & ID 
	PlotShapes(Mix_ID_NR4*shapeStar, 
           Mix_ID_NR4_Color, 
           0, 
           Dist);

	break;


	case actionExplore:
	Buy    = Mix_ID_NR7 OR Pure_NR7 AND Volume > 50000 AND Close > 50; 
	Sell   = Mix_ID_NR4 OR Pure_NR4 AND Volume > 50000 AND Close > 50; 
	Filter = (Pure_NR7_Count > 0) OR (Pure_NR4_Count > 0) OR (Pure_ID_Count > 0);

	SetOption("NoDefaultColumns", True);
	AddColumn(DateTime(), "DATE", formatDateTime,colorDefault, colorDefault, 80);
	AddTextColumn(Name(), "SYMBOL", 77);
	
	AddColumn(IIf(Pure_ID_Count,  48 + Pure_ID_Count,  32), "INSIDE", formatChar, colorYellow, IIf(Pure_ID_Count, colorLightBlue, colorDefault));
	AddColumn(IIf(Pure_NR4_Count, 48 + Pure_NR4_Count, 32), "NR4",    formatChar, colorYellow, IIf(Pure_NR4_Count, colorBlue, colorDefault));
	AddColumn(IIf(Pure_NR7_Count, 48 + Pure_NR7_Count, 32), "NR7",    formatChar, colorYellow, IIf(Pure_NR7_Count, colorGreen, colorDefault));

  
  AddColumn(R, "Range", 6.2, colorDefault, colorDefault, 84);
  AddColumn(High, "High", 6.2, colorDefault, colorDefault, 120);
  AddColumn(Low,  "Low",  6.2, colorDefault, colorDefault, 120);
	break;      

}   

_SECTION_END();








HI, KELVINHAND SIR
I SAW YOUR AFL, BUT IF POSSIBLE FOR U TO MAKE BELOW AFL PROPER WHICH I TRY FOR NR7 AS PER MY UNDERSTANDING ,
THANKS...NAVIN

_SECTION_BEGIN("Price");


SetPositionSize( 2000, spsShares ); // 2000 shares by default

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("camarilla levels");
//---- pivot points
DayH1 = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
DayL1 = TimeFrameGetPrice("L", inDaily, -1); // low
DayC1 = TimeFrameGetPrice("C", inDaily, -1); // close

DayH2 = TimeFrameGetPrice("H", inDaily, -2); // yesterdays high
DayL2 = TimeFrameGetPrice("L", inDaily, -2); // low

DayH3 = TimeFrameGetPrice("H", inDaily, -3); // yesterdays high
DayL3 = TimeFrameGetPrice("L", inDaily, -3); // low

DayH4 = TimeFrameGetPrice("H", inDaily, -4); // yesterdays high
DayL4 = TimeFrameGetPrice("L", inDaily, -4); // low

DayH5 = TimeFrameGetPrice("H", inDaily, -5); // yesterdays high
DayL5 = TimeFrameGetPrice("L", inDaily, -5); // low


DayH6 = TimeFrameGetPrice("H", inDaily, -6); // yesterdays high
DayL6 = TimeFrameGetPrice("L", inDaily, -6); // low

DayH7 = TimeFrameGetPrice("H", inDaily, -7); // yesterdays high
DayL7 = TimeFrameGetPrice("L", inDaily, -7); // low

DayH8 = TimeFrameGetPrice("H", inDaily, -8); // yesterdays high
DayL8 = TimeFrameGetPrice("L", inDaily, -8); // low




_SECTION_BEGIN

R1=(DayH1-DayL1);
R2=(DayH2-DayL2);
R3=(DayH3-DayL3);
R4=(DayH4-DayL4);
R5=(DayH5-DayL5);
R6=(DayH6-DayL6);
R7=(DayH7-DayL7);
R8=(DayH8-DayL8);

A=Min(R1,R2);
B=Min(R3,R4);
CC=Min(R5,R6);
D=Min(R7,R8);
E=Min(A,B);
F=Min(CC,D);
G=Min(E,F);

// KELVINHAND SIR I HERE GOT G AS A MIN RANGE OF LAST 8 DAYS ,NOW I WANT TO PLOT THAT DAYS HIGH & LOW VALUE AS A STAIR CASE LINE (BOTH LINE) & UPPER LEVEL(HIGH LEVEL)TRIGEER
//AS A Buy LEVEL &BELOW LIN Low LEVEL AS A Sell LEVEL.



Plot(Buy, "",colorGreen,styleStaircase);
Plot(Sell, "",colorRed,styleStaircase);




//----
Title = Name()+" SIMPLE PIVOT & FIBO"+Date()+ EncodeColor(colorRed)+" Long Breakout above "+WriteVal(R1,1.2)+"\n"+EncodeColor(colorRed)+" Short breakout below "+WriteVal(S1,1.2)

;


Filter=1;
AddColumn(C,"cmp",1.2);
AddColumn(R1,"R1",1.2);
AddColumn(S1,"S1",1.2);
_SECTION_END();




Buy=Cover=Cross (C, R1);
Sell=Short= Cross (S1 ,C);
//Buy=ExRem(Buy,Sell);
//Sell=ExRem(Sell,Buy);

// plot arrows

shape = Buy * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );



SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );




C13=Param("fonts",15,10,30,1 );
C14=Param("left-right",3.5,1.0,5.0,0.1 );
C15=Param("up-down",20,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (colorRed,217,213));
GfxTextOut( "NR7 ", Status("pxwidth")/C14, Status("pxheight")/C15 );
 

suktam

Active Member
#25
HI, KELVINHAND SIR
I SAW YOUR AFL, BUT IF POSSIBLE FOR U TO MAKE BELOW AFL PROPER WHICH I TRY FOR NR7 AS PER MY UNDERSTANDING ,
THANKS...NAVIN

_SECTION_BEGIN("Price");


SetPositionSize( 2000, spsShares ); // 2000 shares by default

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("camarilla levels");
//---- pivot points
DayH1 = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
DayL1 = TimeFrameGetPrice("L", inDaily, -1); // low
DayC1 = TimeFrameGetPrice("C", inDaily, -1); // close

DayH2 = TimeFrameGetPrice("H", inDaily, -2); // yesterdays high
DayL2 = TimeFrameGetPrice("L", inDaily, -2); // low

DayH3 = TimeFrameGetPrice("H", inDaily, -3); // yesterdays high
DayL3 = TimeFrameGetPrice("L", inDaily, -3); // low

DayH4 = TimeFrameGetPrice("H", inDaily, -4); // yesterdays high
DayL4 = TimeFrameGetPrice("L", inDaily, -4); // low

DayH5 = TimeFrameGetPrice("H", inDaily, -5); // yesterdays high
DayL5 = TimeFrameGetPrice("L", inDaily, -5); // low


DayH6 = TimeFrameGetPrice("H", inDaily, -6); // yesterdays high
DayL6 = TimeFrameGetPrice("L", inDaily, -6); // low

DayH7 = TimeFrameGetPrice("H", inDaily, -7); // yesterdays high
DayL7 = TimeFrameGetPrice("L", inDaily, -7); // low

DayH8 = TimeFrameGetPrice("H", inDaily, -8); // yesterdays high
DayL8 = TimeFrameGetPrice("L", inDaily, -8); // low




_SECTION_BEGIN

R1=(DayH1-DayL1);
R2=(DayH2-DayL2);
R3=(DayH3-DayL3);
R4=(DayH4-DayL4);
R5=(DayH5-DayL5);
R6=(DayH6-DayL6);
R7=(DayH7-DayL7);
R8=(DayH8-DayL8);

A=Min(R1,R2);
B=Min(R3,R4);
CC=Min(R5,R6);
D=Min(R7,R8);
E=Min(A,B);
F=Min(CC,D);
G=Min(E,F);

// KELVINHAND SIR I HERE GOT G AS A MIN RANGE OF LAST 8 DAYS ,NOW I WANT TO PLOT THAT DAYS HIGH & LOW VALUE AS A STAIR CASE LINE (BOTH LINE) & UPPER LEVEL(HIGH LEVEL)TRIGEER
//AS A Buy LEVEL &BELOW LIN Low LEVEL AS A Sell LEVEL.



Plot(Buy, "",colorGreen,styleStaircase);
Plot(Sell, "",colorRed,styleStaircase);




//----
Title = Name()+" SIMPLE PIVOT & FIBO"+Date()+ EncodeColor(colorRed)+" Long Breakout above "+WriteVal(R1,1.2)+"\n"+EncodeColor(colorRed)+" Short breakout below "+WriteVal(S1,1.2)

;


Filter=1;
AddColumn(C,"cmp",1.2);
AddColumn(R1,"R1",1.2);
AddColumn(S1,"S1",1.2);
_SECTION_END();




Buy=Cover=Cross (C, R1);
Sell=Short= Cross (S1 ,C);
//Buy=ExRem(Buy,Sell);
//Sell=ExRem(Sell,Buy);

// plot arrows

shape = Buy * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );



SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );




C13=Param("fonts",15,10,30,1 );
C14=Param("left-right",3.5,1.0,5.0,0.1 );
C15=Param("up-down",20,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (colorRed,217,213));
GfxTextOut( "NR7 ", Status("pxwidth")/C14, Status("pxheight")/C15 );























HI ,KELVINHAND

SIR
ABOVE AFL I SEND FOR NR7 MODIFICATION
BELOW AFL I SEND FOR TREND CATCHING


SIR I WANT OPTIMIZATION AS PER MY SCRIPT & MY TIMEFRAME SO I TRY SOME MODIFICATION IN YOUR TREND CATCHING AFL BUT I NOT GOT ANY THING IN BACKTESTING,I CAN NOT DRAW BUY SELL ARROW SO PL CHECK AFL
& RECTIFY IT
THANKS.....NAVIN



/* Trend catching System

2012, Oct 6th - Modified and integrated By KelvinHand with the given AFL source
* BandStop - Done by Rajandran R
Author of www.marketcalls.in
BBands_Stop_v1.mq4 by [email protected]
translation in Amibroker AFL, E.M.Pottasch, 2011


Reference Guides from
- http://www.traderji.com/metatrader/53910-trend-catching-system.html
- http://www.fxfisherman.com/forums/f...stems/6630-trend-catching-system-perfect.html

*/


_SECTION_BEGIN("Price Chart");

SetPositionSize( 2000, spsShares );
bgTop = ParamColor("BgTop", colorBlack);
bgBot = ParamColor("BgBottom", colorBlack);
SetChartBkGradientFill( bgTop ,bgBot, colorLightGrey);

pStyle = ParamList("Price Style", "Candle|Solid Candle|Bar|Line|Heikin-Ashi",2);
cBull = ParamColor("Price Bull", colorLime);
CBear = ParamColor("Price Bear", colorRed);
cLine = ParamColor("Price Line", colorWhite);


SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));

ThisStyle = styleCandle;
ThisTitle = "";

_O=O; _C=C; _H=H; _L=L;

ThisColor = IIf( _C>_O, cBull, IIf(_C<_O, CBear, CLine));


switch (pStyle )
{

case "Solid Candle":
SetBarFillColor( ThisColor );
break;


case "Bar":
ThisStyle = styleBar;
break;

case "Line":
ThisStyle = styleLine;
ThisColor = cLine;
break;


case "Heikin-Ashi":
_C = (O+H+L+C)/4;
_O = AMA( Ref( _C, -1 ), 0.5 );
_H = Max( H, Max( _C, _O ) );
_L = Min( L, Min( _C, _O ) );

ThisColor = IIf(_C >= _O,CBull, CBear);
SetBarFillColor( ThisColor );

ThisColor = IIf(_C >= _O,cLine, cLine);
ThisTitle = "Heikin-Ashi";
break;

default:
SetBarFillColor( ThisColor );
ThisColor = cLine;

break;

}

PlotOHLC( _O, _H, _L, _C, ThisTitle, ThisColor, ThisStyle);
GraphXSpace = 8;

_SECTION_END();


_SECTION_BEGIN("BandStop");
/* Done by Rajandran R */
/* Author of www.marketcalls.in */
// BBands_Stop_v1.mq4 by [email protected]
// translation in Amibroker AFL, E.M.Pottasch, 2011

// Modified By KelvinHand

Length=Optimize("Length",Param("Length",20, 2,100,1),2,100,1); // Bollinger Bands Period
Deviation=Optimize("Deviation",Param("Deviation",2,1,10,0.5),1,10,0.5);
// Deviation was 2
MoneyRisk=Optimize("Money Risk",Param("Money Risk",1,0.5,3,0.5),0.5,3,0.5);

LineStyle=ParamToggle("Display line mode", "No|Yes", 1); // Display line mode: 0-no,1-yes
cUpTrendLine = ParamColor("UpTrendLine", ColorRGB(65,105,225));
cDnTrendLine = ParamColor("DownTrendLine", colorRed);




Buy=Cover=Cross (C,cUpTrendLine );
Sell=Short= Cross ( cDnTrendLine, C);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

// plot arrows

shape = Buy * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );



SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );












// Offset Factor
TurnedUp=Nz(StaticVarGet("TurnedUp"));
TurnedDown=Nz(StaticVarGet("TurnedDown"));
SoundON = ParamToggle("Sound","Off|On",1);


procedure CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown)
{
global UpTrendLine;
global DownTrendLine;
global smax;
global smin;

UpTrendLine=Null;
DownTrendLine=Null;
smax=Null;
smin=Null;
trend=0;


for (i=Length+1; i<BarCount; i++)
{
smax=bbtop;
smin=bbbot;
if (C>smax[i-1]) trend=1;
if (C<smin[i-1]) trend=-1;
if(trend>0 && smin<smin[i-1]) smin=smin[i-1];
if(trend<0 && smax>smax[i-1]) smax=smax[i-1];
bsmax=smax+0.5*(MoneyRisk-1)*(smax-smin);
bsmin=smin-0.5*(MoneyRisk-1)*(smax-smin);
if(trend>0 && bsmin<bsmin[i-1]) bsmin=bsmin[i-1];
if(trend<0 && bsmax>bsmax[i-1]) bsmax=bsmax[i-1];
if (trend>0)
{
UpTrendLine=bsmin;
if (SoundON==True && !TurnedUp && i==BarCount-1 && IsEmpty(UpTrendLine[i-1]))
{
Say("Bollinger Bands going Up");
TurnedUp=StaticVarSet("TurnedUp",1);
TurnedDown=StaticVarSet("TurnedDown",0);

}
}

if (trend<0)
{
DownTrendLine=bsmax;
if (SoundON==True && !TurnedDown && i==BarCount-1 && IsEmpty(DownTrendLine[i-1]))
{
Say("Bollinger Bands going Down");
TurnedUp=StaticVarSet("TurnedUp",0);
TurnedDown=StaticVarSet("TurnedDown",1);
}
} //if (trend<0)
} //for
} //procedure

bbtop=BBandTop(C,Length,Deviation);
bbbot=BBandBot(C,Length,Deviation);

CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown);
UpTrendSigNal=UpTrendLine AND IsEmpty(Ref(UpTrendLine,-1));
DownTrendSigNal=DownTrendLine AND IsEmpty(Ref(DownTrendLine,-1));

DisplayStyle = styleNoLabel|styleDots|styleNoTitle;
if(LineStyle == 0) DisplayStyle |= styleNoLine;


Plot(UpTrendLine,"UPTRENDLINE",cUpTrendLine,DisplayStyle);
Plot(DownTrendLine,"DOWNTRENDLINE",cDnTrendLine,DisplayStyle) ;

PlotShapes(IIf(UpTrendSignal,shapeCircle,shapeNone),cUpTrendLine,0,bbbot,0);
PlotShapes(IIf(DownTrendSignal,shapeCircle,shapeNone),cDnTrendLine,0,bbtop,0);
_SECTION_END();

_SECTION_BEGIN("Wave Channel");

cOutLine = ParamColor("Outer Line", colorWhite);
cMidLine = ParamColor("Mid Line", colorGrey40);

Plot( MA(C, 34), "", cMidLine, styleNoLabel);
Plot( MA(H, 34), "", cOutLine, styleThick|styleNoLabel);
Plot( MA(L, 34), "", cOutLine, styleThick|styleNoLabel);


_SECTION_END();

_SECTION_BEGIN("WMA Rainbow");

cOutLine = ParamColor("Outline", colorBlue);
cInnerLine = ParamColor("Innerline", colorDarkBlue);


Plot( WMA(C, 2), "", cOutLine, styleThick|styleNoLabel);
Plot( WMA(C, 8), "", cOutLine, styleThick|styleNoLabel);

Plot( WMA(C, 3), "", cInnerLine, styleNoLabel);
Plot( WMA(C, 4), "", cInnerLine, styleNoLabel);
Plot( WMA(C, 5), "", cInnerLine, styleNoLabel);
Plot( WMA(C, 6), "", cInnerLine, styleNoLabel);
Plot( WMA(C, 7), "", cInnerLine, styleNoLabel);


_SECTION_END();
 

KelvinHand

Well-Known Member
#27
hello... i went through the post and the timeframe is still unclear.... can you pls suggest is it better to use in EOD or 15mins TF?

thank you
Hello, I swear, you really did not went through post properly.
The information is given in post #1.

Since you give me a choice of EOD or 15mins.
Then My suggest is it better to use in EOD.

Weekly and Monthly also not a bad suggestion -
More Profit, less stress.

If you are skillful enough, you can use in 1min, tick, vol, range charts.
 
#28
Hello, I swear, you really did not went through post properly.
The information is given in post #1.

Since you give me a choice of EOD or 15mins.
Then My suggest is it better to use in EOD.

Weekly and Monthly also not a bad suggestion -
More Profit, less stress.

If you are skillful enough, you can use in 1min, tick, vol, range charts.
the timeframe is written Hi and above which i didnt understood.... i should had pointed this is my earlier post...:D anyways now that you have cleared it i will go forward with testing....

have a good day..!!
 
#30
Thread starter Similar threads Forum Replies Date
J Day Trading 0
A Forex 12
S AmiBroker 3
S MetaTrader 16
P AmiBroker 2

Similar threads