Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 17:02:25 +0000



[Programming Help] - Saving Tick by Tick Data from a 256,000 Tick Chart

View Count: 1501

[2016-08-15 02:31:34]
User203925 - Posts: 40
I am attempting to parse tick by tick data to a file from a 256,000 tick chart which includes the sc.BaseData[SC_LAST] and my indicator PPO[sc.Index].

I have tried the following code on a 256,000 chart.

ofstream outFile;
outFile.open("ProjectData.txt");

  for (int i = 0; i <= sc.BaseDataIn[SC_LAST].GetArraySize(); i++)
  {
    float Value;
    Value = sc.BaseDataIn[SC_LAST][sc.Index - i];
outFile << Value << "," << PPO[sc.Index] << endl;

}

}
  outFile.close();
  return;

The file does "read" the tick by tick data for my indicator and the price but it only saves sc.BaseData[SC_LAST][sc.Index-1] and PPO[sc.Index-1].

I then tried to use a 1 tick chart and pull the indicator from the 256000 chart but that did not work either. Code Below

SCFloatArray Chart256000;
sc.GetStudyArrayFromChartUsingID(4, 1, 8, Chart256000);
  
PPO2[sc.Index] = Chart256000[sc.Index];
Chart256000[sc.Index] = PPO2[sc.Index];


ofstream outFile;
outFile.open("ProjectDataV5.txt");

      for (int i = 0; i <= sc.BaseDataIn[SC_LAST].GetArraySize(); i++)
      {

        Value = sc.BaseDataIn[SC_LAST][sc.Index - i];
        outFile << Value << "," << PPO2[sc.Index] << endl;
        

      }

      outFile.close();

      //return;

Is there a way to save tick by tick data (data = indicator and price fluctuation from a 256,000 tick chart or any chart greater than 1 tick ?
[2016-08-16 00:14:35]
User203925 - Posts: 40
I found my error! So this is closed
[2016-08-16 18:47:06]
User203925 - Posts: 40
I apologize but I have one more question. I am pulling an indicator from a 256,000 tick chart into a 1 tick chart using sc.GetStudyArrayFromChartUsingID function. The issue I have encountered is that it pulls the indicator from the 256,000 tick chart into the 1 tick chart "as is" meaning it's only pulling the last indicator value of each bar based on the 2560,000 instead of pulling the value of the indicator on the 256,000 for every tick on the 1 tick chart.

I how do I pull the indicator value from the 256,000 tick chart for every tick on the 1 tick chart?
[2016-08-16 18:49:22]
User203925 - Posts: 40
Code below



SCFloatArray Chart256000;
sc.GetStudyArrayFromChartUsingID(4, 1, 8, Chart256000);

PPOFloat1 = Chart256000[sc.Index];
PPOFloat2 = Chart256000[sc.Index - 1];

PPO2[sc.Index] = PPOFloat1;

ofstream outFile;
outFile.open("ProjectDataV6.txt");

for (int i = 0; i <= sc.BaseDataIn[SC_LAST].GetArraySize(); i++)

{
Value = sc.BaseDataIn[SC_LAST][sc.Index - i];
PPOFloat1 = PPO2[sc.Index - i];
outFile << Value << "," << PPOFloat1 << endl;
}

      outFile.close();

      return;
    }



[2016-08-16 18:59:04]
Sierra Chart Engineering - Posts: 104368
The answer to this is that you cannot:
I how do I pull the indicator value from the 256,000 tick chart for every tick on the 1 tick chart?

Refer to:
Referencing Other Time Frames and Symbols When Using the ACSIL
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
[2016-08-16 19:17:00]
User203925 - Posts: 40
Is there any way to record movement in an indicator on sc.BaseData[SC_LAST][sc.Index]? So as the price value on sc.BaseData[SC_LAST][sc.Index] moves my indicator moves. I am trying to parse and save the value change in my indicator based on this movement. Is this possible at all? Using SCDateTime? Or PermStorage?
[2016-08-16 19:38:12]
Sierra Chart Engineering - Posts: 104368
No, the only way to do what you want is to set the chart bars to 1 Number of Trades per Bar in order to have a study value at each trade.
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
[2016-08-16 19:52:14]
User203925 - Posts: 40
So in summary....
I am going to have to input the basedata from the 256,000 tick chart into a study that I will place on the 1 tick chart. I am going to have to calculate my indicator in this study with the imported basedata and then input the indicator into my "for" statement above. Is this correct?
[2016-08-16 19:59:06]
Sierra Chart Engineering - Posts: 104368
This is not clear for us and we do not provide programming help.
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
[2016-08-16 20:37:07]
User203925 - Posts: 40
I'm not asking for programming help. The issue is that the indicator has different values at different size tick charts and the indicators change at different rates on different size charts. So just putting the indicator on the 1 Tick chart wouldn't work.

My main question is how your platform works because the answer revolves around how you save data and how functions pull from that data. I am looking for a function that:

1) Can pull a Subgraph Array from a larger chart to a smaller chart in real time.
2) The function should import this Subrgraph Array from the larger chart into my smaller chart so I can see the changes in this indicator without having to look at the bigger chart. If you can get me this far, I can do the rest but I don't know how your functions pull data and how you save data as a I do not have access to the source code

Is there a function that does this? sc.GetStudyArrayFromChartUsingID does not work. I have Autolooping turned on. Is there another feature that should be turned? In theory my code above should work if sc.GetStudyArrayFromChartUsingID imporated the Subgraph Array in real time. It is only imporiting
[2016-08-16 21:03:36]
User203925 - Posts: 40
Use sc.GetStudyArrayFromChartUsingID to pull any indicator / Array from one chart to another chart. Now when the charts are the same tick size the indicators are equal. But if you reduce the tick size of one of the charts so the size of the charts are not equal, the indicator/array on the reduced size does not calculate up to BaseData[SC_LAST][sc.Index]. Here is the code below to import the indicator/array. See for yourself.



#include "sierrachart.h"

SCSFExport scsf_Master_Storage(SCStudyGraphRef sc)
{
SCSubgraphRef PPO2 = sc.Subgraph[1];
float PPOFloat1 = sc.GetPersistentFloat(1);

if (sc.SetDefaults)
  {
    //Long descriptive name.
    sc.GraphName = "Master Storage";

    sc.StudyVersion = 1.0;

    // During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 1;

    //Data for the "Display Study Documentation" button
    sc.StudyDescription = "Storing PPO Values per tick to file";
    //needed for extra tick data.
    sc.MaintainAdditionalChartDataArrays = 1;

    //sc.GraphRegion = 1; //in this case, not main price graph

    sc.AutoLoop = 1; //Auto looping is enabled.

    //Keep alerts from going crazy.
    sc.AlertOnlyOncePerBar = true;

    //Initial setting for decimal places. Will be changed on first run.
    sc.ValueFormat = 0;

    PPO2.Name = "Percentage Price Oscillator";
    PPO2.DrawStyle = DRAWSTYLE_LINE;
    PPO2.PrimaryColor = COLOR_GREEN;
    PPO2.SecondaryColor = COLOR_RED;
    PPO2.AutoColoring = AUTOCOLOR_SLOPE;


    return;
  }


SCFloatArray Chart256000;
sc.GetStudyArrayFromChartUsingID(4, 1, 8, Chart256000);

PPO2[sc.Index] = Chart256000[sc.Index];
Chart256000[sc.Index] = PPO2[sc.Index];

}


[2016-08-16 22:42:35]
Sierra Chart Engineering - Posts: 104368
In response to post #10, refer to:
Referencing Other Time Frames and Symbols When Using the ACSIL


That page comprehensively explains this subject. There simply is nothing more to add.
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
[2016-08-16 22:53:40]
Sierra Chart Engineering - Posts: 104368
Also you will want to use the Study/Price Overlay study which the page explains, because implementing the logic of that study yourself is going to be quite complicated.
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: 2016-08-16 22:53:59
[2016-08-16 23:08:48]
Sierra Chart Engineering - Posts: 104368
So it would be good to work with the Study/Price Overlay study between those two charts. Once you get it configured the way you want, then of course you can directly reference the data in that overlay study. If you cannot accomplish what you want with that study, then what you are looking for is just not supported.
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
[2016-08-16 23:56:35]
User203925 - Posts: 40
K, Thank you for the insight and the response. I will post any progress so you don't have to answer this for another user
[2016-08-18 00:21:30]
User203925 - Posts: 40
Here is one way to save tick by tick fluctuations between an indicator and the price when the indicator is on different size charts:

Debugging:
1) In the properties settings Go to "C/C++" -> "Code Generation" -> and set "Runtime Library" to Inherit from Parent or leave blank

The projects.
1) Save your indicator on your larger tick chart to a float
2) Pull the float into another study on the 1 tick chart with sc.GetStudyPersistentFloatFromChart(). See code Below


if (sc.Index >= 0) {

Indicator = sc.GetStudyPersistentFloatFromChart(1, 1, 0);
Subgraph[sc.Index] = Indicator;
    

ofstream outFile;
outFile.open("ProjectDataV8.txt");

for (int i = 0; i <= sc.BaseDataIn[SC_LAST].GetArraySize(); i++)
{
PriceValue = sc.BaseDataIn[SC_LAST][sc.Index - i];
Indicator = Subgraph[sc.Index - i];
      
outFile << Value << "," << Free << endl;
}
outFile.close();
return;

Loading the studies.
1) Start your backtest and pause it right away.
2) After you have paused your backtest, load your studies starting with the study on the 1 tick chart. Next, load your study that contains your indicator on the larger chart.
3) Push "Play" on the back test and it will start to write the tick by tick data to file.

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

Login

Login Page - Create Account