Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 20:43:26 +0000



Referencing BaseData from a Daily Chart

View Count: 1432

[2015-08-14 21:49:30]
User424542 - Posts: 6
I'm trying to reference the High,Low, Open, and Close from the BaseData of a Daily Chart from a study that I have in a 5 min Chart. I would like to reference the previous day's HLOC and today's Open on the Daily Chart. When I run this on the daily chart it works but when I run it on my 5 minute chart, it does not work.

SCInputRef ChartBaseData = sc.Input[7];

if (sc.SetDefaults)
  {

ChartBaseData.Name = "Daily Chart";
    ChartBaseData.SetChartNumber(3);



    return;
  }

SCGraphData BaseData;
  sc.GetChartBaseData(ChartBaseData.GetChartNumber(), BaseData);

  SCFloatArrayRef PreviousDayHigh = BaseData[SC_HIGH];

  float PrevDayHigh = PreviousDayHigh[sc.Index - 1];

  SCFloatArrayRef PreviousDayLow = BaseData[SC_LOW];

  float PrevDayLow = PreviousDayLow[sc.Index - 1];

  float PrevDayAvg = (PrevDayHigh + PrevDayLow) / 2;

  SCFloatArrayRef TodayOpen = BaseData[SC_OPEN];

  float DayOpen = TodayOpen[sc.Index];


I need to run it on the 5 minute chart because we would like to flatten all trades at the close of day and the formula for flattening does not work on the daily chart as it needs to access HMS from the 5 minute chart. I have checked the chart number and it's 3.
[2015-08-15 08:39:53]
Sierra Chart Engineering - Posts: 104368
We do not see any obvious problems.

What does this line of code return:
int Size = BaseData[SC_HIGH].GetArraySize();

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-08-15 08:40:10
[2015-08-15 21:02:29]
User126996 - Posts: 30
Thanks but it still doesn't execute a buy or sell like the study does when it's loaded onto the daily chart. I injected a code with a message into the Buy/Sell functions which would appear in the message log to help identify potential errors. During back testing once the study is loaded and then applied to the 5 minute chart, it attempts to Sell, Buy, Sell, Buy, and then the stops. I start both charts and it does not attempt to execute any part of the Buy/Sell functions. The message log is blank. When it's loaded onto the daily chart and it does the same thing but when I play both charts it continuously is looking to Sell or Buy until it finds the necessary condition at which time it executes a trade and then repeats this action. I guess why does it not continuously look for a trade on the 5 minute chart when played like it does on the daily?
[2015-08-15 21:56:15]
Sierra Chart Engineering - Posts: 104368
There is no need to provide the details given in post #3. This kind of information is not needed for the scope of our support and it does not mean anything to someone who did not do the programming.

We are only looking at the code for any obvious errors for referencing the daily chart.

This is the problem:
float PrevDayHigh = PreviousDayHigh[sc.Index - 1];

You must use the array size of the daily chart array. So this needs to be:
float PrevDayHigh = PreviousDayHigh[PreviousDayHigh.GetArraySize() - 2];



We have explained this here:
https://www.sierrachart.com/index.php?page=doc/doc_ACSILRefOtherTimeFrames.php#AccessingCorrectArrayIndexes
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-08-15 21:56:38

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account