Greetings,
I am attempting to find a more efficient way to sum the up ticks every 30 minutes using tick base interval, assign the value to a static variable, then call and plot this static variable in a 30 minute interval chart. I got this to work with an IIF statement but would like to use the timeframe funcitons to increase efficiency.
UP_TICK = IIf( C > Ref( C , -1 ) , v , 0 ) ;
TPO_UP_TICK_SUM_30_MIN_COMPRESS = TimeFrameCompress( UP_TICK , 2 * in15Minute , compressVolume ) ;
TPO_START = IIf( ( Minute() == 00 AND Ref( Minute() , -1 ) > 00 ) OR( Minute() == 30 AND Ref( Minute() , -1 ) < 30 ) , 1 , 0 ) ;
TPO_UP_TICK_SUM = IIf( TPO_START != 1 , Sum( UP_TICK , BarsSince( TPO_START == 1 ) + 1 ) , Sum( UP_TICK , 1 ) ) ;
x = TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expanDPOINT ) ;
STaticVarSet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" , x ) ;
Filter = DateNum() == 1190111 AND Ref( TPO_START , 1 ) == 1 ;
AddColumn( StaticVarGet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" ) , "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" , 1.2 , colorDefault ,
IIf( StaticVarGet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" ) != TPO_UP_TICK_SUM , colorRed , colorGreen ) ) ;
AddColumn( TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expandPOINT ) , "TPO_UP_TICK_SUM_COMPRESS" , 1.2 , colorDefault ,
IIf( TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expandPOINT ) != TPO_UP_TICK_SUM , colorRed , colorGreen ) ) ;
ADDCOLUMN( TPO_UP_TICK_SUM , "TPO_UP_TICK_SUM" , 1.2 ) ;
This is the analysis output
My question is why are some to the timeframecompress values equivalent to the iif statement values and others are not?
When I switch to expandfirst I get the following analysis output.
UP_TICK = IIf( C > Ref( C , -1 ) , v , 0 ) ;
TPO_UP_TICK_SUM_30_MIN_COMPRESS = TimeFrameCompress( UP_TICK , 2 * in15Minute , compressVolume ) ;
TPO_START = IIf( ( Minute() == 00 AND Ref( Minute() , -1 ) > 00 ) OR( Minute() == 30 AND Ref( Minute() , -1 ) < 30 ) , 1 , 0 ) ;
TPO_UP_TICK_SUM = IIf( TPO_START != 1 , Sum( UP_TICK , BarsSince( TPO_START == 1 ) + 1 ) , Sum( UP_TICK , 1 ) ) ;
x = TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expanDFIRST ) ;
STaticVarSet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" , x ) ;
Filter = DateNum() == 1190111 AND Ref( TPO_START , 1 ) == 1 ;
AddColumn ( UP_TICK , "UP_TICK" , 1.0 ) ;
AddColumn( StaticVarGet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" ) , "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" , 1.2 , colorDefault ,
IIf( StaticVarGet( "TPO_UP_TICK_SUM_30_MIN_COMPRESS_STATIC" ) != TPO_UP_TICK_SUM , colorRed , colorGreen ) ) ;
AddColumn( TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expandFIRST ) , "TPO_UP_TICK_SUM_COMPRESS" , 1.2 , colorDefault ,
IIf( TimeFrameExpand( TPO_UP_TICK_SUM_30_MIN_COMPRESS , 2 * in15Minute , expandFIRST ) != TPO_UP_TICK_SUM , colorRed , colorGreen ) ) ;
ADDCOLUMN( TPO_UP_TICK_SUM , "TPO_UP_TICK_SUM" , 1.2 ) ;
It seems like some of the timeframecompress values are jumping ahead an interval?
I feel like this issue is similar to the one in this post.
But I have not been able to figure out what I'm missing.
Thanks,
Mark