Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 06:55:18 +0000



[Programming Help] - Set subgraph value ACSIL

View Count: 502

[2023-02-22 11:42:19]
Tahir - Posts: 35
Hi guys,

I'm trying to create a simple indicator exercise which I hope you can help on.

Here's the logic:


If close[0] > high [1]
store the value of open [1]

so I want to store the value of the previous bar if this bar closes higher then the high of previous bar then I want to set that stored value to the subgraph so I can plot that on the chart.

It should be very simple but I cant seem to get anything to show up on the chart even though there are no build errors.
Thanks in advance for the help.
[2023-02-22 15:23:35]
JohnR - User831573 - Posts: 306
Tahir,

I would suggest you try using Visual Studio to run a debug session to be able to track your logic and values. There have been a # of forums topics on both here and other sites.

Hope this helps,
JohnR
Date Time Of Last Edit: 2023-02-22 15:24:08
[2023-02-22 15:34:26]
Tahir - Posts: 35
Hi John,
I should have clarified. I actually dont know if my code is right as I'm very new to coding so I would appreciate if anyone could write a sample code that I could work with and build on.
[2023-02-22 18:18:06]
User409050 - Posts: 22
you should post your entire code so anyone can help u to fix it, it could be lots of reasons for example your subgraph array doesn't have a name in the set default code block
or your subgraph array is an array data of the subgraph which can only be used to store intermediate calculations and can't be shown on the chart
Date Time Of Last Edit: 2023-02-22 18:18:25
[2023-02-22 19:40:06]
Sierra_Chart Engineering - Posts: 17221
Yes we need to see the source code so we can figure out the issue. Should be very easy to figure out.
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-02-25 01:23:18]
Tahir - Posts: 35
thanks for the response everyone.

code is below. I'm just trying to create a subgraph that plots a line whenever there we close above the previous bar. I'm trying to build on this idea. If I can get this to work then I should hopefully be able to create more advanced price action studies.

#include "sierrachart.h"

SCDLLName("Highs")

SCSFExport scsf_GetChartArrayExample(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Highs = sc.Subgraph[0];
  
  // Set configuration variables
  
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    
    sc.GraphName = "highs";
    sc.GraphRegion =0;
    
    sc.StudyDescription = "Draws a line at new highs.";
    
    Highs.Name = "Buy Level";
    Highs.DrawStyle = DRAWSTYLE_LINE;
    Highs.PrimaryColor = RGB(0,255,0);

    
    
    sc. AutoLoop = 1;
    
    return;
  }
  
    
  
  if (sc.Close[sc.Index] > sc.High[1])
    {
      
      Highs[sc.Index] = sc.High[sc.Index];



    }
  
  
}
[2023-02-25 03:47:45]
ondafringe - Posts: 286
In your "if" condition, try changing sc.High[1] to sc.High[sc.Index - 1]

if (sc.Close[sc.Index] > sc.High[sc.Index - 1])
{
Highs[sc.Index] = sc.High[sc.Index];
}

Date Time Of Last Edit: 2023-02-25 03:48:25
[2023-02-26 22:42:07]
Tony - Posts: 525
SC's bar index goes from left to right. The very first bar on the far left of the chart (it could be out of the window if you see a scroll bar at bottom of the chart window) has index number 0, so, sc.High[1] means the high value of the 2nd bar from far left. The index number of last bar (current bar) will be added one every time a new bar is printed, and it can be accessed by sc.Index.

Just in case, if you wonder why ondafringe use sc.High[sc.Index-1]
[2023-02-27 00:59:52]
Tahir - Posts: 35
Thank you everyone! I finally got this working.

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

Login

Login Page - Create Account