Simple Coding Help - No Promise.

KelvinHand

Well-Known Member
ok and thanks for your reply ,

this is mt4 code for ndx
please rewrite this code for amibroker , many many thanks for all of you

//-------------------------------------------------------------------------------

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 -50
#property indicator_level2 0
#property indicator_level3 50
#property indicator_levelcolor Gray
#property indicator_levelstyle 2
#property indicator_minimum -100
#property indicator_maximum 100

extern int NDX_period = 40;
extern int SmLen = 20;
extern int MaxBars = 0;

static datetime lastcalctime;

double NDX[];
double RawNDX[];
double maNDX[];

double fC0Buffer[];
double fA8Buffer[];
double fC8Buffer[];
double list[128], ring1[128], ring2[11], buffer[62];
bool initFlag;
int limitValue, startValue, loopParam, loopCriteria;
int cycleLimit, highLimit, counterA, counterB;
double cycleDelta, lowDValue, highDValue, absValue, paramA, paramB;
double phaseParam, logParam, JMAValue, series, sValue, sqrtParam, lengthDivider;
int s58, s60, s40, s38, s68;

int init()
{
if(SmLen < 10) SmLen = 10;
else if(SmLen > 30) SmLen = 30;
string ndxname = "NDX(" + NDX_period + ", " + SmLen + ")";
IndicatorShortName(ndxname);
IndicatorDigits(0);
IndicatorBuffers(3);
SetIndexBuffer(0, NDX);
SetIndexLabel(0, ndxname);
SetIndexBuffer(1, RawNDX);
SetIndexBuffer(2, maNDX);
return(0);
}

int start()
{
int limit, i, ii, counted_bars = IndicatorCounted()-1, bars;

if(MaxBars > 0) { bars = MaxBars; if(counted_bars > bars) counted_bars = bars - 2; } else bars = Bars;
if(bars <= NDX_period + 3*SmLen) return(0);
if(counted_bars < 0) counted_bars = 0;
if(counted_bars > NDX_period) limit = bars - counted_bars;
else limit = bars - NDX_period - 1;

for(i = limit; i >= 0; i--)
{
double SumWght = 0, SumDnom = 0, DifAry, DnomAry, FracAry, TimeAry, WgtAry;
for(ii = 1; ii <= NDX_period; ii++)
{
DifAry = MathLog(Close[i+ii-1]) - MathLog(Close[i+ii]);
if(ii == 1) DnomAry = MathAbs(DifAry); else DnomAry += MathAbs(DifAry);
if(DnomAry == 0) FracAry = 0; else FracAry = (MathLog(Close) - MathLog(Close[i+ii])) / DnomAry;
TimeAry = 1 / MathPow(ii, 0.5);
WgtAry = FracAry * TimeAry;
SumWght += WgtAry;
SumDnom += TimeAry;
}
RawNDX = 100 * SumWght / SumDnom;
}
double ExpSmooth = 2, XAvg1, XAvg2, XAvg3;
ExpSmooth = ExpSmooth / (SmLen + 1);
for(i = bars - NDX_period - 1; i >= 0; i--)
{
XAvg1 += ExpSmooth * (RawNDX - XAvg1);
XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
maNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
if(i < bars - NDX_period - 1 - 3*SmLen)
{
if(maNDX > 90) NDX = MathRound(90 + (maNDX - 90) / 2);
else if(maNDX < -90) NDX = MathRound(-90 - (MathAbs(maNDX) - 90) / 2);
else NDX = MathRound(maNDX);
}
}

return(0);
}

int IntPortion(double param)
{
if (param > 0) return (MathFloor (param));
if (param < 0) return (MathCeil (param));
return (0);
}

//-----------------------------------------------------------


Here the quick direct translation from MT4 to AFL starter code.
No working well but see any member want to improve on it for you.
No time for it.

PHP:
NDX_period = Param("NDX Period",40, 1,999);
SmLen = Param("SmLen",20, 10,30);
//MaxBars = 0;


ndx=Null;

for(i = NDX_period; i <Barcount; i++)
{
	SumWght = 0; 
	SumDnom = 0; 
	DifAry=0;
	DnomAry=0;
	FracAry=0;
	TimeAry=0; 
	WgtAry=0;
	
	for(ii = 1; ii <= NDX_period; ii++)
	{
		DifAry = Log(Close[i-(ii-1)]) - Log(Close[i-ii]);
		if(ii == 1) 
			DnomAry = Abs(DifAry); 
		else 
			DnomAry += Abs(DifAry);
		if(DnomAry == 0) 
			FracAry = 0; 
		else 
			FracAry = (Log(Close[i]) - Log(Close[i-ii])) / DnomAry;
			
		TimeAry = 1 / sqrt(ii);
		WgtAry = FracAry * TimeAry;
		SumWght += WgtAry;
		SumDnom += TimeAry;
	}
	RawNDX[i] = 100 * SumWght / SumDnom;
}

ExpSmooth = 2;
ExpSmooth = ExpSmooth / (SmLen + 1);

XAvg1=0; XAvg2=0; XAvg3=0;
for(i = 0; i <Barcount; i++)
{
  XAvg1 += ExpSmooth * (RawNDX[i] - XAvg1);
  XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
  XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
  maNDX[i] = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
  //if(i < bars - NDX_period - 1 - 3*SmLen)
  {
     if(maNDX[i] > 90) 
       NDX[i] = Round(90 + (maNDX[i] - 90) / 2);
     else 
     if(maNDX[i] < -90) 
       NDX[i] = Round(-90 - (Abs(maNDX[i]) - 90) / 2);
     else 
       NDX[i] = Round(maNDX[i]);
  }
}

   PlotGrid(50, colorRed);
   PlotGrid(0, colorGrey50);
   PlotGrid(-50, colorGreen);

   Plot(ndx, "ndx", colorWhite);
 

amitrandive

Well-Known Member
Hi,
Could you please help me in converting this code into amibroker afl. thanks and appreciate your help.

-Krishna
.
.
.

}
//+------------------------------------------------------------------+
Originally Posted by Happy_Singh View Post
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .


Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .

As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .
Cheers

Happy
Please read the highlighted ,before quoting the original message.
Try a simple Google search

www.wises tocktr ader.com/indicators/251-woodie-s-cci-intraday-panel(remove spaces)

http://www.traderji.com/advanced-trading-strategies/37560-woodies-cci-trading-system.html#post405485
 

josh1

Well-Known Member
Hi Happy,
Below is code for 2 Timeframes candlestick bar.

I want to plot the higher TF bars to appear as High and Low. That is the entire body should be consist of High to Low point. No wick. can you help me? The higher TF is normally 60 min.

Code:
_SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");
// Specially designed for use in day trading and to save chart space. This chart will displays 2 sets
// of candlestick bars. One for the time interval set for your chart- for example 1 Minute. 
// The higher timeframe candlestick bars are created by using gfx low-level graphics AND will display  
// according to the parameters you set- for example 5 minutes. 

// I got the idea from David's (dbwyatt_1999) 2 Timeframe chart code which was shared by him on the AmiBroker List. 
// It uses TimeFrame functions with the PlotOHLC function using styleCloud. So I was thinking it would look 
// very nice using low-level graphics instead. Little bit more complicated, but I got a few great pointers from Herman!

// If your chart background turns pink- please read the error message in the upper left corner of the chart.
// Then please observe this AFL code uses ColorBlend(ColorFrom, ColorTo, Factor) which was introduced in Version 5.21 beta.
// The rules are simple- time frames from 1 up to 60 minutes AND Lower time frame must be smaller than the Higher time frame.

Version(5.21); 
SetChartOptions(2, chartShowDates);
Title = Name();
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// PARAMETERS AND SETTINGS:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ChartLum 		= Param("Chart Background Color Intensity", 0.40, 0, 1, 0.01);
TFMinShort		= Param("Short Timeframe (Minutes)", 1, 1, 60, 1);
TFMinLong 		= Param("Long Timeframe (Minutes)", 5, 1, 60, 1);
OnSTFBars		= ParamToggle("Short TF Bars", "Off, On", 1);
OnLTFBars		= ParamToggle("Long TF Bars", "Off, On", 1);
BarLum1 		= Param("Short TF Bar Color Intensity", 0, 0, 1, 0.01);
BarLum2 		= Param("Long TF Bar Color Intensity", 0.70, 0, 1, 0.01);

SetChartBkColor(ColorBlend(colorLightBlue, colorWhite, ChartLum));
// Bar Colors for the Short Timeframe candlestick bars:
LineColor 		= ColorBlend(colorBlack, colorWhite, BarLum1);
UpBarColor		= ColorBlend(colorBrightGreen, colorWhite, BarLum1);
DnBarColor		= ColorBlend(colorRed, colorWhite, BarLum1);
// Bar Colors For The Long Timeframe candlestick bars:
TFLineColor 	= ColorBlend(colorBlack, colorWhite, BarLum2 - 0.1);
TFUpBarColor	= ColorBlend(colorBrightGreen, colorWhite, BarLum2);
TFDnBarColor	= ColorBlend(colorRed, colorWhite, BarLum2);
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FUNCTIONS:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function GetVisibleBarCount() 
{ 
 lvb = Status("lastvisiblebar"); 
 fvb = Status("firstvisiblebar"); 
 return Min( Lvb - fvb, BarCount - fvb ); 
} 

function GfxConvertBarToPixelX( bar ) 
{ 
 lvb = Status("lastvisiblebar"); 
 fvb = Status("firstvisiblebar"); 
 pxchartleft = Status("pxchartleft"); 
 pxchartwidth = Status("pxchartwidth"); 
 return pxchartleft + bar  * pxchartwidth / ( Lvb - fvb + 1 ); 
} 

function GfxConvertValueToPixelY( Value ) 
{ 
 local Miny, Maxy, pxchartbottom, pxchartheight; 
 Miny = Status("axisminy"); 
 Maxy = Status("axismaxy"); 
 pxchartbottom = Status("pxchartbottom"); 
 pxchartheight = Status("pxchartheight"); 
 return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy - Miny ) ); 
} 

StaticVarKey = Name();
procedure xStaticVarSet(SName, SValue)
{
 global StaticVarKey;
 if (StaticVarKey != "")
 	StaticVarSet(Sname + StaticVarKey, Svalue);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// MAIN PROGRAM:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if(Interval() != TFMinShort * 60)
{
 Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "Set the chart time Interval to: " + NumToStr(TFMinShort, 1.0, 1) + 
					" Minute(s) or change the Short Timeframe Parameter setting.";
 OnSTFBars		= 0;
 OnLTFBars		= 0;
 SetChartBkColor(colorRose);
} 

if(TFMinShort >= TFMinLong)
{
 Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "The Long
Timeframe setting must be longer than the Short Timeframe!";
 OnSTFBars		= 0;
 OnLTFBars		= 0;
 SetChartBkColor(colorRose);
}

if(OnSTFBars)
{
 BarColor		= IIf(Close > Open, UpBarColor, DnBarColor);
 SetBarFillColor(BarColor);
 Plot(Close, "", LineColor, styleCandle);
}
else
 Plot(Close, "", colorBlack, styleCandle  | styleNoDraw);

TFSec = in1Minute * TFMinLong; 
TimeFrameSet(TFSec); 
TFOpen 			= Open; 
TFHigh 			= High; 
TFLow 				= Low; 
TFClose			= Close; 
TFBarIndex			= BarIndex();
TFLastBarIndex	= LastValue(BarIndex());
TimeFrameRestore(); 

TFOpen 			= TimeFrameExpand(TFOpen, TFSec, expandFirst); 
TFHigh 			= TimeFrameExpand(TFHigh, TFSec, expandFirst); 
TFLow 				= TimeFrameExpand(TFLow, TFSec, expandFirst); 
TFClose			= TimeFrameExpand(TFClose, TFSec, expandFirst);
TFBarIndex			= TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
TFLastBarIndex	= TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);

CandleTop 			= Max(TFOpen, TFClose); 
CandleBottom		= Min(TFOpen, TFClose); 
//============================================================================
// GFX LOW-LEVEL GRAPHICS SECTION.
// DRAWING THE LONG TIMEFRAME CANDLESTICK BARS:
//============================================================================
if(OnLTFBars)
{ 
 GfxSetOverlayMode(1); 
 AllVisibleBars 	= GetVisibleBarCount(); 
 fvb				= Status("firstvisiblebar"); 
 ChartWidth		= GfxConvertBarToPixelX(AllVisibleBars );
 PixBar 			= ChartWidth / AllVisibleBars;
 Adjust			= Pixbar * 0.35;
 TFMinutes 		= TFMinLong / TFMinShort;
 NewTFBar 			= IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);
 BarInd			= BarIndex();
 TFLastBarIndex	= LastValue(TFLastBarIndex);

 // DRAW BAR HISTORY AND THE CURRENT BAR:
 for(i = 0; i < AllVisibleBars; i++) 
 {
  x1 = GfxConvertBarToPixelX(i) * NewTFBar[i + fvb] - Adjust;
  if(BarInd[i + fvb] < TFLastBarIndex AND NewTFBar[i + fvb] == 1)
	 {
		Counter = 0;
		for(n = i + 1; NewTFBar[n + fvb] == 0 AND n + fvb < BarCount-1; n++)
			Counter++;
		x2 = GfxConvertBarToPixelX(i + Counter) * NewTFBar[i + fvb] + 1 + Adjust;
	 }

  if(TFBarIndex[i + fvb] == TFLastBarIndex)
 	x2 = GfxConvertBarToPixelX(i + TFMinutes - 1) * NewTFBar[i + fvb] + 1 + Adjust;

   y1 = GfxConvertValueToPixelY(CandleTop[i + fvb]); 
   y2 = GfxConvertValueToPixelY(CandleBottom[i + fvb]); 
   yH = GfxConvertValueToPixelY(TFHigh[i + fvb]);
   yL = GfxConvertValueToPixelY(TFLow[i + fvb]);

   // Candle Body:
   GfxSelectPen(TFLineColor, 0);
   FillColor = IIf(TFOpen[i + fvb] < TFClose[i + fvb], TFUpBarColor,TFDnBarColor);
   GfxSelectSolidBrush(FillColor); 
   if(y1 == y2){y1 = y1 - Adjust; y2 = y2 + Adjust;
	GfxSelectSolidBrush(TFLineColor);}
   if(x1 > 0){
   		GfxRectangle( x1, y1, x2, y2); 
   		// Candle High and Low:
   		GfxSelectPen(TFLineColor, 2);
   		GfxMoveTo(x2+(x1-x2)/2, y1);
   		GfxLineTo(x2+(x1-x2)/2, yH);
   		GfxMoveTo(x2+(x1-x2)/2, y2);
   		GfxLineTo(x2+(x1-x2)/2, yL);
   		RequestTimedRefresh(0); 
	}
 } 
}
_SECTION_END();

_SECTION_BEGIN("HighVol");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorGrey40)) ;

Layer = Param("Layer", 0, -5, 5, 1) ;
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorPaleGreen ) + " Open %g," + EncodeColor( colorSkyblue ) + " Hi %g, " 
+ EncodeColor( colorRed ) + " Lo %g, "  + EncodeColor( colorGold )+ " Close %g (%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//EncodeColor( colorBlack )+ Name() + " - " +Interval()/60 +" Min -" + Date()
Plot( C, "Close", ParamColor("Price",colorBlack), styleNoTitle | styleCandle,0,0,0,Layer );
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;

//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False);
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);

_SECTION_END();

_SECTION_BEGIN("SRSARTFtj");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF 
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

//	Rh = ParamField("High", 1) ;
//	Rl = ParamField("Low", 2) ;

tf = Param("TF", 3, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorTurquoise);
Clrdown = ParamColor( "Color Down", colorRose);
Clrsw = ParamColor( "Color SW", colorLavender);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0); 

styledisp = 0 ;
if (NOT showtitle)
	styledisp |= styleNoTitle ;

if (NOT showlabel)
	styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
	expandmode = expandLast ;

if (NOT alloff)
{
	Oldintrvl = Interval() ;

	if (usetf)
	{
		tfs = tf *in1Minute ;
		TimeFrameSet(tfs) ;
	}
	else
		tfs = Interval() ;

	if (isema)
		MAhtf = EMA(H, Periods) ;
	else
		MAhtf = MA(H, Periods) ;

	if (isema)
		MAltf = EMA(L, Periods) ;
	else
		MAltf = MA(L, Periods) ;

	str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
	Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp, 
			IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
			 Clrsw)) ;

	if (usetf)
		TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

	if (usetf)
		MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
	else
		MAhtfe = MAhtf ;

	if (usetf)
		MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
	else
		MAltfe = MAltf ;

	if (usetf)
		Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
	else
		Clre = Clr ;

	RefMAhtfe = MAhtfe ;
	RefMAltfe = MAltfe ;
	RefClre = Clre ;

	Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 ); 
	Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 ); 
	if (showzone)
		PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
	if (MAwidth > 0)
	{
		PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
		PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
	}	
	showext = ParamToggle("Show Extension", "No|Yes", 1)  ;
	showextband = ParamToggle("Show Extension Band", "No|Yes", 1)  ;
	extend = Param("Extend", 20, 0, 100, 1) ;
	showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

	if (showext)
	{
		x0 = BarCount - (extend+1) ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(RefMAhtfe) ;
		Ldlast = SelectedValue(RefMAltfe) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

		if (showextband)
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

	}

	showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

	if (showparam)
	{
		y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
		tfsd = tfs ;
		if (tfsd < Interval())
			tfsd = Interval() ;

		str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
		PlotText(str, BarCount+2, y, colorBlack) ;
	}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj1");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF 
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

//	Rh = ParamField("High", 1) ;
//	Rl = ParamField("Low", 2) ;

tf = Param("TF", 3, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorTurquoise);
Clrdown = ParamColor( "Color Down", colorRose);
Clrsw = ParamColor( "Color SW", colorLavender);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0); 

styledisp = 0 ;
if (NOT showtitle)
	styledisp |= styleNoTitle ;

if (NOT showlabel)
	styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
	expandmode = expandLast ;

if (NOT alloff)
{
	Oldintrvl = Interval() ;

	if (usetf)
	{
		tfs = tf *in1Minute ;
		TimeFrameSet(tfs) ;
	}
	else
		tfs = Interval() ;

	if (isema)
		MAhtf = EMA(H, Periods) ;
	else
		MAhtf = MA(H, Periods) ;

	if (isema)
		MAltf = EMA(L, Periods) ;
	else
		MAltf = MA(L, Periods) ;

	str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
	Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp, 
			IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
			 Clrsw)) ;

	if (usetf)
		TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

	if (usetf)
		MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
	else
		MAhtfe = MAhtf ;

	if (usetf)
		MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
	else
		MAltfe = MAltf ;

	if (usetf)
		Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
	else
		Clre = Clr ;

	RefMAhtfe = MAhtfe ;
	RefMAltfe = MAltfe ;
	RefClre = Clre ;

	Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 ); 
	Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 ); 
	if (showzone)
		PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
	if (MAwidth > 0)
	{
		PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
		PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
	}	
	showext = ParamToggle("Show Extension", "No|Yes", 1)  ;
	showextband = ParamToggle("Show Extension Band", "No|Yes", 1)  ;
	extend = Param("Extend", 20, 0, 100, 1) ;
	showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

	if (showext)
	{
		x0 = BarCount - (extend+1) ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(RefMAhtfe) ;
		Ldlast = SelectedValue(RefMAltfe) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

		if (showextband)
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

	}

	showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

	if (showparam)
	{
		y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
		tfsd = tfs ;
		if (tfsd < Interval())
			tfsd = Interval() ;

		str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
		PlotText(str, BarCount+2, y, colorBlack) ;
	}


}
_SECTION_END();
 
Hello Josh

Will check it and get back :thumb:

Happy :)


See if this serves your purpose . . .

Code:
_SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");
// Specially designed for use in day trading and to save chart space. This chart will displays 2 sets
// of candlestick bars. One for the time interval set for your chart- for example 1 Minute. 
// The higher timeframe candlestick bars are created by using gfx low-level graphics AND will display  
// according to the parameters you set- for example 5 minutes. 

// I got the idea from David's (dbwyatt_1999) 2 Timeframe chart code which was shared by him on the AmiBroker List. 
// It uses TimeFrame functions with the PlotOHLC function using styleCloud. So I was thinking it would look 
// very nice using low-level graphics instead. Little bit more complicated, but I got a few great pointers from Herman!

// If your chart background turns pink- please read the error message in the upper left corner of the chart.
// Then please observe this AFL code uses ColorBlend(ColorFrom, ColorTo, Factor) which was introduced in Version 5.21 beta.
// The rules are simple- time frames from 1 up to 60 minutes AND Lower time frame must be smaller than the Higher time frame.

Version(5.21); 
SetChartOptions(2, chartShowDates);
Title = Name();
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// PARAMETERS AND SETTINGS:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ChartLum 		= Param("Chart Background Color Intensity", 0.40, 0, 1, 0.01);
TFMinShort		= Param("Short Timeframe (Minutes)", 1, 1, 60, 1);
TFMinLong 		= Param("Long Timeframe (Minutes)", 5, 1, 60, 1);
OnSTFBars		= ParamToggle("Short TF Bars", "Off, On", 1);
OnLTFBars		= ParamToggle("Long TF Bars", "Off, On", 1);
BarLum1 		= Param("Short TF Bar Color Intensity", 0, 0, 1, 0.01);
BarLum2 		= Param("Long TF Bar Color Intensity", 0.70, 0, 1, 0.01);

//SetChartBkColor(ColorBlend(colorLightBlue, colorWhite, ChartLum));
// Bar Colors for the Short Timeframe candlestick bars:
LineColor 		= ColorBlend(colorBlack, colorWhite, BarLum1);
UpBarColor		= ColorBlend(colorBrightGreen, colorWhite, BarLum1);
DnBarColor		= ColorBlend(colorRed, colorWhite, BarLum1);
// Bar Colors For The Long Timeframe candlestick bars:
TFLineColor 	= ColorBlend(colorBlack, colorWhite, BarLum2 - 0.1);
TFUpBarColor	= ColorBlend(colorBrightGreen, colorWhite, BarLum2);
TFDnBarColor	= ColorBlend(colorRed, colorWhite, BarLum2);
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FUNCTIONS:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function GetVisibleBarCount() 
{ 
 lvb = Status("lastvisiblebar"); 
 fvb = Status("firstvisiblebar"); 
 return Min( Lvb - fvb, BarCount - fvb ); 
} 

function GfxConvertBarToPixelX( bar ) 
{ 
 lvb = Status("lastvisiblebar"); 
 fvb = Status("firstvisiblebar"); 
 pxchartleft = Status("pxchartleft"); 
 pxchartwidth = Status("pxchartwidth"); 
 return pxchartleft + bar  * pxchartwidth / ( Lvb - fvb + 1 ); 
} 

function GfxConvertValueToPixelY( Value ) 
{ 
 local Miny, Maxy, pxchartbottom, pxchartheight; 
 Miny = Status("axisminy"); 
 Maxy = Status("axismaxy"); 
 pxchartbottom = Status("pxchartbottom"); 
 pxchartheight = Status("pxchartheight"); 
 return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy - Miny ) ); 
} 

StaticVarKey = Name();
procedure xStaticVarSet(SName, SValue)
{
 global StaticVarKey;
 if (StaticVarKey != "")
 	StaticVarSet(Sname + StaticVarKey, Svalue);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// MAIN PROGRAM:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if(Interval() != TFMinShort * 60)
{
 Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "Set the chart time Interval to: " + NumToStr(TFMinShort, 1.0, 1) + 
					" Minute(s) or change the Short Timeframe Parameter setting.";
 OnSTFBars		= 0;
 OnLTFBars		= 0;
// SetChartBkColor(colorRose);
} 

if(TFMinShort >= TFMinLong)
{
 Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "The Long
Timeframe setting must be longer than the Short Timeframe!";
 OnSTFBars		= 0;
 OnLTFBars		= 0;
 //SetChartBkColor(colorRose);
}

if(OnSTFBars)
{
 BarColor		= IIf(Close > Open, UpBarColor, DnBarColor);
 SetBarFillColor(BarColor);
 Plot(Close, "", LineColor, styleCandle);
}
else
 Plot(Close, "", colorBlack, styleCandle  | styleNoDraw);

TFSec = in1Minute * TFMinLong; 
TimeFrameSet(TFSec); 

//Happy Changes Start
//TFOpen 			= Open; 
TFOpen 			= IIf(C>O,L,H);
TFClose			= IIf(C>O,H,L);
//TFClose			= Close; 
//Happy Changes End

TFHigh 			= High; 
TFLow 				= Low; 
TFBarIndex			= BarIndex();
TFLastBarIndex	= LastValue(BarIndex());
TimeFrameRestore(); 

TFOpen 			= TimeFrameExpand(TFOpen, TFSec, expandFirst); 
TFHigh 			= TimeFrameExpand(TFHigh, TFSec, expandFirst); 
TFLow 				= TimeFrameExpand(TFLow, TFSec, expandFirst); 
TFClose			= TimeFrameExpand(TFClose, TFSec, expandFirst);
TFBarIndex			= TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
TFLastBarIndex	= TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);

CandleTop 			= Max(TFOpen, TFClose); 
CandleBottom		= Min(TFOpen, TFClose); 
//============================================================================
// GFX LOW-LEVEL GRAPHICS SECTION.
// DRAWING THE LONG TIMEFRAME CANDLESTICK BARS:
//============================================================================
if(OnLTFBars)
{ 
 GfxSetOverlayMode(1); 
 AllVisibleBars 	= GetVisibleBarCount(); 
 fvb				= Status("firstvisiblebar"); 
 ChartWidth		= GfxConvertBarToPixelX(AllVisibleBars );
 PixBar 			= ChartWidth / AllVisibleBars;
 Adjust			= Pixbar * 0.35;
 TFMinutes 		= TFMinLong / TFMinShort;
 NewTFBar 			= IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);
 BarInd			= BarIndex();
 TFLastBarIndex	= LastValue(TFLastBarIndex);

 // DRAW BAR HISTORY AND THE CURRENT BAR:
 for(i = 0; i < AllVisibleBars; i++) 
 {
  x1 = GfxConvertBarToPixelX(i) * NewTFBar[i + fvb] - Adjust;
  if(BarInd[i + fvb] < TFLastBarIndex AND NewTFBar[i + fvb] == 1)
	 {
		Counter = 0;
		for(n = i + 1; NewTFBar[n + fvb] == 0 AND n + fvb < BarCount-1; n++)
			Counter++;
		x2 = GfxConvertBarToPixelX(i + Counter) * NewTFBar[i + fvb] + 1 + Adjust;
	 }

  if(TFBarIndex[i + fvb] == TFLastBarIndex)
 	x2 = GfxConvertBarToPixelX(i + TFMinutes - 1) * NewTFBar[i + fvb] + 1 + Adjust;

   y1 = GfxConvertValueToPixelY(CandleTop[i + fvb]); 
   y2 = GfxConvertValueToPixelY(CandleBottom[i + fvb]); 
   yH = GfxConvertValueToPixelY(TFHigh[i + fvb]);
   yL = GfxConvertValueToPixelY(TFLow[i + fvb]);

   // Candle Body:
   GfxSelectPen(TFLineColor, 0);
   FillColor = IIf(TFOpen[i + fvb] < TFClose[i + fvb], TFUpBarColor,TFDnBarColor);
   GfxSelectSolidBrush(FillColor); 
   if(y1 == y2){y1 = y1 - Adjust; y2 = y2 + Adjust;
	GfxSelectSolidBrush(TFLineColor);}
   if(x1 > 0){
   		GfxRectangle( x1, y1, x2, y2); 
   		// Candle High and Low:
   		GfxSelectPen(TFLineColor, 2);
   		GfxMoveTo(x2+(x1-x2)/2, y1);
   		GfxLineTo(x2+(x1-x2)/2, yH);
   		GfxMoveTo(x2+(x1-x2)/2, y2);
   		GfxLineTo(x2+(x1-x2)/2, yL);
   		RequestTimedRefresh(0); 
	}
 } 
}
_SECTION_END();
 
Last edited:
Here the quick direct translation from MT4 to AFL starter code.
No working well but see any member want to improve on it for you.
No time for it.

PHP:
NDX_period = Param("NDX Period",40, 1,999);
SmLen = Param("SmLen",20, 10,30);
//MaxBars = 0;


ndx=Null;

for(i = NDX_period; i <Barcount; i++)
{
	SumWght = 0; 
	SumDnom = 0; 
	DifAry=0;
	DnomAry=0;
	FracAry=0;
	TimeAry=0; 
	WgtAry=0;
	
	for(ii = 1; ii <= NDX_period; ii++)
	{
		DifAry = Log(Close[i-(ii-1)]) - Log(Close[i-ii]);
		if(ii == 1) 
			DnomAry = Abs(DifAry); 
		else 
			DnomAry += Abs(DifAry);
		if(DnomAry == 0) 
			FracAry = 0; 
		else 
			FracAry = (Log(Close[i]) - Log(Close[i-ii])) / DnomAry;
			
		TimeAry = 1 / sqrt(ii);
		WgtAry = FracAry * TimeAry;
		SumWght += WgtAry;
		SumDnom += TimeAry;
	}
	RawNDX[i] = 100 * SumWght / SumDnom;
}

ExpSmooth = 2;
ExpSmooth = ExpSmooth / (SmLen + 1);

XAvg1=0; XAvg2=0; XAvg3=0;
for(i = 0; i <Barcount; i++)
{
  XAvg1 += ExpSmooth * (RawNDX[i] - XAvg1);
  XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
  XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
  maNDX[i] = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
  //if(i < bars - NDX_period - 1 - 3*SmLen)
  {
     if(maNDX[i] > 90) 
       NDX[i] = Round(90 + (maNDX[i] - 90) / 2);
     else 
     if(maNDX[i] < -90) 
       NDX[i] = Round(-90 - (Abs(maNDX[i]) - 90) / 2);
     else 
       NDX[i] = Round(maNDX[i]);
  }
}

   PlotGrid(50, colorRed);
   PlotGrid(0, colorGrey50);
   PlotGrid(-50, colorGreen);

   Plot(ndx, "ndx", colorWhite);
Thanks to KelvinHand , and god bless you :clap::clap:
 

KelvinHand

Well-Known Member
Hello Josh

Will check it and get back :thumb:

Happy :)


See if this serves your purpose . . .

Code:
_SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");
// Specially designed for use in day trading and to save chart space. This chart will displays 2 sets
// of candlestick bars. One for the time interval set f[/QUOTE]


Simple.

1. Draw Rect to High and Low of candle 
    --Remark y1, y2
   /*
     y1 = GfxConvertValueToPixelY(CandleTop[i + fvb]); 
     y2 = GfxConvertValueToPixelY(CandleBottom[i + fvb]); 
   */
   
   --Remove yH, YL, assign y1, y2
  // yH = GfxConvertValueToPixelY(TFHigh[i + fvb]);
  // yL = GfxConvertValueToPixelY(TFLow[i + fvb]);

   y1 = GfxConvertValueToPixelY(TFHigh[i + fvb]);
   y2 = GfxConvertValueToPixelY(TFLow[i + fvb]);


2.  Remove the following Candle Shadow
               GfxRectangle( x1, y1, x2, y2); 

   		// Candle High and Low:
   		/*
   		GfxSelectPen(TFLineColor, 2);
   		GfxMoveTo(x2+(x1-x2)/2, y1);
   		GfxLineTo(x2+(x1-x2)/2, yH);
   		GfxMoveTo(x2+(x1-x2)/2, y2);
   		GfxLineTo(x2+(x1-x2)/2, yL);
   		*/
 
Last edited:

josh1

Well-Known Member
Hello Josh

Will check it and get back :thumb:

Happy :)

Hello,

I got it.
CandleTop = max(TFOpen, TFClose);
CandleBottom = min(TFOpen, TFClose);
was to be changed to

CandleTop = TFHigh;
CandleBottom = TFLow. So dumb of me :)

But this one seems to be slow.

Instead, is it possible to just fill the area between hourly High Low with desired color?

Edit - Will check KelvinHand's solution also.
 

toocool

Well-Known Member
Ok here is the thing I wanted an ATR trailing stop loss afl which could be properly modified for number of bars and basic style of ATR trailing method which could be plotted right below candles for stop loss visibility easily and amibroker ATR thingy didn't work as it didn't have any settings .

Now I have got such an afl from some one and it looks fantastic but I don't know it's proper settings however it feels that the afl is very good and properly made

_SECTION_BEGIN("ATR Stop");
P = ParamField("Price field",3);
ATRP = Param( "ATR Period", 5, 1, 10, 1 );
factor = Param( "Multiple", 2, -10, 10, 0.25 );
stop = P + ATR(ATRP) * factor ;
Plot( stop, "ATR Stop", ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();


hi guys there is an issue in this afl the stop loss calculated but this afl is not getting violated at all even after downswing after a bull run , its like a moving average which never gets touched , can you guys correct this ?:)

thanks
 
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",colorBlack,styleCandle);

_SECTION_BEGIN("Fibo Pivots");
PH = DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
PL = DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
PC = DayC = TimeFrameGetPrice("C", inDaily, -1); DayCI = LastValue (DayC,1);// yesterdays close
PR = PH - PL;

numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
R=PH-PL;//range
Today = LastValue(Day());
P=(PH+PL+PC)/3; pI = LastValue (p,1);// Standard Pivot
fr1 = p + (R * 0.38); fr1I = LastValue (fr1,1);
fr2 = p + (R * 0.62); fr2I = LastValue (fr2,1);
fr3 = p + (R * 0.99); fr3I = LastValue (fr3,1);
fs1 = p - (R * 0.38); fs1I = LastValue (fs1,1);
fs2 = p - (R * 0.62); fs2I = LastValue (fs2,1);
fs3 = p - (R * 0.99); fs3I = LastValue (fs3,1);

Plot(IIf(Today == Day(),p,Null), "pivot",colorBlue,styleDashed|styleLine|styleNoRescale|styleNoTitle);
//Plot(p,"Pivot",colorBlue,styleDots|styleNoLine|styleNoRescale);
Plot(IIf(Today == Day(),fr1,Null), "R1",colorRed,styleDashed|styleLine|styleNoRescale);
Plot(IIf(Today == Day(),fr2,Null),"R2",colorPink,styleDashed|styleLine|styleNoRescale);
Plot(IIf(Today == Day(),fr3,Null),"R3",colorRose,styleDashed|styleLine|styleNoRescale);
Plot(IIf(Today == Day(),fs1,Null),"S1",colorGreen,styleDashed|styleLine|styleNoRescale);
Plot(IIf(Today == Day(),fs2,Null),"S2",colorLime,styleDashed|styleLine|styleNoRescale);
Plot(IIf(Today == Day(),fs3,Null),"S3",colorPaleGreen,styleDashed|styleLine|styleNoRescale);
PlotText(" Pivot ", LastValue(BarIndex())-(numbars/Hts), pI, colorBlue);
PlotText(" Fib R1 " , LastValue(BarIndex())-(numbars/Hts), fr1I, colorRed);
PlotText(" Fib R2 " , LastValue(BarIndex())-(numbars/Hts), fr2I, colorPink);
PlotText(" Fib R3 " , LastValue(BarIndex())-(numbars/Hts), fr3I, colorRose);
PlotText(" Fib S1 " , LastValue(BarIndex())-(numbars/Hts), fs1I, colorGreen);
PlotText(" Fib S2 " , LastValue(BarIndex())-(numbars/Hts), fs2I, colorLime);
PlotText(" Fib S3 " , LastValue(BarIndex())-(numbars/Hts), fs3I, colorPaleGreen);
_SECTION_END();
Today = LastValue(Day());
Plot(IIf(Today == Day(),DayH,Null), "YDH",colorRed,styleDashed|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),DayL,Null), "YDL",colorGreen,styleDashed|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),DayC,Null), "YDC",colorBlue,styleDashed|styleLine|styleNoRescale|styleNoTitle);
PlotText(" YdayL ", LastValue(BarIndex()), DayLI, colorGreen);
PlotText(" YdayH " , LastValue(BarIndex()), DayHI, colorRed);
PlotText(" YdayC " , LastValue(BarIndex()), DayCI, colorBlue);


Dear Ajit Here is required formula.

Maruti Mane
 

Similar threads