Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 10:36:19 +0000



Post From: unable to get spreadsheet value

[2023-09-05 05:42:10]
User373245 - Posts: 42
I am trying to dump the value of a study angle into the spreadsheet when my alert condition is true....The alert condition works and the spreadsheet handle is all working. I just cant figure out how to get it to store the value that is in the cell when the long and short signal become true. The study is a line angle that I need the value to when the long or short becomes true on a replay...so I can study it over a certain length of data.

Ive also tried creating an input from a subgraph and both get and set input and building an array and getting it that way and wasn't able to either.

SCInputRef Input_240StnAngle = sc.Input[4];
Input_240StnAngle.Name = "240 STN Val";
Input_240StnAngle.SetChartStudySubgraphValues(17, 73, 0);


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


SCSFExport scsf_SpreadsheetInteractionEx(SCStudyInterfaceRef sc)
{
   SCSubgraphRef Subgraph_SignalState = sc.Subgraph[1];
   SCSubgraphRef Subgraph_240StnAngle = sc.Subgraph[2];
  
   SCInputRef Input_LongSignalSelection = sc.Input[2];
   SCInputRef Input_ShortSignalSelection = sc.Input[3];
   SCInputRef Input_240StnAngle = sc.Input[4];
  
   SCFloatArrayRef Array_240StnAngle = Subgraph_SignalState.Arrays[2];
  
   if (sc.SetDefaults)
{
// Set the configuration and defaults

sc.GraphName = "Spreadsheet Interaction Example";
sc.AutoLoop = 1;

  Subgraph_SignalState.Name = "Standard deviation line angle";
  Subgraph_SignalState.DrawStyle = DRAWSTYLE_LINE;
  
  Subgraph_240StnAngle.Name = "Standard deviation line angle";
  Subgraph_240StnAngle.DrawStyle = DRAWSTYLE_LINE;
  
  Input_LongSignalSelection.Name = "Select Long Signal";
  Input_LongSignalSelection.SetChartStudySubgraphValues(17, 67, 0);

  Input_ShortSignalSelection.Name = "Select Short Signal";
  Input_ShortSignalSelection.SetChartStudySubgraphValues(17, 68, 0);  
  
    Input_240StnAngle.Name = "240 STN Val";
Input_240StnAngle.SetChartStudySubgraphValues(17, 73, 0);
    
  
  
}
  
  void* sheetHandle = NULL;

  SCFloatArray LongArray;      
  sc.GetStudyArrayUsingID(Input_LongSignalSelection.GetStudyID(), Input_LongSignalSelection.GetSubgraphIndex(), LongArray);

    if (LongArray.GetArraySize() == 1)
  return;

  SCFloatArray ShortArray;
  sc.GetStudyArrayUsingID(Input_ShortSignalSelection.GetStudyID(), Input_ShortSignalSelection.GetSubgraphIndex(), ShortArray);

    if (ShortArray.GetArraySize() == -1)
  sc.GetStudyArrayFromChartUsingID(Input_ShortSignalSelection.GetChartStudySubgraphValues(), ShortArray);


  bool LongSignal = LongArray[sc.Index];
  bool ShortSignal = ShortArray[sc.Index];
  if (sc.Index == 0)
  {
  //if((LongSignal || ShortSignal) && Subgraph_SignalState[sc.Index] == 0)
if ((LongSignal || ShortSignal) && (sheetHandle != NULL))
{
    const char* SheetCollectionName = "ACSILInteractionExample";
    const char* SheetName = "Sheet17";
    void* SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false);
    sc.AddMessageToLog("Long Or Signal Condition is TRUE", 0);
     double currentValue = 0.0;
sc.GetSheetCellAsDouble(sheetHandle, 63, 2, currentValue);

// Modify currentValue if needed
// ...

// Store the modified value back in the spreadsheet
sc.SetSheetCellAsDouble(sheetHandle, 63, 2, currentValue);
}



  
  }  
  return;
  
  
}