Simple Coding Help - No Promise.

some body can help me to fix this error please , sometime i cant see the arrow show buy and sell when price too high or too low
it look like this , please fix it , thanks


code

_SECTION_BEGIN("H K CHART");
//---- TREND TRADE
SetChartOptions(1,chartShowArrows|chartShowDates);
GraphXSpace=5;
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.8);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
barcolor = IIf(HaClose >= HaOpen,colorWhite,colorWhite);
if( ParamToggle("Plot Heikin-Ashi", "No,Yes", 1 ) )
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Heikin Ashi " + Name(), colorWhite, styleCandle );
else
Plot( C, "Regular candles " + Name(), colorWhite, styleCandle );
j=Haclose;

//PRICE LINE

PriceLineColor = PriceLineColor= colorCustom4;
PriceLevel = C;

Daysback = 200;
FirstBar = BarCount - DaysBack;
YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",style Line|styleDashed|styleNoTitle|styleThick,maskAll)) ;


side = 1;

dist = 0;

for( i = 0; i < BarCount; i++ )
{
if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist, colorCustom2 );
}


_SECTION_END();



_SECTION_BEGIN("Trend Lines");
p1 = Param("TL 1 Periods", 13, 1, 50, 1);
p2 = Param("TL 2 Periods", 3, 1, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGreen), ParamColor("TL Dn Colour", colorRed));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
Plot(TL2, "TriggerLine 2", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();



//================================================En d Chart Configuration===================================== ==========================================


//====================================Start of Linear Regression Code============================================== ====================================

P = ParamField("Price field",-1);

Length = 150;

Daysback = Param("Period for Liner Regression Line",Length,1,240,1);
shift = Param("Look back period",0,0,240,1);

//=============================== Math Formula ================================================== ================================================== ====

x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );

//==================Plot the Linear Regression Line ================================================== ==================================================

LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 1.5, 0.01);// A slope higher than 0.05 radians will turn green, less than -0.05 will turn red and anything in between will be white.

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);

LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;

if(LineUp)
{
Plot(LRLine, "Lin. Reg. Line Up", IIf(LineUp, colorBrightGreen, colorWhite), LRStyle);
}
else
{
Plot(LRLine, "Lin. Reg. Line Down", IIf(LineDn, colorDarkRed, colorWhite), LRStyle);
}




//========================== Plot 1st SD Channel ================================================== ================================================== ==

SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");

Plot( SDU , "Upper Lin Reg", colorRed,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorLime,SDStyle ); //Inside Regression Lines

//========================== Plot 2d SD Channel ================================================== ================================================== ====

SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");

Plot( SDU2 , "Upper Lin Reg", colorRed,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorLime,SDStyle2 ); //OutSide Regression Lines

Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green if sloping up and red if sloping down.

Plot( LRLine , "LinReg", Trend, LRSTYLE );

//============================ End Indicator Code =========


/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",300,50,5000,10);
nBars = Param("Number of bars", 13, 1, 40);

// -- Title.

Title = Name() ;

// -- Plot basic candle chart

PlotOHLC(Open, High, Low, Close,

"BIdx = " + BarIndex() +

"\n" + "O = " + O + "\n"+"H = "+ H + "\n"+"L = " + L

+ "\n"+"C ",

colorBlack, styleBar);

GraphXSpace=7;

// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for future use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(C, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging

/*

for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

*/

// -- OK, let's plot the pivots using arrows

PlotShapes(

IIf(aHPivs==1, shapeHollowDownArrow, shapeNone), colorRed, 0,

High, Offset=-15);

PlotShapes(

IIf(aLPivs==1, shapeHollowUpArrow , shapeNone), colorBrightGreen, 0,

Low, Offset=-15);
_SECTION_END();


_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",21,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",1,1,1200,1);
Ver=Param("Vertical Position",7,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 12, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorGreen) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+30 );
GraphXSpace=-5;
_SECTION_END();
 
some body can help me to fix this error please , sometime i cant see the arrow show buy and sell when price too high or too low
it look like this , please fix it , thanks


code

_SECTION_BEGIN("H K CHART");
//---- TREND TRADE
SetChartOptions(1,chartShowArrows|chartShowDates);
GraphXSpace=5;
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.8);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
barcolor = IIf(HaClose >= HaOpen,colorWhite,colorWhite);
if( ParamToggle("Plot Heikin-Ashi", "No,Yes", 1 ) )
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Heikin Ashi " + Name(), colorWhite, styleCandle );
else
Plot( C, "Regular candles " + Name(), colorWhite, styleCandle );
j=Haclose;

//PRICE LINE

PriceLineColor = PriceLineColor= colorCustom4;
PriceLevel = C;

Daysback = 200;
FirstBar = BarCount - DaysBack;
YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",style Line|styleDashed|styleNoTitle|styleThick,maskAll)) ;


side = 1;

dist = 0;

for( i = 0; i < BarCount; i++ )
{
if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist, colorCustom2 );
}


_SECTION_END();



_SECTION_BEGIN("Trend Lines");
p1 = Param("TL 1 Periods", 13, 1, 50, 1);
p2 = Param("TL 2 Periods", 3, 1, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGreen), ParamColor("TL Dn Colour", colorRed));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
Plot(TL2, "TriggerLine 2", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();



//================================================En d Chart Configuration===================================== ==========================================


//====================================Start of Linear Regression Code============================================== ====================================

P = ParamField("Price field",-1);

Length = 150;

Daysback = Param("Period for Liner Regression Line",Length,1,240,1);
shift = Param("Look back period",0,0,240,1);

//=============================== Math Formula ================================================== ================================================== ====

x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );

//==================Plot the Linear Regression Line ================================================== ==================================================

LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 1.5, 0.01);// A slope higher than 0.05 radians will turn green, less than -0.05 will turn red and anything in between will be white.

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);

LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;

if(LineUp)
{
Plot(LRLine, "Lin. Reg. Line Up", IIf(LineUp, colorBrightGreen, colorWhite), LRStyle);
}
else
{
Plot(LRLine, "Lin. Reg. Line Down", IIf(LineDn, colorDarkRed, colorWhite), LRStyle);
}




//========================== Plot 1st SD Channel ================================================== ================================================== ==

SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");

Plot( SDU , "Upper Lin Reg", colorRed,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorLime,SDStyle ); //Inside Regression Lines

//========================== Plot 2d SD Channel ================================================== ================================================== ====

SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");

Plot( SDU2 , "Upper Lin Reg", colorRed,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorLime,SDStyle2 ); //OutSide Regression Lines

Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green if sloping up and red if sloping down.

Plot( LRLine , "LinReg", Trend, LRSTYLE );

//============================ End Indicator Code =========


/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",300,50,5000,10);
nBars = Param("Number of bars", 13, 1, 40);

// -- Title.

Title = Name() ;

// -- Plot basic candle chart

PlotOHLC(Open, High, Low, Close,

"BIdx = " + BarIndex() +

"\n" + "O = " + O + "\n"+"H = "+ H + "\n"+"L = " + L

+ "\n"+"C ",

colorBlack, styleBar);

GraphXSpace=7;

// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for future use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(C, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging

/*

for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

*/

// -- OK, let's plot the pivots using arrows

PlotShapes(

IIf(aHPivs==1, shapeHollowDownArrow, shapeNone), colorRed, 0,

High, Offset=-15);

PlotShapes(

IIf(aLPivs==1, shapeHollowUpArrow , shapeNone), colorBrightGreen, 0,

Low, Offset=-15);
_SECTION_END();


_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",21,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",1,1,1200,1);
Ver=Param("Vertical Position",7,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 12, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorGreen) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+30 );
GraphXSpace=-5;
_SECTION_END();


----

next time paste code between
[ code]
//....
[ /code]
remove space between [ code and [ /code

~regards
 
Last edited:
Hi all,

I have corrected the formula as suggested by Mastermind007.

Still I am not getting the formula or buy sell arrow I want.

I want to have buy arrow once the price cross the high of first candle when (C>MA(C,P1) AND C>MA(C,P2)) and the sell arrow once the price is lower than when (C<MA(C,P1) AND C<MA(C,P2)).


Following is the corrected formula.



SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey));

SetChartOptions(0,chartShowArrows|chartShowDates);
SetPositionSize(2, spsShares);

_SECTION_BEGIN("Price");

_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", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();


_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
P1 = Param("Period1", 50, 2, 300, 1, 10 );
Plot( MA( C, P1 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
P2 = Param("Period2", 200, 2, 300, 1, 10 );
Plot( MA( C, P2 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

color = IIf(C>MA(C,P1) AND C>MA(C,P2),colorBlue,IIf(C<MA(C,P1) AND C<MA(C,P2),colorRed, colorBlack));
Plot( C, "Close", color, styleNoTitle |styleCandle );

Col=IIf(MA(C,P1)>MA(C,P2),colorLightBlue,colorYellow);
PlotOHLC( 0,MA(C,P1), MA(C,P2), 0, "Cloud", col, styleCloud );

Buy = (C>MA(C,P1) AND C>MA(C,P2));
Short =(C<MA(C,P1) AND C<MA(C,P2));


Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,L,Offset=-15);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0, H, Offset=-15);



Thanks
Amruta
 

cellclinic

Well-Known Member
Hi friends,

I have one afl its good for delivery trading but some time these afl give false signal. please help me to remove these false signal. out of 10 only 1 signal is false remaning 9 is accurate so please modify and enjoy all for these good afl. Here i paste alf below.
Code:
_SECTION_BEGIN("123");
z=Param("zig",0.4,0.01,3,0.01);
Plot(C,"",colorLightGrey,styleBar);
Plot( Zig(C, z), _DEFAULT_NAME(), colorYellow, styleLine );

p=Peak(C,z,1);
t=Trough(C,z,1);

Buy=Cross(C,p)AND TimeNum()>100000 ;
stop=ValueWhen(Buy,t,1);
Entry=ValueWhen(Buy,p,1);
Target=(Entry+(Entry-stop));
Sell=Cross(stop,C) OR Cross(t,C) OR Cross(C,Target) OR TimeNum()>152500 ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy ); 

PlotShapes(shapeUpArrow*Buy,colorGreen,0, L,-5 );
PlotShapes(shapeDownArrow*Sell,colorRed,0, H,-5 );

Short=Cross(t,C)AND TimeNum()>100000;
stop1=ValueWhen(Short,p,1);
Entry1=ValueWhen(Short,t,1);
Target1=(Entry1-(stop1-Entry1));
Cover=Cross(C,stop1) OR Cross(C,p) OR Cross(Target1,C) OR TimeNum()>152500;

Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short ); 

PlotShapes(shapeSmallUpTriangle*Cover,colorRed,0,L,-30 );
PlotShapes(shapeSmallDownTriangle*Short,colorGreen,0,H,-30 );

finalb = Flip( Buy, Sell );
finals = Flip( Short, Cover );

Plot(IIf(finalb==1,Ref(Entry,1),IIf(finals==1,Entry1,Null)),"",colorGreen,styleDashed);
Plot(IIf(finalb==1,stop,IIf(finals==1,stop1,Null)),"",colorRed,styleDashed);
Plot(IIf(finalb==1,Target,IIf(finals==1,Target1,Null)),"",colorBlue,styleDashed);


z=Param("zig",0.4,0.01,3,0.01);
Plot(C,"",colorLightGrey,styleBar);
Plot( Zig(C, z), _DEFAULT_NAME(), colorYellow, styleLine );

p=Peak(C,z,1);
t=Trough(C,z,1);

Buy=Cross(C,p)AND TimeNum()>100000 ;
stop=ValueWhen(Buy,t,1);
Entry=ValueWhen(Buy,p,1);
Target=(Entry+(Entry-stop));
Sell=Cross(stop,C) OR Cross(t,C) OR Cross(C,Target) OR TimeNum()>152500 ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy ); 

PlotShapes(shapeUpArrow*Buy,colorGreen,0, L,-5 );
PlotShapes(shapeDownArrow*Sell,colorRed,0, H,-5 );

Short=Cross(t,C)AND TimeNum()>100000;
stop1=ValueWhen(Short,p,1);
Entry1=ValueWhen(Short,t,1);
Target1=(Entry1-(stop1-Entry1));
Cover=Cross(C,stop1) OR Cross(C,p) OR Cross(Target1,C) OR TimeNum()>152500;

Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short ); 

PlotShapes(shapeSmallUpTriangle*Cover,colorRed,0,L,-30 );
PlotShapes(shapeSmallDownTriangle*Short,colorGreen,0,H,-30 );

finalb = Flip( Buy, Sell );
finals = Flip( Short, Cover );

Plot(IIf(finalb==1,Ref(Entry,1),IIf(finals==1,Entry1,Null)),"",colorGreen,styleDashed);
Plot(IIf(finalb==1,stop,IIf(finals==1,stop1,Null)),"",colorRed,styleDashed);
Plot(IIf(finalb==1,Target,IIf(finals==1,Target1,Null)),"",colorBlue,styleDashed);











































































































































































































































































































































































































































































_SECTION_END();
Seems Like code is incomplete ...
 
Hi all,

I have corrected the formula as suggested by Mastermind007.

Still I am not getting the formula or buy sell arrow I want.

I want to have buy arrow once the price cross the high of first candle when (C>MA(C,P1) AND C>MA(C,P2)) and the sell arrow once the price is lower than when (C<MA(C,P1) AND C<MA(C,P2)).


Following is the corrected formula.

SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey));

SetChartOptions(0,chartShowArrows|chartShowDates);
SetPositionSize(2, spsShares);

_SECTION_BEGIN("Price");

_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", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();


_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
P1 = Param("Period1", 50, 2, 300, 1, 10 );
Plot( MA( C, P1 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
P2 = Param("Period2", 200, 2, 300, 1, 10 );
Plot( MA( C, P2 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

color = IIf(C>MA(C,P1) AND C>MA(C,P2),colorBlue,IIf(C<MA(C,P1) AND C<MA(C,P2),colorRed, colorBlack));
Plot( C, "Close", color, styleNoTitle |styleCandle );

Col=IIf(MA(C,P1)>MA(C,P2),colorLightBlue,colorYellow);
PlotOHLC( 0,MA(C,P1), MA(C,P2), 0, "Cloud", col, styleCloud );

Buy = (C>MA(C,P1) AND C>MA(C,P2));
Short =(C<MA(C,P1) AND C<MA(C,P2));


Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,L,Offset=-15);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0, H, Offset=-15);



Thanks
Amruta

It is working fine. I believe you need to reduce the average parameters. Default params are way too big. Drop 'em to 5 and 20. It plots fine on 15 min NIFTY F1.
 
Hi Mastermind007

I want the buy arrow once the price is above the high of first blue candle or short arrow once the price is below the low of first red candle as per the following condition.

First Blue Candle condition - BuyTrigger = (C>MA(C,P1) AND C>MA(C,P2));
First Red Candle condition - ShortTrigger =(C<MA(C,P1) AND C<MA(C,P2));

i.e. in order to buy or sell, it needs to cross high or low of the trigger bar.

I hope I explained it more clearly.

Thanks
Amruta
 
Please add exploration to this afl. Thanks in advance.

HTML:
_SECTION_BEGIN("ZeroLag MACD"); 
/*Xero Lag MACD(p,q,r)*/
//based on ZeroLag EMA - see Technical Analysis of Stocks and Commodities, April 2000
p = Param("P",12,3,36,2);
q = Param("Q",26,3,52,2);
r = Param("R",9,3,15,1);

EMA1= EMA(Close,p);
EMA2= EMA(EMA1,p);
Difference= EMA1 - EMA2;
ZeroLagEMAp= EMA1 + Difference;
//---------------------------------------
EMA1= EMA(Close,q);
EMA2= EMA(EMA1,q);
Difference= EMA1 - EMA2;
ZeroLagEMAq= EMA1 + Difference;
//---------------------------------------
ZeroLagMACD=ZeroLagEMAp - ZeroLagEMAq;
//---------------------------------------
// Signal line
EMA1= EMA(ZeroLagMACD,r);
EMA2= EMA(EMA1,r);
Difference= EMA1 - EMA2;
ZeroLagTRIG= EMA1 + Difference;

Plot(zerolagMACD,"",colorRed,styleThick+styleDots);
Plot(zerolagtrig,"",colorBlue,styleDashed);

a = round (zerolagMACD*100)/100;
a1 = Ref(a,-1);
diff1 = round((a - a1)*10)/10;
diff2 = round((a1 - Ref(a,-2))*10)/10;

Title =
EncodeColor(colorYellow)+"MACD              : "+ WriteIf(a > 0,  EncodeColor(colorGreen)+a,EncodeColor(colorRed)+a)
+ WriteIf(diff1 > 0, EncodeColor(colorGreen)+"  Up by "+diff1,EncodeColor(colorRed)+"  Dn by "+diff1)
+"\n"
+EncodeColor(colorYellow)+ "One bar ago   : "+ WriteIf(a1 > 0, EncodeColor(colorGreen)+a1,EncodeColor(colorRed)+a1)
+ WriteIf(diff2 > 0, EncodeColor(colorGreen)+"  Up by "+diff2,EncodeColor(colorRed)+"  Dn by "+diff2)
;
 

//===========================end zeroLagMACD
_SECTION_END();
 
Hello,
I am looking out for Daily ema to plot on 5 mins chart. Had search amibroker file an got the below formula, but its not giving me the exact values of that daily ema on 5 mins chart. where am i going wrong?

here is the formula
TimeFrameSet( inDaily ); // switch now to hourly

maD_9 = EMA( C, 9 ); // 9 bar moving average from Daily data

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( mah_9, inDaily), "9 bar moving average from Daily bars", colorRed );
 

amitrandive

Well-Known Member
Hello,
I am looking out for Daily ema to plot on 5 mins chart. Had search amibroker file an got the below formula, but its not giving me the exact values of that daily ema on 5 mins chart. where am i going wrong?

here is the formula
TimeFrameSet( inDaily ); // switch now to hourly

maD_9 = EMA( C, 9 ); // 9 bar moving average from Daily data

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( mah_9, inDaily), "9 bar moving average from Daily bars", colorRed );

Use this,and set number of bars from parameters.


Code:
TimeFrameSet( inDaily ); // switch now to daily
P1= Param("Daily P", 8, 3, 100,1);
mah_13D = MA( C, P1 ); // moving average from daily data
Plot( TimeFrameExpand( mah_13D, inDaily), " EMA Daily",ParamColor( "Daily EMA", colorCycle ), ParamStyle("Daily style",styleLine | styleThick| styleNoRescale));
TimeFrameRestore(); // restore time frame to original
 
Last edited:

Similar threads