Jump to content
Medved Trader Forums

Where is Prev Vol for use in a scan?


Recommended Posts

Ok, I will try to calculate Prev Vol with TimeStamp code.

Also, can you check the settings for Alert Parameter Note:  DayRange and DayRange %.

It appears to be incorrect data.

Thanks, Roger

 

 

 

Link to comment
Share on other sites

I thinks it works ok, discovered dxfeed does not provide Day Range or Range Percentage in PreMarket.

I was trying to get that in Premarket scan alerts Notes, but it was just showing Last and 0.

Also can you give me hint on coding for Previous Volume?

I am using dxfeed and it has Prev Vol available.

Having difficulty in getting any data from a specific Timestamp.

Thanks, Roger

 

Link to comment
Share on other sites

You can calculate previous day's volume as follows (in Advanced mode). In the following CurrentState.PrevDayVolume always holds the previous day's volume.

The bolded parts in the below code are the parts that are different from the standard template state code that is generated automatically in advanced mode.

 

public void MainCalculation()
{
    if ( CurrentState.DayNumber != TradingDay.DayNumber )
    {
        CurrentState.PrevDayVolume = CurrentState.TodayVolume;
        CurrentState.TodayVolume   = 0;
        CurrentState.DayNumber     = TradingDay.DayNumber;
    }
    CurrentState.TodayVolume += BarVolume;

}

/// <summary>
/// INITIALIZES paintbar. Is called at start of paintbar calculation, should be used to initialize anything needed for the paintbar
/// NOTE: do NOT initialize the CurrentState here - the PaintbarClearState will be called AFTER this call, and will wipe it out.
/// </summary>
private void PaintbarInitialize()
{

}

/// <summary>
/// Holds paintbar state - fill with variables needed to be preserved for next paintbar calc
/// </summary>
private struct PaintbarState
{
   public double PrevDayVolume;
   public double TodayVolume;
   public int DayNumber;

}

/// <summary>
/// Holds current PB state - use to calc PB, changes to it carry over to next PB calc
/// </summary>
private PaintbarState CurrentState;

/// <summary>
/// Holds saved PB state - internal
/// </summary>
private PaintbarState SavedState;

/// <summary>
/// Is called at start of paintbar calculation, should be used to clear the paintbar state
/// and initialize whatever variables you place into it. This is called AFTER PaintbarInitialize
/// </summary>
private void PaintbarClearState()
{
    CurrentState           = new PaintbarState();
    CurrentState.DayNumber = -1;
}

/// <summary>
/// Saves paintbar state (called internally).
/// </summary>
private void PaintbarSaveState()
{
    SavedState = CurrentState;
}

/// <summary>
/// Restores paintbar state (called internally).
/// </summary>
private void PaintbarRestoreState()
{
    CurrentState = SavedState;
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...