Jump to content
Medved Trader Forums

Is it possible to create this scan? $ Change% from 7:00 AM (or any timestamp)


Roger

Recommended Posts

Mr. Medved, I am trying to create this scan:  $Change% from 7:00 AM (or any other timestamp). 

Symbol.Data.Last - SymbolData.Last(7:00 AM timestamp) / SymbolData.Last(7:00 AM timestamp) * 100

And create a Column for this:  Change7

How do I get SymbolData.Last at specific time? (7:00 AM timestamp)



Thanks, Roger

 

Link to comment
Share on other sites

The scan, when it runs, does not run only on the very last candle. It runs on every candle first (then, as  the real time data comes in, it keeps running on the last and then new candles).

So something like this will work

int lastdaynum  = -1;
double CloseAt7 = 0;

public void MainCalculation()
{
    if (TradingDay.DayNumber != lastdaynum)
    {
        CloseAt7   = 0;
        lastdaynum = TradingDay.DayNumber;
    }
    if (CloseAt7 == 0 && Timestamp >= TradingDay.SessionStart.AddHours(3)) // session starts at 4am, so add 3 to get 7am
    {
        CloseAt7 = Close;
    }
    if (CloseAt7 == 0)
        SetScanResult(0);
    else
        SetScanResult(Close-CloseAt7);
}
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.

×
×
  • Create New...