Code

pkgmtnl

Well-Known Member
#21
Thnx sir,
If i make charting time frame to "Day" then value of 10days average volume changes (become correct) and Value of todays Volume remain correct,

but if I change the time frame to 5min, the value of 10days average volume changes (becomes 10000000000) and Value of todays Volume remain correct,


But it showing correct in ur images? how come?
and sir
If i want to change instead of 10days to 30days wat needs to be changed in syntax?

Can the ratio of Today's Volume/ Last 10days Avg Volume can also be added?

thanx
 
Last edited:

asnavale

Well-Known Member
#22
Thnx sir,
If i make charting time frame to "Day" then value of 10days average volume changes (become correct) and Value of todays Volume remain correct,

but if I change the time frame to 5min, the value of 10days average volume changes (becomes 10000000000) and Value of todays Volume remain correct,

But it showing correct in ur images? how come?
The value becomes -10000000000. This means the calclated value is empty. In other words, there is no sufficient data to calculate the values. If you have data for lesser number of days than averaging period, this error appears. If you are getting correct values in daily timeframe and not in smaller time frames that may be due to some error in the RT data.

and sir
If i want to change instead of 10days to 30days wat needs to be changed in syntax?
yes you can change the averaging period. Change the following line:

DV30 = MA(V, 30);

replace 30 inside the bracket to whatever value you want.

Can the ratio of Today's Volume/ Last 10days Avg Volume can also be added?

thanx
Yes it can be displayed. Write the required value in the _N(Title = ....) line.

-Anant
 

pkgmtnl

Well-Known Member
#23
Anant ji
On my request U gave me a syntax for angle, which i incorporated in an Exp AFL

As

V1= MACD(r1, r2);
V2 = Ref(MACD(r1, r2), -1);
PI = 22/7;

BUY
Cond13 = atan(V1-V2) > PI/6;

SELL
Cond14 = atan(V2 -V1) > PI/6;

But, I have observed that Its not giving Correct signal on SELL side?
My purpose was to screen out the scripts giving steep up or downslope on MACD.
can u further guide on this issue?
 

asnavale

Well-Known Member
#24
Anant ji
On my request U gave me a syntax for angle, which i incorporated in an Exp AFL

As

V1= MACD(r1, r2);
V2 = Ref(MACD(r1, r2), -1);
PI = 22/7;

BUY
Cond13 = atan(V1-V2) > PI/6;

SELL
Cond14 = atan(V2 -V1) > PI/6;

But, I have observed that Its not giving Correct signal on SELL side?
My purpose was to screen out the scripts giving steep up or downslope on MACD.
can u further guide on this issue?
Hi pkg,

The code looks for angle with only two points, that is today's MACD and yesterday's MACD. This can not gove accurate results because with two points you can always draw a straight line and the angle of this line need not continue to be same in future. To get a better estimate of the angle we need more points, at least four or five. But by that time it may be too late. Therefore the method can not give accurate results. In general, any strategy which changes today's calculated value depending on tomorrow's price can not be relied upon. It works excellently in back testing because the future values are already available. Similar problems are encountered when you use linear regression or Zig-Zag indicator. Therefore, it is better to stick to those methoids which rely only on calculations up to today and todays calculation does not change due to tomorrow's value.

-Anant
 

pkgmtnl

Well-Known Member
#25
Anant Ji,
I am facing a problem that When I put these two together, the two AFL does not work together.

Part 1 can work independently untill Part 2 is not imposed.
Once Part2 is imposed along Part1, then only Part2 displays and part1 does not displays

// Say Part 1
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

if ( NewPeriod )
{
Say( "New period" );
Plot( 1, "", colorYellow, styleArea | styleOwnScale, 0, 1 );
}

Title = "\n" +

" Current Time: " + Now( 2 ) + "\n" +
"Chart Interval: " + NumToStr( TimeFrame, 1.0 ) + " Seconds\n" +
" Second Number: " + NumToStr( SecNumber, 1.0, False ) + "\n" +
" Seconds Left: " + NumToStr( SecsLeft, 1.0, False ) + "\n" +
" Seconds To Go: " + NumToStr( SecsToGo, 1.0, False );

// When I paste the below syntax the Above of Part 1 information goes from screen;
// Say Part 2

SetChartBkColor(ParamColor("Panel color ",colorPaleBlue));
SetChartOptions(0, chartShowDates | chartWrapTitle);

Dt = DateNum();
DV = 0;

for (i = BarCount -1; i > 0; i--)
{

if(Dt < Now(3)) break;
DV = DV + V;
}

TimeFrameSet(inDaily);
DV30 = MA(V, 30);


_N(Title = StrFormat("{{NAME}}, {{DATE}} - {{INTERVAL}}: {{OHLCX}}\n Last 30 Day Avg Vol = %1.0f, Today's Vol = %1.0f", DV30, DV));

TimeFrameRestore();
 
Last edited:

Similar threads