Simple Coding Help - No Promise.

_SECTION_BEGIN("Price");
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("Price 131");
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0 ,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0 ,L,-20);

Title =
EncodeColor(colorBlack)+ "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorBlack)+ Interval(2)
+ EncodeColor(colorBlack) + " | " + Date() +" | "
+"\n"+EncodeColor(1) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + " | Volume : "+ WriteVal(V,1.0)+
"\n"+ EncodeColor(colorBlack)+"\n"+
EncodeColor(colorBlack) + "Day's Range = " + EncodeColor(colorBlack) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
EncodeColor(colorBlack) + "Day's Hi = " + EncodeColor(colorBlack) + Hiday + "\n" +
EncodeColor(colorBlack) + "Day's Lo= " + EncodeColor(colorBlack) + Loday ;

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;

YHL = 1;
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorBlack);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorBlack);
}
_SECTION_END();

_SECTION_BEGIN("Price 131");
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0 ,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0 ,L,-20);

Title =
EncodeColor(colorBlack)+ "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorBlack)+ Interval(2)
+ EncodeColor(colorBlack) + " | " + Date() +" | "
+"\n"+EncodeColor(1) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + " | Volume : "+ WriteVal(V,1.0)+
"\n"+ EncodeColor(colorBlack)+"\n"+
EncodeColor(colorBlack) + "Day's Range = " + EncodeColor(colorBlack) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
EncodeColor(colorBlack) + "Day's Hi = " + EncodeColor(colorBlack) + Hiday + "\n" +
EncodeColor(colorBlack) + "Day's Lo= " + EncodeColor(colorBlack) + Loday ;

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;

YHL = 1;
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorBlack);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorBlack);
}
_SECTION_END();






This AFL is showing just today range, i am in need of afl which shows yesterday range & average of last 5 trading session & average of last 20 trading session on screen.

so i can compare how much movement more left in script.

for example if daily range of silver is 800 point & if i can see today it moved just 400 point till eve, i will buy it above high or sell below low for 400 pt tgt.

but current afl showing just today range, can u help pls.

THKS
 

Nehal_s143

Well-Known Member
Found Afl based on Jesse Livermore Secret Market Key method at
http : / / www . amibroker . com /library/detail.php?id=1267

//------------------------------------------------------------------------------
// Formula Name : Project Freedom - Jesse Livermore Secret Market Key
// Author : KH Tang
// Date Updated : 30 Apr 2007
// Origin : Personal Study and Understanding of Livermore's work
// Version : 1.0
// Blog : http://blessedfool.gaia.com/blog
//------------------------------------------------------------------------------

/*
//------------------------------------------------------------------------------
Program Overview

This program classifies price action into the following states based upon rules

his book - "How to Trade in Stocks"

StateNo1 - Up Trend
StateNo2 - Nat Rally
StateNo3 - Sec Rally
StateNo4 - Dn Trend
StateNo5 - Nat React
StateNo6 - Sec React

State change is determined by a user specified threshold of price change.
The program also determines a number of pivot points:

UpTrendPP - Peak Up Trend Price
NatRallyPP - Peak Nat Rally Price
DnTrendPP - Bottom Dn Trend Price
NatReactPP - Bottom Nat React Price

This program may be used as a basis for a number of studies:
- trend paint bars,
- pivot price indicator lines
- strategies (trend following AND/OR breakout/breakDn)

For detailed explanation of the system Jesse Livermore Orginal Work.
Note: Livermore's system used a threshold of 6 points for stocks priced
over $30.
For modern Market, due to different markets has wide range of prices. The
threshold price is set in Percentage...(default 10%)

//------------------------------------------------------------------------------
*/

// General Graphic Control
GraphXSpace = 15;

SetChartBkGradientFill( ParamColor("BgTop", colorSkyblue),
ParamColor("BgBottom",
colorWhite),ParamColor("titleblock",colorWhite));

ThresholdPercentValue = Param("Threshold in Percent units",10,4,15,1);

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

if(i==0)
{ //Initialization
//var:
StateNo=1;
InUpTrend=True;
InDnTrend=False;

SecRally = NatRally = UpTrend = Close;
SecReact = NatReact = DnTrend =Close;

NatRallyReset=True;
NatReactReset=True;

UpTrendPP=C[0];
NatRallyPP=C[0];
NatReactPP=C[0];
DnTrendPP=C[0];

} //end;

else //{Main}
{ //begin //{calc current Threshold if required}

// Memory Refresh Manually... Work like refreshing the D-Ram.
// This is the fastest trick to handle the issue with AMI-AFL. (KH Tang)
// With this, one can program anything in a flowchart. :)

StateNo=StateNo[i-1];
InUpTrend=InUpTrend[i-1];
InDnTrend=InDnTrend[i-1];

UpTrend = UpTrend[i-1];
NatRally = NatRally[i-1];
SecRally = SecRally[i-1];
SecReact = SecReact[i-1];
NatReact = NatReact[i-1];
DnTrend = DnTrend[i-1];

NatRallyReset=NatRallyReset[i-1];
NatReactReset=NatReactReset[i-1];

UpTrendPP=UpTrendPP[i-1];
NatRallyPP=NatRallyPP[i-1];
NatReactPP=NatReactPP[i-1];
DnTrendPP=DnTrendPP[i-1];

ThresholdPct=ThresholdPercentValue/100;


//------------------------------------------------------------------------------
//111111111111111111111111111111111111111111111111111111111111111111111111111111
//------------------------------------------------------------------------------
//State No 1: In Up Trend Column
if(StateNo[i-1]==1)//
{//UpTrend Routine
if(C>=C[i-1])
{//Price Move Up
if(C>UpTrend)
{
StateNo=1;//Remain in UpTrend - 1111111111111111111111111111111
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
}
}//End of Price Move Up
else
{//Price Move Dn
if((InDnTrend AND C<DnTrendPP) OR //PivotPoint Check
(InUpTrend AND C< UpTrend/(1+2*ThresholdPct)) )
{//Drop to DnTrend
StateNo=6;//Dn Trend - 6666666666666666666666666666666666666666
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
UpTrendPP=UpTrend;
}// End of Drop to DnTrend
else
{
if(C<(UpTrend/(1+ThresholdPct)))
{//Drop Below Current State React
if(NatReactReset OR C < NatReact)
{//First Time or Below NatReact
StateNo=5;//Nat React - 55555555555555555555555555555555
NatReactReset=False;
NatReact=C;
UpTrendPP=UpTrend;
}//End of First Time or Below NatReact
else
{//Drop to SecReact
StateNo=4;//SecReact - 444444444444444444444444444444444
SecReact=C;
UpTrendPP=UpTrend;
}//End of Drop to SecReact
}
}//End of Drop Below Current Price React
}//End of Price Move Dn
}//End of UpTrend Routine

//------------------------------------------------------------------------------
//222222222222222222222222222222222222222222222222222222222222222222222222222222
//------------------------------------------------------------------------------
//State No 2: In Nat Rally Column
else if(StateNo[i-1]==2)//
{//NatRally Routine
//NatRallyReset=False;

if(C>C[i-1])
{//Price Move Up
if( (InUpTrend AND C>UpTrendPP) OR
(InDnTrend AND C> DnTrend*(1+2*ThresholdPct)) )
{//Price move to UpTrend - 1111111111111111111111111111111111111111111
StateNo=1;
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
}//End of Price Move to UpTrend
else
{
if(C>NatRally)
{//Price Continue to move to higher NatRally
StateNo=2;//Remain in NatRally - 222222222222222222222222222
NatRally=C;
NatRallyReset=False;
}//End of Price Continue to move to higher NatRally
}
}//End of Price Move Up
else //of(C>C[i-1])
{//Price Move Dn
if((InDnTrend AND C<DnTrendPP) OR
(InUpTrend AND C< UpTrend/(1+2*ThresholdPct)) )
{//Drop to DnTrend
StateNo=6;//Dn Trend - 6666666666666666666666666666666666666666
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
NatRallyPP=NatRally;
}// End of Drop to DnTrend
else
{
if(C<(NatRally/(1+ThresholdPct)))
{//Drop Below Current State React
if(NatReactReset OR C < NatReact)
{//First Time or Below NatReact
StateNo=5;//Nat React - 55555555555555555555555555555555
NatReactReset=False;
NatReact=C;
NatRallyPP=NatRally;
}//End of First Time or Below NatReact
else
{//Drop to SecReact
StateNo=4;//SecReact - 444444444444444444444444444444444
SecReact=C;
NatRallyPP=NatRally;
}//End of Drop to SecReact
}
}//End of Drop Below Current Price React
}//End of Price Move Dn
}//End of NatRally Routine

//------------------------------------------------------------------------------
//333333333333333333333333333333333333333333333333333333333333333333333333333333
//------------------------------------------------------------------------------
//State No 3: In Sec Rally Column
else if(StateNo[i-1]==3) //
{//SecRally Routine
if(C>C[i-1])
{//Price Move Up
if( (InUpTrend AND C>UpTrendPP) OR
(InDnTrend AND C> DnTrend*(1+2*ThresholdPct)) )
{//Price move to UpTrend - 1111111111111111111111111111111111111111111
StateNo=1;
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
}//End of Price Move to UpTrend
else
{
if(C>NatRally)
{//Price Continue to move to higher NatRally
StateNo=2;//Remain in NatRally - 222222222222222222222222222
NatRally=C;
NatRallyReset=False;

}//End of Price Continue to move to higher NatRally
else
{//Remain at SecRally State
if(C>SecRally)
{//New Higher Sec Price - 3333333333333333333333333333333333333
StateNo=3;//Remain in SecRally State
SecRally=C;//Update new higher price
}//End of New Higher Sec Price
}//End of Remain at Sec State
}
}//End of Price Move Up
else //of(C>C[i-1])
{//Price Move Dn
if((InDnTrend AND C<DnTrendPP) OR
(InUpTrend AND C< UpTrend/(1+2*ThresholdPct)) )
{//Drop to DnTrend
StateNo=6;//Dn Trend - 666666666666666666666666666666666666666 6
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
}// End of Drop to DnTrend
else
{
if(C<(SecRally/(1+ThresholdPct)))
{//Drop Below Current State React
if(C < NatReact)
{//First Time or Below NatReact
StateNo=5;//Nat React - 55555555555555555555555555555555
NatReact=C;
}//End of First Time or Below NatReact
else
{//Drop to SecReact
StateNo=4;//SecReact - 444444444444444444444444444444444
SecReact=C;
}//End of Drop to SecReact
}
}//End of Drop Below Current Price React
}//End of Price Move Dn
}//End of SecRally Routine

//------------------------------------------------------------------------------
//444444444444444444444444444444444444444444444444444444444444444444444444444444
//------------------------------------------------------------------------------
//State No 4: In Sec React Column
//Note that these two state are sharing the same processing routine
else if(StateNo[i-1]==4)//
{//SecReact Routine

if(C>C[i-1])
{//Price Move Up
if( (InUpTrend AND C>UpTrendPP) OR
(InDnTrend AND C> DnTrend*(1+2*ThresholdPct)) )
{//Price move to UpTrend - 1111111111111111111111111111111111111111111
StateNo=1;
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
}//End of Price Move to UpTrend
else
{
if(C>(SecReact*(1+ThresholdPct)))
{//Raise Above Current State React
if(C>NatRally)
{
StateNo=2;//Move to NatRally - 2222222222222222222222
NatRally=C;
NatRallyReset=False;
}
else
{//Raise to SeconaryRally
StateNo=3;//Raise to SecRally - 333333333333333333333
SecRally=C;
}//End of Raise to SecRally
}// End of Raise Above Current State React
}
}//End of Price Move Up
else //of(C>C[i-1])
{//Price Move Dn
if((InDnTrend AND C<DnTrendPP) OR
(InUpTrend AND C< UpTrend/(1+2*ThresholdPct)) )
{//Drop to DnTrend
StateNo=6;//Dn Trend - 6666666666666666666666666666666666666666
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
}// End of Drop to DnTrend
else
{
if(C<NatReact)
{//Raise Above NatReact
StateNo=5;//NatReact - 5555555555555555555555555555555555555
NatReact=C;
}//Raise Above NatReact
else
{//Remain at SecReact
if(C<SecReact)
{//Lower SecReact
SecReact=C;
}//End of Lower SecReact
}//End of Remain at SecReact
}
}//End of Price Move Dn
}//End of Sec React Routine

//------------------------------------------------------------------------------
//555555555555555555555555555555555555555555555555555555555555555555555555555555
//------------------------------------------------------------------------------
//State No 5: In Nat React Column
else if(StateNo[i-1]==5)//
{//NatReact Routine
//NatReactReset=False;
if(C>C[i-1])
{//Price Move Up
if( (InUpTrend AND C>UpTrendPP) OR
(InDnTrend AND C> DnTrend*(1+2*ThresholdPct)) )
{//Price move to UpTrend - 1111111111111111111111111111111111111111111
StateNo=1;
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
NatReactPP=NatReact;
}//End of Price Move to UpTrend
else
{
if(C>(NatReact*(1+ThresholdPct)))
{//Raise Above Current State React
if(NatRallyReset OR C>NatRally)
{
StateNo=2;//Move to NatRally - 2222222222222222222222
NatRallyReset=False;
NatRally=C;
NatReactPP=NatReact;
}
else
{//Raise to SeconaryRally
StateNo=3;//Raise to SecRally - 333333333333333333333
SecRally=C;
NatReactPP=NatReact;
}//End of Raise to SecRally
}// End of Raise Above Current State React
}
}//End of Price Move Up
else //of(C>C[i-1]) - Common with State 1
{//Price Move Dn
if((InDnTrend AND C<DnTrendPP) OR
(InUpTrend AND C< UpTrend/(1+2*ThresholdPct)) )
{//Drop to DnTrend
StateNo=6;//Dn Trend - 6666666666666666666666666666666666666666
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
}// End of Drop to DnTrend
else
{
if(C<NatReact)
{//Raise Above NatReact
StateNo=5;//NatReact - 5555555555555555555555555555555555555
NatReact=C;
}//Raise Above NatReact
}
}//End of Price Move Dn
}//End of NatReact Routine
//------------------------------------------------------------------------------
//666666666666666666666666666666666666666666666666666666666666666666666666666666
//------------------------------------------------------------------------------
//State No 6: In Dn Trend Column
else if(StateNo[i-1]==6)//
// Must be in State No 6
{//DnTrend Routine
if(C>C[i-1])
{//Price Move Up
if( (InUpTrend AND C>UpTrendPP) OR
(InDnTrend AND C> DnTrend*(1+2*ThresholdPct)) )
{//Price move to UpTrend - 1111111111111111111111111111111111111111111
StateNo=1;
InUpTrend=True;
InDnTrend=False;
UpTrend=C;
DnTrendPP=DnTrend;
}//End of Price Move to UpTrend
else
{
if(C>(DnTrend*(1+ThresholdPct)))
{//Raise Above Current State React
if(NatRallyReset OR C>NatRally)
{
StateNo=2;//Move to NatRally - 2222222222222222222222
NatRallyReset=False;
NatRally=C;
DnTrendPP=DnTrend;
}
else
{//Raise to SeconaryRally
StateNo=3;//Raise to SecRally - 333333333333333333333
SecRally=C;
DnTrendPP=DnTrend;
}//End of Raise to SecRally
}// End of Raise Above Current State React
}
}//End of Price Move Up
else //of(C>C[i-1]) - Common with State 1
{//Price Move Dn
if(C<DnTrend)
{//Price move futher Dn
StateNo=6;//Dn Trend - 6666666666666666666666666666666666666666
InDnTrend=True;
InUpTrend=False;
DnTrend=C;
}//End of Price move Futher Dn
}//End of Price Move Dn
}//End of DnTrend Routine

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

//Checking and Processing Parameters here...
//Reset Value of Rally and React Values if needed

// React Values become Obseleted Price moved to high up. Reset them.
if(InUpTrend AND NatReact < UpTrend/(1+2*ThresholdPct) )
{
NatReactReset=True;
}
// Rally Values become Obaseleted as Price move to low Dn. Reset them
if(InDnTrend AND NatRally > DnTrend*(1+2*ThresholdPct) )
{
NatRallyReset=True;
}

} //end; //{main}
} //End of For i Loop!

//Plotting Section - Just for testing

//InUpTrend
WeightNo= IIf(StateNo==1,5, // UpTrend
IIf(InUpTrend AND StateNo==5,1, // and NatReact
IIf(InUpTrend AND StateNo==2,4, // and NatRally
IIf(InUpTrend AND StateNo==4,2, // and SecReact
IIf(InUpTrend AND StateNo==3,3, // and SecRally
IIf(StateNo==6,-5, // DownTrend
IIf(InDnTrend AND StateNo==2,-1, // and NatRally
IIf(InDnTrend AND StateNo==5,-4, // and NatReact
IIf(InDnTrend AND StateNo==3,-2, // and SecRally
-3 // and SecReact
)))))))));

Plot(WeightNo,"Livermore Secret Market Key Stage Diagram",IIf(WeightNo>0 AND
WeightNo==5,colorGreen,
IIf(WeightNo>0,colorBlue,
IIf(WeightNo<0 AND WeightNo==-5,colorRed,colorPink))),styleStaircase);
Plot(0,"",colorBlack,styleNoLabel);

//End of Livermore Market Key Section

Above afl works only on eod data

For intraday use, need to replace this line :
ThresholdPercentValue = Param( \"Threshold in Percent units\", 0.10, 0.01, 15, 0.01 );


but i think some problem, intraday chart not getting plotted properly even after replacing with above lines
 

toughard

Well-Known Member
hi every one.
 
Last edited:
Hi,
I need some help with AFL coding.
What I want to have is simple text alerts when:
1) price hits new DAILY lows
2) price hits new DAILY heights
3) change between last price and previous day close i 0%
4)change between last price and current day Open is 0.

I use Amibroker Professional version so I can use function GetRTData:

I tried this:

x1=GetRTData("Last");
x2=GetRTData("Open");
x3=GetRTData("High");
x4=GetRTData("Low");
x5=GetRTData("Prev");

AlertIf(x2-x1=0,"","Open",1);
AlertIf(x3-x1=0,"","NewHigh",1);
AlertIf(x4-x1=0,"","NewLow",1);
AlertIf(x5-x1=0,"","Zero",1);

..but, in Alertif function there is lookback parameter.
How can I change lookback parameter to show only current day quotes.
I can't set this parameter to fixed number because I use 1min bars and in the first few minutes of the session it will takes numbers from previous day bars.
Maybe there is another way to run this simple alerts..

Thank You in advance
Marek
 
Found Afl based on Jesse Livermore Secret Market Key method at
http://www.amibroker.com/library/detail.php?id=1267

....

but i think some problem, intraday chart not getting plotted properly even after replacing with above lines
And what is the problem...? This code seems to be simple straight forward "finite state machine" progression and a great thing to do would be draw the FSM of it first.
 
_SECTION_BEGIN("Price");

....

This AFL is showing just today range, i am in need of afl which shows yesterday range & average of last 5 trading session & average of last 20 trading session on screen.

....
I am no expert but the best way to learn is to code - especially build on existing code. There may be other (better!) ways but is this what you were looking for?

Code:
_SECTION_BEGIN("Hi-Lo");

HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0,L,-20);

TimeFrameSet(inDaily);
DR=H-L;
DR5=MA(DR,5);
DR20=MA(DR,20);
TimeFrameRestore();

DRE=TimeFrameExpand(DR,inDaily);
DR5E=TimeFrameExpand(DR5,inDaily);
DR20E=TimeFrameExpand(DR20,inDaily);

Title = EncodeColor(colorYellow) + "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorYellow)+ Interval(2) + 
        EncodeColor(colorYellow) + " | " + Date() +" | "+"\n" +
		 EncodeColor(colorYellow) + "Today's Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
		 EncodeColor(colorYellow) + "Today's Hi = " + EncodeColor(colorYellow) + Hiday + "\n" +
		 EncodeColor(colorYellow) + "Today's Lo = " + EncodeColor(colorYellow) + Loday + "\n" +
		 EncodeColor(colorYellow) + "Yesterday's Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DRE, 1.2)) + "\n" +
		 EncodeColor(colorYellow) + "5 Day MA of Daily Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DR5E,1.2)) + "\n" +
		 EncodeColor(colorYellow) + "20 Day MA of Daily Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DR20E,1.2)) ;

_SECTION_END();
Disclaimer: my first post in this forum - finally. :D
 
I am no expert but the best way to learn is to code - especially build on existing code. There may be other (better!) ways but is this what you were looking for?

Code:
_SECTION_BEGIN("Hi-Lo");

HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0,L,-20);

TimeFrameSet(inDaily);
DR=H-L;
DR5=MA(DR,5);
DR20=MA(DR,20);
TimeFrameRestore();

DRE=TimeFrameExpand(DR,inDaily);
DR5E=TimeFrameExpand(DR5,inDaily);
DR20E=TimeFrameExpand(DR20,inDaily);

Title = EncodeColor(colorYellow) + "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorYellow)+ Interval(2) + 
        EncodeColor(colorYellow) + " | " + Date() +" | "+"\n" +
		 EncodeColor(colorYellow) + "Today's Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
		 EncodeColor(colorYellow) + "Today's Hi = " + EncodeColor(colorYellow) + Hiday + "\n" +
		 EncodeColor(colorYellow) + "Today's Lo = " + EncodeColor(colorYellow) + Loday + "\n" +
		 EncodeColor(colorYellow) + "Yesterday's Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DRE, 1.2)) + "\n" +
		 EncodeColor(colorYellow) + "5 Day MA of Daily Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DR5E,1.2)) + "\n" +
		 EncodeColor(colorYellow) + "20 Day MA of Daily Range = " + EncodeColor(colorYellow) + StrToNum(NumToStr(DR20E,1.2)) ;

_SECTION_END();
Disclaimer: my first post in this forum - finally. :D
Good work!
If you cannot read text, change color to something darker such as red or black
 

Nehal_s143

Well-Known Member
_SECTION_BEGIN("Price");
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("Price 131");
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0 ,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0 ,L,-20);

Title =
EncodeColor(colorBlack)+ "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorBlack)+ Interval(2)
+ EncodeColor(colorBlack) + " | " + Date() +" | "
+"\n"+EncodeColor(1) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + " | Volume : "+ WriteVal(V,1.0)+
"\n"+ EncodeColor(colorBlack)+"\n"+
EncodeColor(colorBlack) + "Day's Range = " + EncodeColor(colorBlack) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
EncodeColor(colorBlack) + "Day's Hi = " + EncodeColor(colorBlack) + Hiday + "\n" +
EncodeColor(colorBlack) + "Day's Lo= " + EncodeColor(colorBlack) + Loday ;

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;

YHL = 1;
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorBlack);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorBlack);
}
_SECTION_END();

_SECTION_BEGIN("Price 131");
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
PlotShapes(shapeSmallCircle*(H==HiDay),colorDarkRed,0 ,H,20);
PlotShapes(shapeSmallCircle*(L==Loday),colorDarkGreen,0 ,L,-20);

Title =
EncodeColor(colorBlack)+ "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorBlack)+ Interval(2)
+ EncodeColor(colorBlack) + " | " + Date() +" | "
+"\n"+EncodeColor(1) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + " | Volume : "+ WriteVal(V,1.0)+
"\n"+ EncodeColor(colorBlack)+"\n"+
EncodeColor(colorBlack) + "Day's Range = " + EncodeColor(colorBlack) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
EncodeColor(colorBlack) + "Day's Hi = " + EncodeColor(colorBlack) + Hiday + "\n" +
EncodeColor(colorBlack) + "Day's Lo= " + EncodeColor(colorBlack) + Loday ;

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;

YHL = 1;
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleNoLine|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorBlack);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorBlack);
}
_SECTION_END();






This AFL is showing just today range, i am in need of afl which shows yesterday range & average of last 5 trading session & average of last 20 trading session on screen.

so i can compare how much movement more left in script.

for example if daily range of silver is 800 point & if i can see today it moved just 400 point till eve, i will buy it above high or sell below low for 400 pt tgt.

but current afl showing just today range, can u help pls.

THKS
I dont think your way of seeing todays range and 400 pts in silver is correct, as todays range is noting but high - low, which will keep changing as new day high or new day low is made, if you want to relate the range then do it with last 5 days or 20 days, just a suggestion. :)
 

Nehal_s143

Well-Known Member
And what is the problem...? This code seems to be simple straight forward "finite state machine" progression and a great thing to do would be draw the FSM of it first.
Sir, if we use on eod data indicator is getting plotted, if used on intraday chart indicator is not getting plotted properly, even after changing the code for intraday
 

Similar threads