Can Any Senior write codes for this?

pkgmtnl

Well-Known Member
#1
Sir,

I want that these things should constantly displayes on Chart irrespective of TimeInterval of charts, i choose...
a) 30 Days Average Volume =
b) 21 Days Average Volume =
c) 7 Days Average Volume =
d) Total Volume of Current day (from 9.00AM till time of last Tick) =

Can it be like this :-

V30=TimeFrameExpand( V, inDaily*30 )/30; // expand for display
V21=TimeFrameExpand( V, inDaily*21 )/21; // epand for display
V7=TimeFrameExpand( V, inWeekly )/7; // expand for display
V=TimeFrameExpand( V, ? ); // expand for display
I am not sure if above is correct way?
and How to reproduce on screen if its correct?

How to Code it?

please guide..!
 
#2
Hi pkgmtnl,

I am a Tradestation Programmer, and just learning amibroker,
It should be something like this.

Please try this code and let me know...

Code:
PlotText( "30 Days Average Volume =" + MA(Volume,30) , BarCount, H[ 1 ], colorRed, colorYellow )
This Plot the 30 bar's moving average at the lastbar above the High of the penalty bar.

Thanks,
Mani
 

pkgmtnl

Well-Known Member
#3
Hi pkgmtnl,

I am a Tradestation Programmer, and just learning amibroker,
It should be something like this.

Please try this code and let me know...

Code:
PlotText( "30 Days Average Volume =" + MA(Volume,30) , BarCount, H[ 1 ], colorRed, colorYellow )
This Plot the 30 bar's moving average at the lastbar above the High of the penalty bar.

Thanks,
Mani
Thanx Brother,

Actually I was looking for
30Days Moving Average Volume
,....
....
.
....
 

singhboy

Active Member
#4
_SECTION_BEGIN("MA");
TimeFrameSet(inDaily);
EMA_30= EMA(V,30);
TimeFrameRestore();

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot (TimeFrameExpand( EMA_30, inDaily), _DEFAULT_NAME(), ParamColor( "Color", colorBlue ), ParamStyle("Style") );

_SECTION_END();
 

asnavale

Well-Known Member
#5
Sir,

I want that these things should constantly displayes on Chart irrespective of TimeInterval of charts, i choose...
a) 30 Days Average Volume =
b) 21 Days Average Volume =
c) 7 Days Average Volume =
d) Total Volume of Current day (from 9.00AM till time of last Tick) =

Can it be like this :-

V30=TimeFrameExpand( V, inDaily*30 )/30; // expand for display
V21=TimeFrameExpand( V, inDaily*21 )/21; // epand for display
V7=TimeFrameExpand( V, inWeekly )/7; // expand for display
V=TimeFrameExpand( V, ? ); // expand for display
I am not sure if above is correct way?
and How to reproduce on screen if its correct?

How to Code it?

please guide..!
Hi pkg,

From the description you have given above it appears that you are interested in daily volumes but with current day's live data. If you are not interseted in lower timeframe bars (like 1min, 5min, 15min etc.) then the solution is simple.

1) On the intraday chart, set intraday time interval to daily. (Just press Control-D). Now all the data is displayed in daily timeframe with the last bar (today's bar) changing continuously with time as new data comes in.

2) Define the following variables:
V30 = MA(V, 30); // 30-day avg vol
V21 = MA(V, 21); // 21 day avg vol
V7 = MA(V, 7); //7-day avg vol

3) Now plot them:

Plot(V30, "30day avg", color-of-your-choice, styleLine);
Plot(V21, "21day avg", color-of-your-choive, styleLine);
Plot(V7, "7day avg", color-of-your-choice, styleLine);
Plot(V, "ToDay's vol", color-of-your-choice, styleLine);

Please note: In the above lines for plotting, 'color-of-your-choice' means wharever color you want. It is not a variable.

If you want to only display the values and not plot them, then the step 3 above will be as below:

Alternate Step 3)

To display the values on chart title the following line should be part of your afl:


_N(Title = StrFormat("V30=%1.0f, V21=%1.0f, V7=%1.0f, Todays vol=%1.0f\n",V30, V21, V7, V));

If you want to plot/display the values on a chart of any other timeframe then you have to use TimeframeSet and TimeframeExpand functions to calculate the values of V30, V21, V7 and V.

try it and if you find any difficulty, please report here in this thread.

-Anant
 

pkgmtnl

Well-Known Member
#6
Hi pkg,

From the description you have given above it appears that you are interested in daily volumes but with current day's live data. If you are not interseted in lower timeframe bars (like 1min, 5min, 15min etc.) then the solution is simple.

1) On the intraday chart, set intraday time interval to daily. (Just press Control-D). Now all the data is displayed in daily timeframe with the last bar (today's bar) changing continuously with time as new data comes in.

2) Define the following variables:
V30 = MA(V, 30); // 30-day avg vol
V21 = MA(V, 21); // 21 day avg vol
V7 = MA(V, 7); //7-day avg vol

3) Now plot them:

Plot(V30, "30day avg", color-of-your-choice, styleLine);
Plot(V21, "21day avg", color-of-your-choive, styleLine);
Plot(V7, "7day avg", color-of-your-choice, styleLine);
Plot(V, "ToDay's vol", color-of-your-choice, styleLine);

Please note: In the above lines for plotting, 'color-of-your-choice' means wharever color you want. It is not a variable.

If you want to only display the values and not plot them, then the step 3 above will be as below:

Alternate Step 3)

To display the values on chart title the following line should be part of your afl:


_N(Title = StrFormat("V30=%1.0f, V21=%1.0f, V7=%1.0f, Todays vol=%1.0f\n",V30, V21, V7, V));

If you want to plot/display the values on a chart of any other timeframe then you have to use TimeframeSet and TimeframeExpand functions to calculate the values of V30, V21, V7 and V.

try it and if you find any difficulty, please report here in this thread.

-Anant
yes anant bhai,
I knew its solution will only come from u, but u have disabled PM.
How can we write i WriteIf or Printf so that it also comes in Interpretation table.

Yes got it right, I needed Average Day volume of 30days/ 21days/ 7days and Current day Total Volume (not volume of bar).

kindly guide on this too.
thnx
 
#7
pkgmtnl

Try the following code

SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64|styleOwnScale);
TimeFrameSet(inDaily);
V30=MA(V,30);
V21=MA(V,21);
V7=MA(V,3);
TimeFrameRestore();
Barsfromtodaybegin = 1 + BarsSince( Day() != Ref(Day(), -1));
Totalvolume=Sum(V,barsfromtodaybegin);
Plot(V30,"30 day Avg Volume",colorRed,styleNoLine);
Plot(V21,"21 day Avg Volume",colorGreen,styleNoLine);
Plot(V7,"7 day Avg Volume",colorBlue,styleNoLine);
Plot(Totalvolume,"Today Tot Volume from 9.00AM",colorBrown,styleNoLine);

vidyasagar
 
Last edited:

pkgmtnl

Well-Known Member
#8
pkgmtnl

Try the following code

SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64|styleOwnScale);
TimeFrameSet(inDaily);
V30=MA(V,30);
V21=MA(V,21);
V7=MA(V,3);
TimeFrameRestore();
Barsfromtodaybegin = 1 + BarsSince( Day() != Ref(Day(), -1));
Totalvolume=Sum(V,barsfromtodaybegin);
Plot(V30,"30 day Avg Volume",colorRed,styleNoLine);
Plot(V21,"21 day Avg Volume",colorGreen,styleNoLine);
Plot(V7,"7 day Avg Volume",colorBlue,styleNoLine);
Plot(Totalvolume,"Today Tot Volume from 9.00AM",colorBrown,styleNoLine);

vidyasagar
Thanx sir,
Its working on charts,

it can now come in interpretation table:
SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64|styleOwnScale);
TimeFrameSet(inDaily);
V30=MA(V,30);
V21=MA(V,21);
V7=MA(V,7);
TimeFrameRestore();
Barsfromtodaybegin = 1 + BarsSince( Day() != Ref(Day(), -1));
Totalvolume=Sum(V,barsfromtodaybegin);
Plot(V30,"30 day Avg Volume",colorRed,styleNoLine);
Plot(V21,"21 day Avg Volume",colorGreen,styleNoLine);
Plot(V7,"7 day Avg Volume",colorBlue,styleNoLine);
Plot(Totalvolume,"Today Tot Volume from 9.00AM",colorBrown,styleNoLine);

printf("\nvolume details : ");
printf("\nv30 : "+WriteVal(V30));
printf("\nv21 : "+WriteVal(V21));
printf("\nv7 : "+WriteVal(V7));
printf("\nTotalvolume : "+WriteVal(Totalvolume));
printf("\n====================
 
Last edited:

Similar threads