Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 07:50:43 +0000



Post From: How To Tell If Data Is Delayed

[2023-04-06 03:05:45]
Tony - Posts: 460
@DTF

Here is the study that does that, please follow the instruction about how to build it:
How to Build an Advanced Custom Study from Source Code

In the evening session, you will see "Delayed" a lot, nothing wrong with your data feed, just
because the trading volume is so low. (see attached animated .gif)


#include "sierrachart.h"
SCDLLName("Stream Delayed Warning")

void AddDrawing (
  SCStudyInterfaceRef sc, int UniqueNumber, int HorizontalStart,
  int HorizontalEnd, DrawingTypeEnum DrawingType,
  float BeginValue, float EndValue, int DrawingColor, int FontSize,
  int BoldFlag_LineWidth, SCString TextContent
)
{
  s_UseTool Pencil;
  Pencil.Clear();

  Pencil.LineNumber = UniqueNumber;
  Pencil.BeginDateTime = HorizontalStart;
  Pencil.EndDateTime = HorizontalEnd;

  Pencil.FontBackColor = sc.ChartBackgroundColor;
  Pencil.DrawUnderneathMainGraph = 0;

  Pencil.DrawingType = DrawingType;
  Pencil.UseRelativeVerticalValues = 1;
  Pencil.BeginValue = BeginValue;
  Pencil.EndValue = EndValue;
  Pencil.Color = DrawingColor;
  Pencil.FontSize = FontSize;
  Pencil.FontBold = BoldFlag_LineWidth;
  Pencil.LineWidth = BoldFlag_LineWidth;
  Pencil.Text = TextContent;

  sc.UseTool(Pencil);
}





SCSFExport scsf_StreamDelayedWarning(SCStudyInterfaceRef sc)
{
  SCInputRef Horizontal {sc.Input[0]};
  SCInputRef Vertical {sc.Input[1]};
  SCInputRef TextColor {sc.Input[2]};
  SCInputRef TextSize {sc.Input[3]};

  if (sc.SetDefaults)
  {
    sc.GraphName = "Stream Delayed Warning";

    sc.AutoLoop = 1;
    sc.UpdateAlways = 1;
    sc.GraphRegion = 0;
    
    Horizontal.Name = "Horizontal Position (0-150)";
    Horizontal.SetInt(5);
    Vertical.Name = "Vertical Position (0-100)";
    Vertical.SetInt(80);
    TextColor.Name = "Text Color";
    TextColor.SetColor(0, 0, 0);
    TextSize.Name = "Text Size";
    TextSize.SetInt(12);
    
    return;
  }

  SCString DisplayText {""};

  if (sc.CurrentSystemDateTime - sc.BaseDataEndDateTime[sc.Index] > SCDateTime::SECONDS(1)) {
    DisplayText.Format("Delayed ");
    if (sc.CurrentSystemDateTime - sc.BaseDataEndDateTime[sc.Index] > SCDateTime::SECONDS(300))
      DisplayText.AppendFormat("> 5m");
    else
      DisplayText.AppendFormat(
        "%d s", (sc.CurrentSystemDateTime - sc.BaseDataEndDateTime[sc.Index]).GetTimeInSeconds()
      );
  }
  else
    DisplayText.Format("Streaming");

  AddDrawing (
    sc, 100, Horizontal.GetInt(), 0, DRAWING_TEXT, Vertical.GetInt(),
    0, TextColor.GetColor(), TextSize.GetInt(), 0, DisplayText
  );
  
}


Date Time Of Last Edit: 2023-04-06 05:15:14
imageStream.gif / V - Attached On 2023-04-06 05:10:56 UTC - Size: 1.43 MB - 73 views
Attachment Deleted.