Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 01:39:30 +0000



[Programming Help] - Make HTTP request on each bar

View Count: 1623

[2018-06-15 13:55:37]
User38606 - Posts: 106
Hi. I have all my signals such as ENTRY/EXIT BUY EXIT and SELL EXIT in Spreadsheet Studies. It is an algorithm which is prescribed in spreadsheet study. All Shows up nicely on the chart. My next step is to send these signals via HTTP request to external soft for execution (i.e. Interactive Brokers or smth else API). How do I do this? What would you recommend to read? Thank you!
[2018-06-15 17:56:10]
Sierra Chart Engineering - Posts: 104368
This really is not within the scope of our support.

But there is this ACSIL function:
sc.MakeHTTPRequest()

We do not provide any programming help. We do not think it is practical to accomplish this and you will find this very difficult if not impossible.
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: 2018-06-15 17:56:35
[2022-10-03 07:18:35]
User743002 - Posts: 1
Hello, I tried sending a request on every bar using sc.MakeHTTPRequest(), using the exact same code you provided as an example in the documentation. It sends exactly one request in the beginning and then never sends again. Never timeouts, never closes the connection, never reconnects. How do I make it to send a request on every bar? Thank you!
[2024-07-13 23:07:35]
d9e5c763 - Posts: 108
if anyone else needs this functionality, you can refer to my code:

#include "sierrachart.h"

SCDLLName("SC Custom Studies")

SCSFExport scsf_ReadOpenInterest(SCStudyGraphRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "Intraday Open Interest";
sc.StudyDescription = "Reads Open Interest data from RESTful interface in intraday charts";

sc.AutoLoop = 1;
sc.GraphRegion = 1;
sc.ValueFormat = 26;

sc.Subgraph[0].Name = "Open Interest";
sc.Subgraph[0].DrawStyle = DRAWSTYLE_BAR;
sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0);

return;
}

SCString Message;
SCString Symbol = sc.Symbol;

n_ACSIL::s_BarPeriod BarPeriod;
sc.GetBarPeriodParameters(BarPeriod);

int SecondsPerBar = BarPeriod.IntradayChartBarPeriodParameter1;

if (Symbol && sc.Index == sc.DataStartIndex)
{
if (BarPeriod.ChartDataType != INTRADAY_DATA) {
sc.AddMessageToLog("this study is only for intraday charts", 1);
return;
}

if (BarPeriod.IntradayChartBarPeriodType != IBPT_DAYS_MINS_SECS) {
sc.AddMessageToLog("this study is only for time-based intraday charts", 1);
return;
}

Message.Format("chart bar period parameter (seconds): %d", SecondsPerBar);
sc.AddMessageToLog(Message, 1);

SCString timeZone = sc.GetChartTimeZone(sc.ChartNumber);

if (timeZone.Compare("UTC+00") != 0)
{
Message.Format("chart time zone is not UTC: %s", timeZone.GetChars());
sc.AddMessageToLog(Message, 1);
return;
}
}

  int& RequestState = sc.GetPersistentInt(1);
int& CurrentBarIndex = sc.GetPersistentInt(2);

  if (RequestState == HTTP_REQUEST_ERROR || RequestState == HTTP_REQUEST_RECEIVED)
  {
SCDateTime CurrentBarDateTime = sc.BaseDateTimeIn[CurrentBarIndex];
uint32_t DateTime = static_cast<uint32_t>(CurrentBarDateTime.ToUNIXTime());

SCString RequestURL;
RequestURL.Format("http://127.0.0.1:8001/%s/%d/%u", Symbol.GetChars(), SecondsPerBar, DateTime);

    if (!sc.MakeHTTPRequest(RequestURL))
    {
      return;
    }

    RequestState = HTTP_REQUEST_MADE;
  }

if (RequestState == HTTP_REQUEST_MADE && sc.HTTPRequestID != 0)
{
const char* HTTPResponseChars = sc.HTTPResponse.GetChars();
if (isdigit(HTTPResponseChars[0]))
{
RequestState = HTTP_REQUEST_RECEIVED;
int OpenInterestValue = atoi(HTTPResponseChars);
sc.Subgraph[0][CurrentBarIndex] = OpenInterestValue;

Message.Format("CurrentBarIndex: %d; OpenInterestValue: %d", CurrentBarIndex, OpenInterestValue);
sc.AddMessageToLog(Message, 1);

if (OpenInterestValue > 0) {CurrentBarIndex++;}
}
}
}

btw, is there any way to disable the 'Making HTTP request.' message from being displayed in the message log? this message will appears every time when the chart is refreshed or updated

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

Login

Login Page - Create Account