Help me code this pls

#1
what i want is a buy sell triger in nr4 code .currently it only works as exploration and marking on chart i want a buy when the nr4 bar and nr7 bar is taken out on the upside and vice versa for sell and i want only nr4 and nr7 bar to be taken into account and no inside days,idnr4 and idnr7 are to be ignored



Code for nr4

_SECTION_BEGIN("NR Chart");
bgTop = ParamColor("BgTop", colorBlack);
bgBot = ParamColor("BgBottom", colorBlack);
bgTitle = ParamColor("Title", colorBlack);

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<R[i-j]) iSum++;
if (iSum== (n-1))
NRx = 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=Count;

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

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

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

Count=0;
for(j=0; ID_NR4[i-j]; j++) Count++;
if (Count>0) Mix_ID_NR4_Count=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();
 

Similar threads