Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 12:51:05 +0000



Post From: Custom Charts Upgrade

[2024-03-07 00:11:24]
WarriorTrader - Posts: 245
Hello,

I have two custom charts that use the old school way. Is it necessary to update my code to the new objects?

Thanks,
--WT


    sc.IsCustomChart = 1; // true
    sc.GraphRegion = 0; // First region
    sc.DrawZeros = 0; // false
    sc.GraphDrawType = GDT_CANDLESTICK; //GDT_OHLCBAR;
    sc.StandardChartHeader = 1; // true


    Open.Name = "Open";
    Open.DrawStyle = DRAWSTYLE_LINE;
    Open.PrimaryColor = RGB(0, 255, 0);
    Open.DrawZeros = true;

    High.Name = "High";
    High.DrawStyle = DRAWSTYLE_LINE;
    High.PrimaryColor = RGB(0, 255, 0);
    High.DrawZeros = true;

    Low.Name = "Low";
    Low.DrawStyle = DRAWSTYLE_LINE;
    Low.PrimaryColor = RGB(255, 0, 0);
    Low.DrawZeros = true;

    Close.Name = "Last";
    Close.DrawStyle = DRAWSTYLE_LINE;
    Close.PrimaryColor = RGB(255, 0, 0);
    Close.DrawZeros = true;

    Volume.Name = "Volume";
    Volume.DrawStyle = DRAWSTYLE_IGNORE;
    Volume.PrimaryColor = RGB(255, 0, 0);
    Volume.DrawZeros = false;  

    OpenInterest.Name = "# of Trades / OI";
    OpenInterest.DrawStyle = DRAWSTYLE_IGNORE;

    OHLCAvg.Name = "OHLC Avg";
    OHLCAvg.DrawStyle = DRAWSTYLE_IGNORE;

    HLCAvg.Name = "HLC Avg";
    HLCAvg.DrawStyle = DRAWSTYLE_IGNORE;

    HLAvg.Name = "HL Avg";
    HLAvg.DrawStyle = DRAWSTYLE_IGNORE;
    

    ResizeTickHistory.Name = "Reset chart (will erase all bars)";
    ResizeTickHistory.SetYesNo(0);

    return;
  }


  const int MAX_HISTORY = 2000;

  struct s_TickHistoryType {

    int BaseIndex;
    float OpenOut;
    float HighOut;
    float LowOut;
    float CloseOut;
    float VolumeOut;

    s_TickHistoryType() : BaseIndex(0), OpenOut(0), HighOut(0), LowOut(0), CloseOut(0), VolumeOut(0) {}

  };

  struct s_CurrentBarType {

    int BaseIndex;
    float OpenOut;
    float HighOut;
    float LowOut;
    float CloseOut;
    float VolumeOut;

    s_CurrentBarType() : BaseIndex(0), OpenOut(0), HighOut(0), LowOut(0), CloseOut(0), VolumeOut(0) {}

  };

  s_TickHistoryType * TickHistory = (s_TickHistoryType *)sc.GetPersistentInt(5); //sc.PersistVars->i5;
  s_CurrentBarType * CurrentBar = (s_CurrentBarType *)sc.GetPersistentInt(8); //sc.PersistVars->i8;
  int& TickHistorySize = sc.GetPersistentInt(6); //sc.PersistVars->i6;






  if ((sc.UpdateStartIndex == 0) && (FirstBar == 0)) {

    sc.ResizeArrays(0);
    
    if (!sc.AddElements(1))
      return;