Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 18:31:48 +0000



Synchronous ASCIL method to draw on a chart on demand?

View Count: 1160

[2014-11-02 16:10:48]
maxima120 - Posts: 144
I know that the cornerstone of user created studies in ASCIL is to place the code into a scsf_Xxxx method which will be called asynchronously from within the SC core code on each tick.

Lets say I have a regular chart #1.

Now imagine I have a some sort of event happened in another chart #2.

I want to be able to call a method synchronously (from within the scsf_SomeChart2Study) on the chart #1 and tell it to draw something on chart #1.

I know its not something you might want to consider lightly but sooner or later these sorts of interactions between charts will become inevitable.

My advice would be to get on with it rather sooner. So you can implement it in your own time rather to some deadline.

My idea of implementation would be:

1. create a dictionary of all charts in chartbook accessible from all custom studies.
2. create synchronous methods on chart objects (which might be just functions to call within common sense, like calling draw tool on that chart regardless the state of the chart (eg in between ticks)

or alternatively
2. trigger a 'tick' artificially by calling something on chart #2 from chart #1
eg


SCSFExport scsf_StudyOnChart1(SCStudyInterfaceRef sc)
{
...
chart2.OnTick();
...
}

[2014-11-06 18:18:29]
Sierra Chart Engineering - Posts: 104368
This is already supported.

Refer to this member of the s_UseTool structure:
https://www.sierrachart.com/index.php?page=doc/doc_ACSILDrawingTools.html#ChartNumber
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
[2014-11-07 11:22:59]
maxima120 - Posts: 144
ok lets say I use the tool drawing for this and I set the ChartNumber to the chart #2.

How do I get access to the chart #2 context (SCStudyGraphRef) ? I need the chart #2 the last index and the last price.

eg.
Tool.BeginIndex = sc2.Index;
Tool.BeginValue = sc2.Subgraph[4];
[2014-11-09 09:16:49]
Zosimus - Posts: 345
This function can help you find an index on the second chart that corresponds to a specific index on the first chart:

http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetContainingIndexForDateTimeIndex


This function can help you retrieve all the data of a specific subgraph from a specific study on another chart:

http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetStudyArrayFromChartUsingID


I hope this helps.
[2014-11-09 18:54:11]
maxima120 - Posts: 144
Thank you.. I believe I followed both of your advices. But I dont get any markers. I never used Tools in ASCIL before.. Would appreciate a bit of further help..


  if (sc.SetDefaults)
  {
    sc.GraphName = "StudyCrossMarker2 (using tools to plot on another chart)";
    
    sc.GraphRegion = 0;
    sc.FreeDLL = 1;
    sc.AutoLoop = 0;
    sc.CalculationPrecedence = LOW_PREC_LEVEL;
...
}
...

  if(xUp)
  {
    LongCross[sc.Index] = sc.Close[sc.Index];

    SCFloatArray otherChart;

    sc.GetStudyArrayFromChartUsingID(otherChartReference.GetChartStudySubgraphValues(), otherChart);

    int otherChartNumber = otherChartReference.GetChartNumber();
    
    int otherChartIndex = sc.GetContainingIndexForDateTimeIndex(otherChartNumber, sc.Index);
  
    //
    s_UseTool Tool;

    Tool.Clear();
    Tool.ChartNumber = otherChartNumber;

    Tool.DrawingType = DRAWING_MARKER;
    Tool.LineNumber = toolIndex++;

    Tool.BeginIndex = otherChartIndex;
    Tool.BeginValue = otherChart[otherChartIndex];

    Tool.Color = RGB(0,200,0);
    Tool.AddMethod = UTAM_ADD_OR_ADJUST;

    Tool.MarkerType = MARKER_POINT;
    Tool.MarkerSize = 80;

    Tool.LineWidth = 50;

    sc.UseTool(Tool);
    
    //    
    SCString message;
    message.Format("LONG. Other chart: number %d index %d value %f. Tool number %d.", otherChartNumber, otherChartIndex, otherChart[otherChartIndex], Tool.LineNumber);
    sc.AddMessageToLog(message, 0);
  }


Chart: Replay 30.0X: Chart #7 | Study: StudyCrossMarker2 (using tools to plot on another chart) | LONG. Other chart: number 10 index 949 value 1925.000000. Tool number 135. | 2014-11-09 18:38:50
Chart: Replay 30.0X: Chart #7 | Study: StudyCrossMarker2 (using tools to plot on another chart) | LONG. Other chart: number 10 index 949 value 1925.000000. Tool number 136. | 2014-11-09 18:38:50
Chart: Replay 30.0X: Chart #7 | Study: StudyCrossMarker2 (using tools to plot on another chart) | LONG. Other chart: number 10 index 949 value 1925.000000. Tool number 137. | 2014-11-09 18:38:50

The chart number and the value seems very much correct. The study is applied on chart 7 and supposed to draw on chart 10.. But there is nothing (I set large marker size to make sure I can see it !! :))
[2014-11-09 19:20:13]
Zosimus - Posts: 345
Somewhere among the Tool properties lines (after s_UseTool Tool; ) add a line : Tool.AddAsUserDrawnDrawing = 1;
[2014-11-09 20:18:30]
maxima120 - Posts: 144
yep it worked! thanks a lot :)

P.S. should SC update their help pages with that?
Date Time Of Last Edit: 2014-11-09 20:18:51
[2014-11-09 20:50:08]
Zosimus - Posts: 345
This is the documentation that would have helped you:

http://www.sierrachart.com/index.php?l=doc/doc_ACSILDrawingTools.html#ChartNumber

But, yeah... could be added in a more central place.
[2014-11-09 23:01:31]
maxima120 - Posts: 144
yeah.. I meant that page - it has Code Example on the top - I copied it. so the AddAsUserDrawnDrawing must be in the example as otherwise it wont work. right?
[2014-11-09 23:39:00]
Zosimus - Posts: 345
The code example uses: Tool.ChartNumber = sc.ChartNumber; which means that it wants to draw the tool on the same chart and in this case there is no problem. The AddAsUserDrawnDrawing = 1 is required only when you want to draw on another chart.

[2014-11-11 03:24:00]
Sierra Chart Engineering - Posts: 104368
There has been a small improvement that was made to ensure the drawing appears immediately when adding an ACSIL drawing to another chart. Update to 1210 or higher.
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

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

Login

Login Page - Create Account