I am using below afl to show results from data updated during market hours, but the afl is showing data from previous day. How can i get this to show data of today only?
// Define the breakout line
BreakoutLine = Study("BO", 1427);
// Calculate PDiff, setting it to Null if BreakoutLine is Null or Close is 0
PDiff = IIf(Close == 0, Null, (Close - BreakoutLine) / Close * 100);
// Calculate percentage difference, handling Null values or zero Close
//PDiff = IIf( IsNull( BreakoutLine ) OR Close == 0, 0, ( Close - BreakoutLine ) / Close * 100 );
// Define colors based on PDiff, with colorDefault for Null values
ColorDiff = IIf(IsNull(PDiff), colorDefault,
IIf(PDiff > 2, colorRed, // Red: PDiff > 2%
IIf(PDiff >= -5 AND PDiff <= 2, colorGreen, // Green: -5% <= PDiff <= 2%
IIf(PDiff > -10 AND PDiff < -5, colorOrange, // Orange: -10% < PDiff < -5%
colorGrey40)))); // Grey: PDiff <= -10% or other cases
// Volume multiplier calculation
VolPeriod = 30;
VolMul = Volume / ( MA( Volume, VolPeriod ) + 1e-9 ); // Add small constant to avoid division by zero
ColorVol = IIf( VolMul > 2, colorGreen, IIf( VolMul > 1, colorOrange, colorGrey40 ) );
// Rate of Change (ROC) coloring
RocCol = IIf( ROC( Close, 1 ) > 0, colorGreen, IIf( ROC( Close, 1 ) < -2, colorRed, colorOrange ) );
// Function to retrieve RS ranking (from IBD_RS_Ranking.afl)
function GetRS( Symbol )
{
return StaticVarGet( "RS1_" + Symbol );
}
// Check if stock is in specific watchlists
READY_TO_BUY = IIf( InWatchListName( "READY_TO_BUY" ), True, False );
RECENT_IPOS = IIf( InWatchListName( "RECENT_IPOS" ), True, False );
STAGE_1 = IIf( InWatchListName( "STAGE_1" ), True, False );
// Create a string to display watchlist names
Watchlist = WriteIf( READY_TO_BUY, "READY_TO_BUY",
WriteIf( RECENT_IPOS, "RECENT_IPOS",
WriteIf( STAGE_1, "STAGE_1",
" " ) ) );
// Check if the stock is in "PullBackTradingSystem" or "RECENT_IPOS" watchlist
InPullBack = InWatchListName( "PullBackTradingSystem" ) OR InWatchListName( "RECENT_IPOS" );
// Identify the last bar
LastBar = BarIndex() == BarCount - 1;
// Set Exploration filter: only last bar for stocks in watchlist with specific conditions
//Filter = InPullBack AND LastBar AND ROC( Close, 1 ) > 1.8 AND VolMul >= 0.25;
Filter = InPullBack AND LastBar;
// Add columns to Exploration window
AddColumn( Close, "Close", 1.2 );
AddColumn( ROC( Close, 1 ), "ROC Yest", 1.2, colorWhite, RocCol );
AddColumn( VolMul, "Vol Mul", 1.3, colorWhite, ColorVol );
AddColumn( GetRS( Name() ), "RS", 1 ); // RS ranking column
AddTextColumn( Watchlist, "Watchlist" );
AddColumn( PDiff, "DisttoBreakout", 1.2, colorWhite, ColorDiff ); // Add percentage difference column
AddColumn( BreakoutLine, "Breakout Line", 1.2 ); // Display raw BreakoutLine values for debugging
AddTextColumn( IndustryID( 1 ), "Industry name" );
AddTextColumn( SectorID( 1 ), "Sector name" );
// Sort by RS column (descending)
SetSortColumns( -4 );