VWAP/ATP Values for creating Price Charts..

#11
The Correct possible way with the constraints u have mentioned is the following way.

Code:
function ATP(a)
{
nd=Day() != Ref(Day(), -1);

Bars = 1 + BarsSince( nd );
TodayVolume = Sum(V,Bars);
StartBar = ValueWhen(TimeNum() == 091500, BarIndex());

at=IIf (BarIndex() >= StartBar,(Sum (a * V, Bars ) /TodayVolume),0);
return at;
}
ATPo = ATP(o);
ATPh = ATP(h);
ATPl = ATP(l);
ATPc = ATP(c);
col = IIf(ATPo<ATPc,colorDarkGreen,colorTan);

PlotOHLC(ATPo,ATPh,ATPl,ATPc,"ATP candles",col,styleCandle);
I hope this will serve your purpose.
Hello Extremist,

I plugged the code and i can see the charts...:thumb::thumb::thumb:

I would be really grateful if could look into the following:

1. The above code seems to be restricted to only intra-day, when using higher time frames like daily, weekly or monthly it is just displaying just one candle..


2. For research purposes, i am looking to feed values other than price like atp, volume, Open interest into oscillators and see the behavior.

I would like to feed the ATP into this oscillator, (I think from John Ehlers), the code of which is attached:

HTML:
_SECTION_BEGIN("CYBER STOCH");
//==================================
//==================================
// 	From John Ehler's book     ===
// 	Rocket Science for Traders ===
//                     	     		===
// 	AFL By Robert Dunbar  	   ===
//==================================
//==================================

Arrows = ParamToggle( "Buy/Sell Arrows", "No|Yes", 1 );
alpha = Param( "Alpha", 0.07, 0.01, 0.4, 0.01, 0.01 );
Len = Param( "Length", 8, 1, 25, 1, 1 );
BullSig = BearSig = Trigger = Cycle = MaxCycle = MinCycle = Value1 = Value2 =
0;
PriceIn = ( ( H + L ) / 2 );

SmoothX = ( PriceIn + 2 * Ref( PriceIn, -1 ) + 2 * Ref( PriceIn, -2 ) + Ref(
PriceIn, -3 ) ) / 6;


for ( i = 6; i < BarCount; i++ )
{
    Cycle[i] = ( ( 1 - 0.5 * alpha ) ^ 2 ) * ( SmoothX[ i ] - 2 * SmoothX[ i - 1
] + SmoothX[ i - 2] ) + 2 * ( 1 - alpha ) * Cycle[ i - 1 ] - ( ( 1 - alpha ) ^ 2
) * Cycle[ i - 2 ];

    if ( i < 7 )
        Cycle[i] = ( PriceIn[i] - 2 * PriceIn[i-1] + PriceIn[i-2] ) / 4;
}

MaxCycle = HHV( Cycle, Len );

MinCycle = LLV( Cycle, Len );

Value1 = IIf( MaxCycle != MinCycle, ( Cycle - MinCycle ) / ( MaxCycle - MinCycle
), Value1 );

Value2 = ( 4 * Value1 + 3 * Ref( Value1, -1 ) + 2 * Ref( Value1, -2 ) + Ref(
Value1, -3 ) ) / 10;

Value2 = 2 * ( Value2 - 0.5 );

Trigger = ( 0.96 * ( Ref( Value2, -1 ) + 0.02 ) );

BullSig = IIf( Cross( Value2, Trigger ), True, False );
BearSig = IIf( Cross( Trigger, Value2 ), True, False );


Plot( Value2, "CyberCycle", colorLightBlue );
Plot( Trigger , "Trigger", colorRed );
Plot( 0 , "", colorWhite, styleDashed );

if ( Arrows )
{
    PlotShapes( shapeUpArrow*BullSig, colorBrightGreen );
    PlotShapes( shapeDownArrow*BearSig, colorRed );
}
_SECTION_END();
I tried incorporating your code into the AFL and putting your code outiside the brackets of the stocahstic code and replaced "pricein" with ATPh, AtPl, , but wasn't working. Similarly tried putting your code within the code of the AFL with the same results of not working.

Really appreciate your help, if you could look into this when you get time.

Thanks a lot man
 
#14
Hello Extremist,

I plugged the code and i can see the charts...:thumb::thumb::thumb:

I would be really grateful if could look into the following:

1. The above code seems to be restricted to only intra-day, when using higher time frames like daily, weekly or monthly it is just displaying just one candle..


2. For research purposes, i am looking to feed values other than price like atp, volume, Open interest into oscillators and see the behavior.

I would like to feed the ATP into this oscillator, (I think from John Ehlers), the code of which is attached:

HTML:
_SECTION_BEGIN("CYBER STOCH");
//==================================
//==================================
// 	From John Ehler's book     ===
// 	Rocket Science for Traders ===
//                     	     		===
// 	AFL By Robert Dunbar  	   ===
//==================================
//==================================

Arrows = ParamToggle( "Buy/Sell Arrows", "No|Yes", 1 );
alpha = Param( "Alpha", 0.07, 0.01, 0.4, 0.01, 0.01 );
Len = Param( "Length", 8, 1, 25, 1, 1 );
BullSig = BearSig = Trigger = Cycle = MaxCycle = MinCycle = Value1 = Value2 =
0;
PriceIn = ( ( H + L ) / 2 );

SmoothX = ( PriceIn + 2 * Ref( PriceIn, -1 ) + 2 * Ref( PriceIn, -2 ) + Ref(
PriceIn, -3 ) ) / 6;


for ( i = 6; i < BarCount; i++ )
{
    Cycle[i] = ( ( 1 - 0.5 * alpha ) ^ 2 ) * ( SmoothX[ i ] - 2 * SmoothX[ i - 1
] + SmoothX[ i - 2] ) + 2 * ( 1 - alpha ) * Cycle[ i - 1 ] - ( ( 1 - alpha ) ^ 2
) * Cycle[ i - 2 ];

    if ( i < 7 )
        Cycle[i] = ( PriceIn[i] - 2 * PriceIn[i-1] + PriceIn[i-2] ) / 4;
}

MaxCycle = HHV( Cycle, Len );

MinCycle = LLV( Cycle, Len );

Value1 = IIf( MaxCycle != MinCycle, ( Cycle - MinCycle ) / ( MaxCycle - MinCycle
), Value1 );

Value2 = ( 4 * Value1 + 3 * Ref( Value1, -1 ) + 2 * Ref( Value1, -2 ) + Ref(
Value1, -3 ) ) / 10;

Value2 = 2 * ( Value2 - 0.5 );

Trigger = ( 0.96 * ( Ref( Value2, -1 ) + 0.02 ) );

BullSig = IIf( Cross( Value2, Trigger ), True, False );
BearSig = IIf( Cross( Trigger, Value2 ), True, False );


Plot( Value2, "CyberCycle", colorLightBlue );
Plot( Trigger , "Trigger", colorRed );
Plot( 0 , "", colorWhite, styleDashed );

if ( Arrows )
{
    PlotShapes( shapeUpArrow*BullSig, colorBrightGreen );
    PlotShapes( shapeDownArrow*BearSig, colorRed );
}
_SECTION_END();
I tried incorporating your code into the AFL and putting your code outiside the brackets of the stocahstic code and replaced "pricein" with ATPh, AtPl, , but wasn't working. Similarly tried putting your code within the code of the AFL with the same results of not working.

Really appreciate your help, if you could look into this when you get time.

Thanks a lot man

Guys, Can anyone please look into this. Will be much obliged.
 
#15
................

function ATP(a)
{
nd=Day() != Ref(Day(), -1);

Bars = 1 + BarsSince( nd );
TodayVolume = Sum(V,Bars);
StartBar = ValueWhen(TimeNum() == 000000, BarIndex());

at=IIf (BarIndex() >= StartBar,(Sum (a * V, Bars ) /TodayVolume),0);
return at;
}
ATPo = ATP(O);
ATPh = ATP(H);
ATPl = ATP(L);
ATPc = ATP(C);
col = IIf(ATPo<ATPc,colorDarkGreen,colorTan);

PlotOHLC(ATPo,ATPh,ATPl,ATPc,"ATP candles",col,styleCandle);
 
Last edited:

Similar threads