Simple Coding Help - No Promise.

pratapvb

Well-Known Member
generally took 20D ema and plotted 2 SD bands with it....
used formula = StDev(C,20);
found out that it behaved same way as the Vwap would
wanted to have vwap like something in daily or other TF charts

Then u already have it. What more u are looking for
 

Gandhar.

Well-Known Member

poortrader

Well-Known Member
I have this simple afl for plotting Previous day High/Low and Close. But after sometime the chart becomes compressed. Need help in keeping the scale of the chart same

=================
xx = DateNum() !=Ref(DateNum(),-1);
bt=LastValue(BarsSince(xx))+1;

Hcolor=ParamColor("High Color",colorPink);
Lcolor=ParamColor("Low Color",colorSeaGreen);
Ccolor=ParamColor("Close Color",colorBlue);

mh=TimeFrameGetPrice( "H", inDaily, -1 );
ml=TimeFrameGetPrice( "L", inDaily, -1 );
mc=TimeFrameGetPrice( "C", inDaily, -1 );

//Plot(mh,"",colorPink,styleDashed|styleNoLabel);
//Plot(ml,"",colorSeaGreen,styleDashed|styleNoLabel);
//Plot(mc,"",colorLightBlue,styleDashed|styleNoLabel);

Plot(LineArray( BarCount-bt, LastValue(mh,1), BarCount-1, LastValue(mh,1), 0 ),"", Hcolor,styleDashed);
Plot(LineArray( BarCount-bt, LastValue(ml,1), BarCount-1, LastValue(ml,1), 0 ),"", Lcolor,styleDashed);
Plot(LineArray( BarCount-bt, LastValue(mc,1), BarCount-1, LastValue(mc,1), 0 ),"", Ccolor,styleDashed);
==================
 
I have this simple afl for plotting Previous day High/Low and Close. But after sometime the chart becomes compressed. Need help in keeping the scale of the chart same

=================
xx = DateNum() !=Ref(DateNum(),-1);
bt=LastValue(BarsSince(xx))+1;

Hcolor=ParamColor("High Color",colorPink);
Lcolor=ParamColor("Low Color",colorSeaGreen);
Ccolor=ParamColor("Close Color",colorBlue);

mh=TimeFrameGetPrice( "H", inDaily, -1 );
ml=TimeFrameGetPrice( "L", inDaily, -1 );
mc=TimeFrameGetPrice( "C", inDaily, -1 );

//Plot(mh,"",colorPink,styleDashed|styleNoLabel);
//Plot(ml,"",colorSeaGreen,styleDashed|styleNoLabel);
//Plot(mc,"",colorLightBlue,styleDashed|styleNoLabel);

Plot(LineArray( BarCount-bt, LastValue(mh,1), BarCount-1, LastValue(mh,1), 0 ),"", Hcolor,styleDashed);
Plot(LineArray( BarCount-bt, LastValue(ml,1), BarCount-1, LastValue(ml,1), 0 ),"", Lcolor,styleDashed);
Plot(LineArray( BarCount-bt, LastValue(mc,1), BarCount-1, LastValue(mc,1), 0 ),"", Ccolor,styleDashed);
==================
Add styleNoRescale like styleDashed | styleNoRescale
 

amitrandive

Well-Known Member
_SECTION_BEGIN("RGST-VJAY-Lines");
// RGST-VJAY-Lines AFL
/* afl that can plot lines for:
Monthly HL,
Weekly HL,
Yesterdays HLC,
Today's Open, HOD, LOD.
can turn these lines on/off from parameters
can change colour of these lines from parameters

Using parameters can plot HL lines for current month/week or last month/week.
Default is current month/week.
To plot lines for last month/week change the parameter "MonthSelected"/"WeekSelected" to -1.
*/
ShowTodaysOHL= ParamToggle("ShowTodaysOHL", "No|Yes", 1);
ShowYesterdaysHLC= ParamToggle("ShowYesterdaysHLC", "No|Yes", 1);
ShowWeeklyHL= ParamToggle("ShowWeeklyHL", "No|Yes", 1);
ShowMonthlyHL= ParamToggle("ShowMonthlyHL", "No|Yes", 1);
WeekSelected= Param("WeekSelected", 0, minimum=-156, maximum=0, step=1); // second parameter is -1 for last week. 0 for current week.
MonthSelected= Param("MonthSelected", 0, minimum=-36, maximum=0, step=1); // second parameter is -1 for last month. 0 for current month.
FilterDayCh= ParamToggle("Filter Day Change Connections", "No|Yes", 1) ;

dt= DateTime() ;
dtnum= DateTimeConvert(0, dt) ;
isNewDt= dtnum != Ref(dtnum, -1) ;
isLastbar= H-H ;
if(FilterDayCh)
isLastbar= dtnum != Ref(dtnum, 1) ;
_SECTION_END();

_SECTION_BEGIN("ShowTodaysOHL");
TodaysOColor= ParamColor("TodaysOColor", colorSkyblue);
TodaysHColor= ParamColor("TodaysHColor", colorSkyblue);
TodaysLColor= ParamColor("TodaysLColor", colorSkyblue);
TodaysOStyle= ParamStyle("TodaysOStyle", styleDashed|styleNoLabel|styleNoRescale);
TodaysHStyle= ParamStyle("TodaysHStyle", styleDashed|styleNoLabel|styleNoRescale);
TodaysLStyle= ParamStyle("TodaysLStyle", styleDashed|styleNoLabel|styleNoRescale);
DayOpen= TimeFrameGetPrice("O", inDaily, 0);
DH= TimeFrameGetPrice("H", inDaily, 0);
DL= TimeFrameGetPrice("L", inDaily, 0);

if(ShowTodaysOHL)
{
Plot(IIf(isLastbar,Null,DayOpen),"Today's Open", TodaysOColor, TodaysOStyle);
Plot(IIf(isLastbar,Null,DH), "Today's High", TodaysHColor, TodaysHStyle);
Plot(IIf(isLastbar,Null,DL), "Today's Low", TodaysLColor, TodaysLStyle);
}
_SECTION_END();

_SECTION_BEGIN("Yesterdays HLC");
D1HColor= ParamColor("YHColor", colorRed);
D1HStyle= ParamStyle("YHStyle", styleLine|styleDashed|styleNoLabel|styleNoRescale);
//D2HColor= ParamColor("D2HColor", colorCustom12);
//D2HStyle= ParamStyle("D2HStyle", styleDashed|styleNoLabel|styleNoRescale);
//D3HColor= ParamColor("D3HColor", colorCustom12);
//D3HStyle= ParamStyle("D3HStyle", styleDashed|styleNoLabel|styleNoRescale);

D1LColor= ParamColor("YLColor", colorLime);
D1LStyle= ParamStyle("YLStyle", styleLine|styleDashed|styleNoLabel|styleNoRescale);
//D2LColor= ParamColor("D2LColor", colorLime);
//D2LStyle= ParamStyle("D2LStyle", styleDashed|styleNoLabel|styleNoRescale);
//D3LColor= ParamColor("D3LColor", colorLime);
//D3LStyle= ParamStyle("D3LStyle", styleDashed|styleNoLabel|styleNoRescale);

D1CColor= ParamColor("YCColor", colorGreen);
D1CStyle= ParamStyle("YCStyle", styleDashed|styleNoLabel|styleNoRescale);

if(ShowYesterdaysHLC)
{
D1H= TimeFrameGetPrice("H", inDaily, -1);
D1L= TimeFrameGetPrice("L", inDaily, -1);
D1C= TimeFrameGetPrice("C", inDaily, -1);
Plot(IIf(isLastbar,Null,D1H), "YH", D1HColor, D1HStyle);
Plot(IIf(isLastbar,Null,D1L), "YL", D1LColor, D1LStyle);
Plot(IIf(isLastbar,Null,D1C), "YC", D1CColor, D1CStyle);

//D2H= TimeFrameGetPrice("H", inDaily, -2);
//D2L= TimeFrameGetPrice("L", inDaily, -2);
//Plot(IIf(isLastbar,Null,D2H), "D2H", D2HColor, D2HStyle);
//Plot(IIf(isLastbar,Null,D2L), "D2L", D2LColor, D2LStyle);

//D3H= TimeFrameGetPrice("H", inDaily, -3);
//D3L= TimeFrameGetPrice("L", inDaily, -3);
//Plot(IIf(isLastbar,Null,D3H), "D3H", D3HColor, D3HStyle);
//Plot(IIf(isLastbar,Null,D3L), "D3L", D3LColor, D3LStyle);
}
_SECTION_END();

_SECTION_BEGIN("Weekly HL");
//W1OColor= ParamColor("W1OColor", colorLightBlue);
W1HColor= ParamColor("W1HColor", colorBlue);
W1LColor= ParamColor("W1LColor", colorBlue);
//W1CColor= ParamColor("W1CColor", colorLightBlue);

//W1OStyle= ParamStyle("W1OStyle", styleDots|styleNoLabel|styleNoRescale);
W1HStyle= ParamStyle("W1HStyle", styleDots|styleNoLabel|styleNoRescale);
W1LStyle= ParamStyle("W1LStyle", styleDots|styleNoLabel|styleNoRescale);
//W1CStyle= ParamStyle("W1CStyle", styleDots|styleNoLabel|styleNoRescale);

if(ShowWeeklyHL)
{
//WO= TimeFrameGetPrice("O", inWeekly, WeekSelected);
WH= TimeFrameGetPrice("H", inWeekly, WeekSelected);
WL= TimeFrameGetPrice("L", inWeekly, WeekSelected);
//WC= TimeFrameGetPrice("C", inWeekly, WeekSelected);

//Plot(IIf(isLastbar,Null,WO), "WO", W1OColor, W1OStyle);
Plot(IIf(isLastbar,Null,WH), "WH", W1HColor, W1HStyle);
Plot(IIf(isLastbar,Null,WL), "WL", W1LColor, W1LStyle);
//Plot(IIf(isLastbar,Null,WC), "WC", W1CColor, W1CStyle);
}
_SECTION_END();

_SECTION_BEGIN("Monthly HL");
//M1OColor= ParamColor("M1OColor", colorLightYellow);
M1HColor= ParamColor("M1HColor", colorYellow);
M1LColor= ParamColor("M1LColor", colorYellow);
//M1CColor= ParamColor("M1CColor", colorLightYellow);

//M1OStyle= ParamStyle("M1OStyle", styleDots|styleNoLabel|styleNoRescale);
M1HStyle= ParamStyle("M1HStyle", styleDashed|styleNoLabel|styleNoRescale);
M1LStyle= ParamStyle("M1LStyle", styleDashed|styleNoLabel|styleNoRescale);
//M1CStyle= ParamStyle("M1CStyle", styleDots|styleNoLabel|styleNoRescale);

if(ShowMonthlyHL)
{
//MO= TimeFrameGetPrice("O", inMonthly, MonthSelected);
MH= TimeFrameGetPrice("H", inMonthly, MonthSelected);
ML= TimeFrameGetPrice("L", inMonthly, MonthSelected);
//MC= TimeFrameGetPrice("C", inMonthly, MonthSelected);

//Plot(IIf(isLastbar,Null,MO), "MO", M1OColor, M1OStyle);
Plot(IIf(isLastbar,Null,MH), "MH", M1HColor, M1HStyle);
Plot(IIf(isLastbar,Null,ML), "ML", M1LColor, M1LStyle);
//Plot(IIf(isLastbar,Null,MC), "MC", M1CColor, M1CStyle);
}
_SECTION_END();

_SECTION_BEGIN("Price1");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();


The chart is too much compressed nothing visible ,please help .
 

Giraffe

Well-Known Member
How can we access Time and Sales data in Amibroker's AFL to plot indicators.

Found the GetRTData following command in Amibroker.
"Bid = "+GetRTData("Bid");
"Ask = "+GetRTData("Ask");
"Last = "+GetRTData("Last");
"Vol = "+GetRTData("TradeVolume")

But how to use it to plot indicator in realtime so that it picks every trade (as in time and sales window) and plots Ask-Bid volume in realtime.

Amibrokers Time and Sales windows shows this Ask-Bid volume in the bottom statistics. Is there any way to plot it as an indicator (preferably in candlestick form so the its shows open, high, low and close values of Ask-Bid volume).

 

whisky

Well-Known Member
Giraffe Bro kaha the itne din, missed you.
 

Similar threads