Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 09:38:52 +0000



Post From: REPORT CODING ISSUE -8998

[2023-12-21 09:59:36]
User103688 - Posts: 9
Good Morning,
I'm trying to make my first Custom Study for automatic trading and I recive this error from Message Log:
-8998
;
Surfing in the web I found that in Sierra Chart, when encountered during order placement, typically indicates an issue with the order configuration or a problem with the connection to the trading service.
I'm with Stage5 for the connection with Denali Data Feed and I specify the symbol like
newOrder.Symbol = "ESH24_FUT_CME";
and nothing changes.
Can Someone help me, please?

The entire code is:

#include "sierrachart.h"
SCDLLName("MyTradingSystem")

SCSFExport scsf_SimpleEMiniLimitOrderBot(SCStudyInterfaceRef sc)
{
SCInputRef OrderPlacedFlag = sc.Input[0];

if (sc.SetDefaults)
{
// Set the configuration
sc.GraphName = "Simple E-Mini Limit Order Bot - 4 Ticks Below";
    sc.GraphRegion = 0; // Set the study to display in region 1
sc.StudyDescription = "Places a limit order for the E-mini S&P 500, 4 ticks below the current price.";
sc.AutoLoop = 0;

OrderPlacedFlag.Name = "Order Placed Flag";
OrderPlacedFlag.SetInt(0);

return;
}

if (OrderPlacedFlag.GetInt() == 1)
{
return; // Exit if order has already been placed
}

// Get the current market price
float currentPrice = sc.Close[sc.ArraySize - 1];

// Define the order
s_SCNewOrder newOrder;
  newOrder.OrderQuantity = 1;
  newOrder.OrderType = SCT_ORDERTYPE_MARKET;
  newOrder.TextTag = "Trading example tag";
  newOrder.Symbol = "ESH24_FUT_CME";
  newOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;

// Send the order
  int OrderID = 0;
  SCString logMessage;
  int result = sc.BuyEntry(newOrder, OrderID);

  if (result != 1) { // Assuming '1' indicates a successful order placement
logMessage.Format("Order placement failed with error code: %d", result);
sc.AddMessageToLog(logMessage, 1); // Logging in the Trade Service Log
  logMessage.Format("Attempting to place order. Price: %f, Quantity: %d, Symbol: %s", currentPrice, newOrder.OrderQuantity, newOrder.Symbol);
  sc.AddMessageToLog(logMessage, 1);
  } else {
    logMessage.Format("Order placed successfully. Order ID: %d", OrderID);
    sc.AddMessageToLog(logMessage, 0); // Logging in the Message Log
  }

// Set the flag indicating that the order has been placed
OrderPlacedFlag.SetInt(1);
}