Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 08:51:12 +0000



Post From: Help With Building Custom Study

[2024-06-19 22:51:41]
limitlesstrevor - Posts: 3
I am trying to build a custom study that will send post data to a python script when a trade I entered or exited on Sierra chart, and I am getting error codes when I try to build it.

These are the error codes:

C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): note: Concatenating suffix 'type' with suffix 'entry'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): note: Concatenating suffix 'type' with suffix 'symbol'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): note: Concatenating suffix 'type' with suffix 'price'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(34): error C3688: invalid literal suffix 'type'; literal operator or literal operator template 'operator ""type' not found
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): note: Concatenating suffix 'type' with suffix 'exit'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): note: Concatenating suffix 'type' with suffix 'symbol'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): note: Concatenating suffix 'type' with suffix 'entry_price'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): note: Concatenating suffix 'type' with suffix 'exit_price'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3680: cannot concatenate user-defined string literals with mismatched literal suffix identifiers
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): note: Concatenating suffix 'type' with suffix 'points'
C:\SierraChart\ACS_Source\chickwasodpasda.cpp(51): error C3688: invalid literal suffix 'type'; literal operator or literal operator template 'operator ""type' not found

This is the code in the file I selected:

#include "sierrachart.h"
#include "scstructures.h"
SCDLLName("HTTP POST Example")
// Global variables to track trade entry and exit
float tradeEntryPrice = 0.0f; // Use 'f' for float literals
bool inTrade = false;
// Custom study function
SCSFExport scsf_HTTPPOSTExample(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "HTTP POST Example";
sc.AutoLoop = 1;
return;
}
// Define the URL of your Flask application endpoint
SCString URL = "http://127.0.0.1:5000/trade"; // Replace with your server's IP and port
// Fetch the symbol
SCString symbol = sc.GetChartSymbol(sc.ChartNumber);
// Get trade position data
s_SCPositionData PositionData;
if (!sc.GetTradePosition(PositionData))
{
// Handle error if unable to get position data
sc.AddMessageToLog("Failed to get trade position data", 1);
return;
}
// Check if there is an open position
if (PositionData.PositionQuantity != 0 && !inTrade)
{
tradeEntryPrice = static_cast<float>(PositionData.AveragePrice); // Explicitly cast to float
inTrade = true;
// Construct the POST data for entry
SCString POSTData = "{ "type": "entry", "symbol": "" + symbol + "", "price": "" + std::to_string(tradeEntryPrice) + "" }";
// Headers (if needed)
SCString Headers = "Content-Type: application/json";
// Make the HTTP POST request for entry
sc.MakeHTTPRequest(POSTData + Headers);
// Log the result
SCString logMessage = "HTTP POST Entry result: ";
sc.AddMessageToLog(logMessage, 0);
}
// Check if the position is closed
if (PositionData.PositionQuantity == 0 && inTrade)
{
float tradeExitPrice = static_cast<float>(sc.Close[sc.Index]); // Example: Exit using the current close price
inTrade = false;
// Calculate profit or loss in points
float profitLossPoints = tradeExitPrice - tradeEntryPrice;
// Construct the POST data for exit
SCString POSTData = "{ "type": "exit", "symbol": "" + symbol + "", "entry_price": "" + std::to_string(tradeEntryPrice) + "", "exit_price": "" + std::to_string(tradeExitPrice) + "", "points": "" + std::to_string(profitLossPoints) + "" }";
// Headers (if needed)
SCString Headers = "Content-Type: application/json";
// Make the HTTP POST request for exit
sc.MakeHTTPRequest(POSTData + Headers);
// Log the result
SCString logMessage = "HTTP POST Exit result: ";
sc.AddMessageToLog(logMessage, 0);
}
}

Would love some help with what I need to change in the code to fix this, thanks!