Syntax for filtering Stocks based on things happened in particular time period

Mine is a simple program, which does check the direction of movement of an indicator.
The program does filter the stocks based on certain conditions.

I am trying add one more condition, " check if the direction change happened in the morning before 10:30 am today".
I will analyze and act only o those filtered stocks in the remaining time of the day available for trading.

I am looking for SYNTAX of using time in building a filter condition. Here is the code"

_SECTION_BEGIN("SatSTOM11");

LookBack = Param("Lookback", 31, 2, 100 );
Smooth1 = Param("Smooth 1", 25, 1, 100 );
Smooth2 = Param("Smooth 2", 2, 1, 100 );

HH = HHV( H, LookBack );
LL = LLV( L, LookBack );

StoMom = 100 * EMA( EMA( C - 0.5 * ( HH + LL ), Smooth1 ), Smooth2 ) / 
( 0.5 * EMA( EMA( HH - LL, Smooth1 ), Smooth2 ) );

Plot(StoMom, _DEFAULT_NAME(), colorwhite);
PlotGrid(0, colorwhite,8, 1, False );
PlotGrid(30, colorRed,10, 1, False );
PlotGrid(-30, colorBlue,10, 1, False );


Buy=(StoMom>Ref(StoMom,-1) AND Ref(StoMom,-1)<Ref(StoMom,-2));// AND time was <=today 10:30 am;


Filter = Buy ;
sig=IIf(Buy==True,1,2);

AddColumn(sig, "Signal"); 
SetSortColumns(-2);
_SECTION_END();

@snbarma take a look at the TimeNum() function documentation.

One basic example how to use it is in this thread. Searching the forum you'll find other code samples to study.

1 Like

I found the solution in the internet.

hour()==9 AND Minute()<46;

Thank you Beppe.
I was searching the net for the syntax.

@snbarma it is always a good idea to begin your searches from the source:

2 Likes