Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 10:53:20 +0000



[Programming Help] - TickValue & PointValue for Instrument

View Count: 252

[2024-05-28 19:57:54]
User567781 - Posts: 5
I see sc.TickSize in the ACSIL. However, I do not see the PointValue for the Instrument on the chart. Is there an ACSIL reference to obtain this. I am trying to do the following:

float dollarvalue = PointValue * TickSize * ticks * contracts.
[2024-06-09 19:20:15]
User567781 - Posts: 5
Here is how I approached the contract values in case anyone else needs some help:

//prototypes
float GetTickSize(SCStudyGraphRef sc, SCString attachedInstrument);
float ConvertTicksToDollars(SCStudyGraphRef sc, int ticks, int contracts);
float GetTickValue(SCStudyGraphRef sc, SCString attachedInstrument);
float GetTicksPerPoint(SCStudyGraphRef sc, float tickSize);

float GetTickSize(SCStudyGraphRef sc, SCString attachedInstrument)
{
  float tickSize = sc.TickSize;

  return (tickSize);
}
float ConvertTicksToDollars(SCStudyGraphRef sc, int ticks, int contracts)
{
  float dollarValue = 0;

  if (ticks > 0 && contracts > 0)
  {
    float tickValue = sc.CurrencyValuePerTick;

    float tickSize = sc.TickSize;
    
    dollarValue = tickValue * ticks * contracts;
  }

  return dollarValue;
}
float GetTickValue(SCStudyGraphRef sc, SCString attachedInstrument)
{
  float tickValue = 0;
  //float tickValue = instrument.MasterInstrument.PointValue * CustomChartBarInterface.TickSize;
  //PointValue = currency val of 1 point move $20 for nq, $2 for mnq
  //ticksize = 0.25 4 per point
  //mnq 1 tick $0.50
  //nq 1 tick $5.00
  //.25*20 = $5

  tickValue = sc.CurrencyValuePerTick;

  return tickValue;
}
float GetTicksPerPoint(SCStudyGraphRef sc, float tickSize)
{
  float tickPoint = 1;

  if (tickSize < 1)
  {
    tickPoint = (float)(1.0 / tickSize);
  }

  return (tickPoint);
}
[2024-06-10 00:19:58]
emmanuel - Posts: 57
In your function `GetTicksPerPoint(SCStudyGraphRef sc, float tickSize)` you are dividing by tickSize. If the tick size somehow ends up being zero, you'll get a division by zero error. That would probably crash your study.

It's worth handling that situation.
Date Time Of Last Edit: 2024-06-10 00:20:17

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

Login

Login Page - Create Account