Class ChartData

java.lang.Object
com.strategyquant.tradinglib.debug.Debugger
com.strategyquant.tradinglib.ChartData
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StrategyBase

public class ChartData extends com.strategyquant.tradinglib.debug.Debugger implements Serializable
The Class ChartData.
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    The Constant ChartTF_D1.
    static int
    The Constant ChartTF_M1.
    static int
    The Constant ChartTF_W1.
    The Close.
    The Connection.
    int
    The Event type.
    The High.
    The Instrument.
    static org.slf4j.Logger
    The Constant Log.
    The Low.
    com.strategyquant.tradinglib.strategy.MarketData
    The Market data.
    com.strategyquant.datalib.dataseries.ComputedDataSeries
    The Median.
    The Open.
    The Symbol.
    com.strategyquant.datalib.dataseries.TimeDataSeries
    The Time.
    The Timeframe.
    com.strategyquant.datalib.dataseries.ComputedDataSeries
    The Typical.
    The Volume.
    com.strategyquant.datalib.dataseries.ComputedDataSeries
    The Weighted.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a new chart data.
    ChartData​(com.strategyquant.tradinglib.strategy.MarketData marketData, ChartDef chartDef, int serieIndex, int backtestEngine)
    Instantiates a new chart data.
    ChartData​(String timeframe, com.strategyquant.datalib.dataseries.TimeDataSeries time, DataSeries open, DataSeries high, DataSeries low, DataSeries close, DataSeries volume, com.strategyquant.datalib.dataseries.TimeDataSeries timeD, DataSeries openD, DataSeries highD, DataSeries lowD, DataSeries closeD, com.strategyquant.datalib.dataseries.TimeDataSeries timeW, DataSeries openW, DataSeries highW, DataSeries lowW, DataSeries closeW, com.strategyquant.datalib.dataseries.TimeDataSeries timeM, DataSeries openM, DataSeries highM, DataSeries lowM, DataSeries closeM)
    Instantiates a new chart data.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Ask()
    Ask.
    int
    Bars.
    int
    Bars​(int chartIndex)
    Bars.
    double
    Bid()
    Bid.
    double
    Returns BigPointValue (Tradestation compatibility)
    int
    Chart hash code.
    cloneForTF​(int chartTF)
    Clone for TF.
    double
    Close​(int shift)
    Close.
    double
    Close​(int chartIndex, int shift)
    Close.
    double
    CloseD​(int shift)
    Close D.
    double
    CloseD​(int chartIndex, int shift)
    Close D.
    double
    CloseM​(int shift)
    Close M.
    double
    CloseM​(int chartIndex, int shift)
    Close M.
    double
    CloseW​(int shift)
    Close W.
    double
    CloseW​(int chartIndex, int shift)
    Close W.
    void
    destroys all objects in this market data and frees offheap memory.
    void
    findTickInData​(TickEvent tick, int eventTypeToProcess, boolean callCloseEvent, boolean updateData, int dataSerie)
    Find tick in data.
    void
    findTickInDataComplete​(TickEvent tick, int eventTypeToProcess)
    there are always two calls of processTick() from MarketData for every tick: - first for BarClose event, and then for BarOpen event
    int
    Gets the connection hash.
    Gets the connection name.
    int
    Gets the current bar.
    int
     
    Gets the instrument info.
    double
    Gets the min distance.
    int
    Gets the serie index.
    getSeries​(int serieType)
    Gets the series.
    getSeries​(int serieType, int chartTF)
    Gets the series.
    Gets the symbol.
    int
    Gets the symbol hash.
    double
    High​(int shift)
    High.
    double
    High​(int chartIndex, int shift)
    High.
    double
    HighD​(int shift)
    High D.
    double
    HighD​(int chartIndex, int shift)
    High D.
    double
    HighM​(int shift)
    High M.
    double
    HighM​(int chartIndex, int shift)
    High M.
    double
    HighW​(int shift)
    High W.
    double
    HighW​(int chartIndex, int shift)
    High W.
    boolean
    returns true if current tick starts a new bar - means it is open of a new bar Reguired for realistic gaps handling in MT4.
    boolean
    isNextDay​(TickEvent tickEvent)
    Checks if is next day.
    boolean
    returns true if this chart was updated in the recent tick.
    double
    Low​(int shift)
    Low.
    double
    Low​(int chartIndex, int shift)
    Low.
    double
    LowD​(int shift)
    Low D.
    double
    LowD​(int chartIndex, int shift)
    Low D.
    double
    LowM​(int shift)
    Low M.
    double
    LowM​(int chartIndex, int shift)
    Low M.
    double
    LowW​(int shift)
    Low W.
    double
    LowW​(int chartIndex, int shift)
    Low W.
    double
    Median​(int shift)
    Median.
    double
    Returns MinMove (Tradestation compatibility)
    double
    Open​(int shift)
    Open.
    double
    Open​(int chartIndex, int shift)
    Open.
    double
    OpenD​(int shift)
    Open D.
    double
    OpenD​(int chartIndex, int shift)
    Open D.
    double
    Openint​(int shift)
    Openint.
    double
    OpenM​(int shift)
    Open M.
    double
    OpenM​(int chartIndex, int shift)
    Open M.
    double
    OpenW​(int shift)
    Open W.
    double
    OpenW​(int chartIndex, int shift)
    Open W.
    double
    Returns PriceScale (Tradestation compatibility)
    void
    processTick​(TickEvent tick, int eventTypeToProcess, int seriesCount)
    there are always two calls of processTick() from MarketData for every tick: - first for BarClose event, and then for BarOpen event
    void
    processTickSimplified​(TickEvent tick, int seriesCount)
    simplified tick processing for bars - used only in MarketData.requestHistoryData()
    void
    Reset prepared data shifts.
    void
    setCurrentBar​(int reservedBars, int userDefinedStartingBar)
    Sets the current bar.
    void
    setIndyStartingBar​(int indyStartingBar)
     
    void
    Sets the instrument info.
    void
    setPerformanceParams​(boolean hasOnTickRule, boolean hasDailyDataBlock, boolean hasWeeklyDataBlock, boolean hasMonthlyDataBlock)
    Sets the performance params.
    void
    setSymbol​(String symbol)
    Sets the symbol.
    long
    Time.
    long
    Time​(int shift)
    Time.
    long
    Time​(int chartIndex, int shift)
    Time.
    long
    Time current.
    long
    TimeD​(int shift)
    Time D.
    long
    TimeM​(int shift)
    Time M.
    long
    TimeW​(int shift)
    Time W.
    double
    Typical​(int shift)
    Typical.
    double
    Volume​(int shift)
    Volume.
    double
    Volume​(int chartIndex, int shift)
    Volume.

    Methods inherited from class com.strategyquant.tradinglib.debug.Debugger

    debug, fdebug

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • Log

      public static final org.slf4j.Logger Log
      The Constant Log.
    • ChartTF_D1

      public static final int ChartTF_D1
      The Constant ChartTF_D1.
      See Also:
      Constant Field Values
    • ChartTF_W1

      public static final int ChartTF_W1
      The Constant ChartTF_W1.
      See Also:
      Constant Field Values
    • ChartTF_M1

      public static final int ChartTF_M1
      The Constant ChartTF_M1.
      See Also:
      Constant Field Values
    • Time

      public com.strategyquant.datalib.dataseries.TimeDataSeries Time
      The Time.
    • Open

      public DataSeries Open
      The Open.
    • High

      public DataSeries High
      The High.
    • Low

      public DataSeries Low
      The Low.
    • Close

      public DataSeries Close
      The Close.
    • Median

      public com.strategyquant.datalib.dataseries.ComputedDataSeries Median
      The Median.
    • Typical

      public com.strategyquant.datalib.dataseries.ComputedDataSeries Typical
      The Typical.
    • Weighted

      public com.strategyquant.datalib.dataseries.ComputedDataSeries Weighted
      The Weighted.
    • Volume

      public DataSeries Volume
      The Volume.
    • MarketData

      public com.strategyquant.tradinglib.strategy.MarketData MarketData
      The Market data.
    • Connection

      public String Connection
      The Connection.
    • Symbol

      public String Symbol
      The Symbol.
    • Instrument

      public String Instrument
      The Instrument.
    • Timeframe

      public String Timeframe
      The Timeframe.
    • EventType

      public int EventType
      The Event type.
  • Constructor Details

    • ChartData

      public ChartData()
      Instantiates a new chart data.
    • ChartData

      public ChartData(String timeframe, com.strategyquant.datalib.dataseries.TimeDataSeries time, DataSeries open, DataSeries high, DataSeries low, DataSeries close, DataSeries volume, com.strategyquant.datalib.dataseries.TimeDataSeries timeD, DataSeries openD, DataSeries highD, DataSeries lowD, DataSeries closeD, com.strategyquant.datalib.dataseries.TimeDataSeries timeW, DataSeries openW, DataSeries highW, DataSeries lowW, DataSeries closeW, com.strategyquant.datalib.dataseries.TimeDataSeries timeM, DataSeries openM, DataSeries highM, DataSeries lowM, DataSeries closeM)
      Instantiates a new chart data.
      Parameters:
      timeframe - the timeframe
      time - the time
      open - the open
      high - the high
      low - the low
      close - the close
      volume - the volume
      timeD - the time D
      openD - the open D
      highD - the high D
      lowD - the low D
      closeD - the close D
      timeW - the time W
      openW - the open W
      highW - the high W
      lowW - the low W
      closeW - the close W
      timeM - the time M
      openM - the open M
      highM - the high M
      lowM - the low M
      closeM - the close M
    • ChartData

      public ChartData(com.strategyquant.tradinglib.strategy.MarketData marketData, ChartDef chartDef, int serieIndex, int backtestEngine) throws Exception
      Instantiates a new chart data.
      Parameters:
      marketData - the market data
      chartDef - the chart def
      serieIndex - the serie index
      backtestEngine - the backtest engine
      Throws:
      Exception - the exception
  • Method Details

    • chartHashCode

      public int chartHashCode()
      Chart hash code.
      Returns:
      the int
    • TimeCurrent

      public long TimeCurrent() throws TradingException
      Time current.
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • Time

      public long Time(int shift) throws TradingException
      Time.
      Parameters:
      shift - the shift
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • Time

      public long Time() throws TradingException
      Time.
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • Time

      public long Time(int chartIndex, int shift) throws TradingException
      Time.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • TimeD

      public long TimeD(int shift) throws TradingException
      Time D.
      Parameters:
      shift - the shift
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • TimeW

      public long TimeW(int shift) throws TradingException
      Time W.
      Parameters:
      shift - the shift
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • TimeM

      public long TimeM(int shift) throws TradingException
      Time M.
      Parameters:
      shift - the shift
      Returns:
      the long
      Throws:
      TradingException - the trading exception
    • Ask

      public double Ask() throws TradingException
      Ask.
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Bid

      public double Bid() throws TradingException
      Bid.
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Open

      public double Open(int shift) throws TradingException
      Open.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Open

      public double Open(int chartIndex, int shift) throws TradingException
      Open.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenD

      public double OpenD(int shift) throws TradingException
      Open D.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenD

      public double OpenD(int chartIndex, int shift) throws TradingException
      Open D.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenW

      public double OpenW(int shift) throws TradingException
      Open W.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenW

      public double OpenW(int chartIndex, int shift) throws TradingException
      Open W.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenM

      public double OpenM(int shift) throws TradingException
      Open M.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • OpenM

      public double OpenM(int chartIndex, int shift) throws TradingException
      Open M.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Close

      public double Close(int shift) throws TradingException
      Close.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Close

      public double Close(int chartIndex, int shift) throws TradingException
      Close.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseD

      public double CloseD(int shift) throws TradingException
      Close D.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseD

      public double CloseD(int chartIndex, int shift) throws TradingException
      Close D.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseW

      public double CloseW(int shift) throws TradingException
      Close W.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseW

      public double CloseW(int chartIndex, int shift) throws TradingException
      Close W.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseM

      public double CloseM(int shift) throws TradingException
      Close M.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • CloseM

      public double CloseM(int chartIndex, int shift) throws TradingException
      Close M.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • High

      public double High(int shift) throws TradingException
      High.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • High

      public double High(int chartIndex, int shift) throws TradingException
      High.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighD

      public double HighD(int shift) throws TradingException
      High D.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighD

      public double HighD(int chartIndex, int shift) throws TradingException
      High D.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighW

      public double HighW(int shift) throws TradingException
      High W.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighW

      public double HighW(int chartIndex, int shift) throws TradingException
      High W.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighM

      public double HighM(int shift) throws TradingException
      High M.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • HighM

      public double HighM(int chartIndex, int shift) throws TradingException
      High M.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Low

      public double Low(int shift) throws TradingException
      Low.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Low

      public double Low(int chartIndex, int shift) throws TradingException
      Low.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowD

      public double LowD(int shift) throws TradingException
      Low D.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowD

      public double LowD(int chartIndex, int shift) throws TradingException
      Low D.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowW

      public double LowW(int shift) throws TradingException
      Low W.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowW

      public double LowW(int chartIndex, int shift) throws TradingException
      Low W.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowM

      public double LowM(int shift) throws TradingException
      Low M.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • LowM

      public double LowM(int chartIndex, int shift) throws TradingException
      Low M.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Volume

      public double Volume(int shift) throws TradingException
      Volume.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Openint

      public double Openint(int shift) throws TradingException
      Openint.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Volume

      public double Volume(int chartIndex, int shift) throws TradingException
      Volume.
      Parameters:
      chartIndex - the chart index
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Median

      public double Median(int shift) throws TradingException
      Median.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Typical

      public double Typical(int shift) throws TradingException
      Typical.
      Parameters:
      shift - the shift
      Returns:
      the double
      Throws:
      TradingException - the trading exception
    • Bars

      public int Bars()
      Bars.
      Returns:
      the int
    • Bars

      public int Bars(int chartIndex)
      Bars.
      Parameters:
      chartIndex - the chart index
      Returns:
      the int
    • getConnectionHash

      public int getConnectionHash()
      Gets the connection hash.
      Returns:
      the connection hash
    • getSymbolHash

      public int getSymbolHash()
      Gets the symbol hash.
      Returns:
      the symbol hash
    • getSymbol

      public String getSymbol()
      Gets the symbol.
      Returns:
      the symbol
    • setSymbol

      public void setSymbol(String symbol)
      Sets the symbol.
      Parameters:
      the - symbol
    • getConnectionName

      public String getConnectionName()
      Gets the connection name.
      Returns:
      the connection name
    • isUpdated

      public boolean isUpdated()
      returns true if this chart was updated in the recent tick.
      Returns:
      true, if is updated
    • processTick

      public void processTick(TickEvent tick, int eventTypeToProcess, int seriesCount) throws Exception
      there are always two calls of processTick() from MarketData for every tick: - first for BarClose event, and then for BarOpen event
      Parameters:
      tick - the tick
      eventTypeToProcess - the event type to process
      seriesCount - the series count
      Throws:
      Exception - the exception
    • findTickInData

      public void findTickInData(TickEvent tick, int eventTypeToProcess, boolean callCloseEvent, boolean updateData, int dataSerie) throws Exception
      Find tick in data.
      Parameters:
      tick - the tick
      eventTypeToProcess - the event type to process
      callCloseEvent - the call close event
      updateData - the update data
      dataSerie - the data serie
      Throws:
      Exception - the exception
    • isNextDay

      public boolean isNextDay(TickEvent tickEvent)
      Checks if is next day.
      Parameters:
      tickEvent - the tick event
      Returns:
      true, if is next day
    • findTickInDataComplete

      public void findTickInDataComplete(TickEvent tick, int eventTypeToProcess) throws Exception
      there are always two calls of processTick() from MarketData for every tick: - first for BarClose event, and then for BarOpen event
      Parameters:
      tick - the tick
      eventTypeToProcess - the event type to process
      Throws:
      Exception - the exception
    • processTickSimplified

      public void processTickSimplified(TickEvent tick, int seriesCount) throws Exception
      simplified tick processing for bars - used only in MarketData.requestHistoryData()
      Parameters:
      tick - the tick
      seriesCount - the series count
      Throws:
      Exception - the exception
    • getSeries

      public DataSeries getSeries(int serieType) throws TradingException
      Gets the series.
      Parameters:
      serieType - the serie type
      Returns:
      the series
      Throws:
      TradingException - the trading exception
    • getSeries

      public DataSeries getSeries(int serieType, int chartTF) throws TradingException
      Gets the series.
      Parameters:
      serieType - the serie type
      chartTF - the chart TF
      Returns:
      the series
      Throws:
      TradingException - the trading exception
    • destroy

      public void destroy()
      destroys all objects in this market data and frees offheap memory.
    • getInstrumentInfo

      public InstrumentInfo getInstrumentInfo()
      Gets the instrument info.
      Returns:
      the instrument info
    • setInstrumentInfo

      public void setInstrumentInfo(InstrumentInfo ii)
      Sets the instrument info.
      Parameters:
      ii - the InstrumentInfo
    • MinMove

      public double MinMove()
      Returns MinMove (Tradestation compatibility)
      Returns:
    • BigPointValue

      public double BigPointValue()
      Returns BigPointValue (Tradestation compatibility)
      Returns:
    • PriceScale

      public double PriceScale()
      Returns PriceScale (Tradestation compatibility)
      Returns:
    • getMinDistance

      public double getMinDistance()
      Gets the min distance.
      Returns:
      the min distance
    • resetPreparedDataShifts

      public void resetPreparedDataShifts()
      Reset prepared data shifts.
    • setPerformanceParams

      public void setPerformanceParams(boolean hasOnTickRule, boolean hasDailyDataBlock, boolean hasWeeklyDataBlock, boolean hasMonthlyDataBlock)
      Sets the performance params.
      Parameters:
      hasOnTickRule - the has on tick rule
      hasDailyDataBlock - the has daily data block
      hasWeeklyDataBlock - the has weekly data block
      hasMonthlyDataBlock - the has monthly data block
    • getCurrentBar

      public int getCurrentBar()
      Gets the current bar.
      Returns:
      the current bar
    • setCurrentBar

      public void setCurrentBar(int reservedBars, int userDefinedStartingBar)
      Sets the current bar.
      Parameters:
      reservedBars - the reserved bars
      userDefinedStartingBar - the user defined starting bar
    • getSerieIndex

      public int getSerieIndex()
      Gets the serie index.
      Returns:
      the serie index
    • cloneForTF

      public ChartData cloneForTF(int chartTF)
      Clone for TF.
      Parameters:
      chartTF - the chart TF
      Returns:
      the chart data
    • isNewBarOnMainSymbolTF

      public boolean isNewBarOnMainSymbolTF(TickEvent tick)
      returns true if current tick starts a new bar - means it is open of a new bar Reguired for realistic gaps handling in MT4.
      Parameters:
      tick - the tick
      Returns:
      true, if is new bar on main symbol TF
    • getIndyStartingBar

      public int getIndyStartingBar()
    • setIndyStartingBar

      public void setIndyStartingBar(int indyStartingBar)