#  Public and for release, CBEC v3.2.06 Build 4257+ [25th November, 2025]
#
#  Copyright(c) Ivyware Pty Ltd 2018-25  (all rights reserved)
#               MELBOURNE, VICTORIA, AUSTRALIA, 3000
#
#  This file is provided as-is by Ivyware Pty Ltd.  No claims are made
#  as to fitness for any particular purpose.  No warranties of any kind
#  are expressed or implied.  The recipient agrees to determine
#  applicability of information provided.
#
#  Ivyware hereby grants the right to freely use the information
#  supplied in this file for the creation of Python Advisor and Scanner
#  scripts supporting the Chartboard Application, and to make copies of
#  this file in any form for internal or external distribution as long as
#  this notice remains attached.
#
#  No waranty or suitability for purpose is implied.
#
#  Python Automation script that runs through the CBEC classes to both
#  demonstrate usage and perform simple consistency checks
#  NOTES: Only those charts active in chart will be processed through
#         to completion, disabled charts are ignored.
#         Download latest version from
#         https://www.ivyware.com.au/PythonScripts/TestPythonCBEC.pyw
#       : Download latest version of the Chartboard Extension Classes
#         (PythonCBEC.pyw) upon which this script is based from
#         https://www.ivyware.com.au/PythonScripts/PythonCBEC.pyw
#       : Requirement is for python 3.8 to be installed
#       : Based upon Chartboard Extension Classes (CBEC) shipped with
#         Chartboard product.
#       : Provides sample code for both querying and setting Chart Stack
#         parameters and calculated values. Doubles as a test script for
#         the duplex Chartboard-Python interface.
#       : Can be enhanced as circumstances dictate.  However, it should be
#         be renamed given each successive Chartboard update over-writes this
#         file.
#       : Activate the [Home > Windows Console] and the [OHLCvs >
#         Python Debug > Callbacks] or [PFigure > Python Debug > Callbacks]
#         for further development and monitoring implementation.
#    ***: Script under development and subject to change without notice***
#

import sys
sys.path.insert(0, 'C:\\Program Files\\Chartboard\\PythonScripts') # CBEC folder
from PythonCBEC import *
import ctypes  # An included library with Python install.   
from datetime import datetime
import os
from PYCB import PYCB_return
from PYCB import PYCB_error

#
#  Environment variables
#  NOTES: List of current environment variables suitable for debugging
print ( 'Python environment')
for param in os.environ.keys():
    print ( "%20s %s" % (param,os.environ[param]) )

#
#   Establish Root of which all other objects are descendants
#   NOTES: Effectively the Chartboard application itself
oCRoot = CRoot()
print ( 'CRoot Instance:' + str(oCRoot.Instance))
print ( 'CRoot sVersionCBEC:' + oCRoot.sVersionCBEC)
print ( 'CRoot sVersion:' + oCRoot.sVersion)
print ( 'CRoot nBuildCBEC:' + str(oCRoot.nBuildCBEC))
print ( 'CRoot nBuild:' + str(oCRoot.nBuild))
#
#   Establish CView
#   NOTES: CView is the parent of all charts, and is the actual tabbed view
#        : Switch to monthly view for display of trades, otherwise may Not be visable
print('CRoot,CViewFactory entry')
oCView = oCRoot.CViewFactory('This');
oCView.SetPUnits(PUNITS_Month)
print('CRoot,CViewFactory exit')
#
#   Create CStackOHLCvs object
#   NOTES: Effectively the View tab under which this python script is running
#          and identified by the 'CView' and 'this' tags
#        : Stack type MUST identify as 'CStackOHLCvs'
oCStack = oCView.CStackFactory();
if not oCStack.IsOHLCvs():
    assert 0, "Script only supports OHLCvs stacks, not " + oCStack.sType
    sys_exit(1)
oCStack.PaintEoD(1)                    # Activates visual updates
print ( 'CStack Period Units:' + oCStack.sPUnits)
print ( 'CStack Stock Code:' + oCStack.StockCode())
print ( oCStack)
print ( 'CStack Operative Time=' + str(oCStack.DATE()) )
print ( 'CStack Period Units=' + str(oCStack.nPUnits) )
PUnits = oCStack.nPUnits
#
#   Establish CStack object
#   NOTES: Effectively the View tab under which this python script is running
#          and identified by the 'this' tag
#        : Displaced by oCView_CStackFactory() in the above code
#oCStack = oCRoot.CStackFactory('CView','this');
#print ( 'CStack Period Units:' + oCStack.sPUnits)
#print ( 'CStack Stock Code:' + oCStack.StockCode())
#print ( oCStack)
#print ( 'CStack Operative Time=' + str(oCStack.DATE()) )
#print ( 'CStack Period Units=' + str(oCStack.nPUnits) )
#PUnits = oCStack.nPUnits
#
#   Aroon Chart test
if oCStack.ChartExists('Aroon'):
    print('####Found Aroon Chart')
    oChartAroon = oCStack.ChartFactory('Aroon')
    #
    # Testing DSeriesAroon
    oDSeriesAroon = oChartAroon.DSeriesFactory('Aroon')
    print('Aroonperiods='+str(oDSeriesAroon.iAroonperiods))
    print('GetValue_d AroonHi='+str(oDSeriesAroon.GetValue_d("AroonHi",0,0)))
    print('GetValue_d AroonLo='+str(oDSeriesAroon.GetValue_d("AroonLo",0,0)))
    print('GetValue_d AroonDiff='+str(oDSeriesAroon.GetValue_d("AroonDiff",0,0)))
#
#   ADX Chart test - Average Directional Index
if oCStack.ChartExists('ADX'):
    print('####Found ADX Chart')
    oChartADX = oCStack.ChartFactory('ADX')
    #
    # Testing DSeriesADX
    oDSeriesADX = oChartADX.DSeriesFactory('ADX')
    print('ADXperiods='+str(oDSeriesADX.iADXperiods))
    print('ADX='+str(oDSeriesADX.GetValue_d("ADX",0,0)))
    print('DIplus='+str(oDSeriesADX.GetValue_d("DIplus",0,0)))
    print('DIminus='+str(oDSeriesADX.GetValue_d("DIminus",0,0)))
#
#   ATR Chart test - Average True Range
if oCStack.ChartExists('ATR'):
    print('####Found ATR Chart')
    oChartATR = oCStack.ChartFactory('ATR')
    #
    # Testing DSeriesATR
    oDSeriesATR = oChartATR.DSeriesFactory('ATR')
    print('ATRperiods='+str(oDSeriesATR.iATRperiods))
    print('ATR='+str(oDSeriesATR.GetValue_d("ATR",0,0)))
    print('TR='+str(oDSeriesATR.GetValue_d("TR",0,0)))
#
#   CCI Chart test - Commodity Channel Index
if oCStack.ChartExists('CCI'):
    print('####Found CCI Chart')
    oChartCCI = oCStack.ChartFactory('CCI')
    #
    # Testing DSeriesCCI
    oDSeriesCCI = oChartCCI.DSeriesFactory('CCI')
    print('CCIperiods='+str(oDSeriesCCI.iCCIperiods))
    print('CCI='+str(oDSeriesCCI.GetValue_d("CCI",0,0)))
#
#   Chaikin Chart test - Chaikin Oscillator
if oCStack.ChartExists('Chaikin'):
    print('####Found Chaikin Chart')
    oChartChaikin = oCStack.ChartFactory('Chaikin')
    #
    # Testing DSeriesChaikin
    oDSeriesChaikin = oChartChaikin.DSeriesFactory('Chaikin')
    print('FASTperiods='+str(oDSeriesChaikin.iFASTperiods))
    print('SLOWperiods='+str(oDSeriesChaikin.iSLOWperiods))
    print('Chaikin='+str(oDSeriesChaikin.GetValue_d("Chaikin",0,0)))
#
#   CMF Chart test - Chaikin Money Flow
if oCStack.ChartExists('CMF'):
    print('####Found CMF Chart')
    oChartCMF = oCStack.ChartFactory('CMF')
    #
    # Testing DSeriesCMF
    oDSeriesCMF = oChartCMF.DSeriesFactory('CMF')
    print('CMFperiods='+str(oDSeriesCMF.iCMFperiods))
#
#   Coppock Chart test - Coppock Indicator
if oCStack.ChartExists('Coppock'):
    print('####Found Coppock Chart')
    oChartCoppock = oCStack.ChartFactory('Coppock')
    #
    # Testing DSeriesCoppock
    oDSeriesCoppock = oChartCoppock.DSeriesFactory('Coppock')
    print('ROCAperiods='+str(oDSeriesCoppock.iROCAperiods))
    print('ROCBperiods='+str(oDSeriesCoppock.iROCBperiods))
    print('WMAperiods='+str(oDSeriesCoppock.iROCAperiods))
    print('Coppock='+str(oDSeriesCoppock.GetValue_d('Coppock',PUNITS_Day,0)) )
#
#   DPO Chart test - Detrended Price Oscillator
if oCStack.ChartExists('DPO'):
    print('####Found DPO Chart')
    oChartDPO = oCStack.ChartFactory('DPO')
    #
    # Testing DSeriesDPO
    oDSeriesDPO = oChartDPO.DSeriesFactory('DPO')
    print('DPOperiods='+str(oDSeriesDPO.iDPOperiods))
    print('DPO='+str(oDSeriesDPO.GetValue_d("DPO",0,0)))
#
#   EFI Chart test - Elder Ray
if oCStack.ChartExists('EFI'):
    print('####Found EFI Chart')
    oChartEFI = oCStack.ChartFactory('EFI')
    #
    # Testing DSeriesEFI
    oDSeriesEFI = oChartEFI.DSeriesFactory('EFI')
    print('EFIperiods='+str(oDSeriesEFI.iEFIperiods))
    print('EFI='+str(oDSeriesEFI.GetValue_d("EFI",0,0)))
#
#   EhlerFT Chart test - Ehler Fisher Transform
if oCStack.ChartExists('EhlerFT'):
    print('####Found EhlerFT Chart')
    oChartEhlerFT = oCStack.ChartFactory('EhlerFT')
    #
    # Testing DSeriesEhlerFT
    oDSeriesEhlerFT = oChartEhlerFT.DSeriesFactory('EhlerFT')
    print('EhlerFTperiods='+str(oDSeriesEhlerFT.iEhlerFTperiods))
    print('EhlerFT='+str(oDSeriesEhlerFT.GetValue_d("EhlerFT",0,0)))
    print('EhlerFTsignal='+str(oDSeriesEhlerFT.GetValue_d("EhlerFTsignal",0,0)))
    print('BoS(Buy or Sell)='+str(oDSeriesEhlerFT.GetValue_i("BoS",0,0)))
    print('BoS(Buy or Sell age)='+str(oDSeriesEhlerFT.GetValue_i("BoSage",0,0)))
#
#   KST Chart test - Pring's Know Sure Thing
if oCStack.ChartExists('KST'):
    print('####Found KST Chart')
    oChartKST = oCStack.ChartFactory('KST')
    #
    # Testing DSeriesKST
    oDSeriesKST = oChartKST.DSeriesFactory('KST')
    print('ROC1periods='+str(oDSeriesKST.iROC1periods))
    print('ROC2periods='+str(oDSeriesKST.iROC2periods))
    print('ROC3periods='+str(oDSeriesKST.iROC3periods))
    print('ROC4periods='+str(oDSeriesKST.iROC4periods))
    print('SMA1periods='+str(oDSeriesKST.iSMA1periods))
    print('SMA2periods='+str(oDSeriesKST.iSMA2periods))
    print('SMA3periods='+str(oDSeriesKST.iSMA3periods))
    print('SMA4periods='+str(oDSeriesKST.iSMA4periods))
    print('Signalperiods='+str(oDSeriesKST.iSignalperiods))
    print('KST='+str(oDSeriesKST.GetValue_d("KST",0,0)))
    print('KSTsignal='+str(oDSeriesKST.GetValue_d("KSTsignal",0,0)))
    print('BoS(Buy or Sell)='+str(oDSeriesKST.GetValue_i("BoS",0,0)))
    print('BoS(Buy or Sell age)='+str(oDSeriesKST.GetValue_i("BoSage",0,0)))
#
#   MACD Chart test - Moving Average Cummulative Distribution
if oCStack.ChartExists('MACD'):
    print('####Found MACD Chart')
    oChartMACD = oCStack.ChartFactory('MACD')
    #
    # Testing DSeriesMACD
    oDSeriesMACD = oChartMACD.DSeriesFactory('MACD')
    print('EMA1periods='+str(oDSeriesMACD.iEMA1periods))
    print('EMA2periods='+str(oDSeriesMACD.iEMA2periods))
    print('SignalPeriods='+str(oDSeriesMACD.iSignalperiods))
    print('MACD='+str(oDSeriesMACD.GetValue_d("MACD",0,0)))
    print('MACDsignal='+str(oDSeriesMACD.GetValue_d("MACDsignal",0,0)))
    print('MACDiff='+str(oDSeriesMACD.GetValue_d("MACDiff",0,0)))
    print('BoS value='+str(oDSeriesMACD.GetValue_i('BoS',PUNITS_Month,0)) )
    print('BoSage value='+str(oDSeriesMACD.GetValue_i('BoSage',PUNITS_Month,0)) )
#
#   MFI Chart test - Money Flow Index
if oCStack.ChartExists('MFI'):
    print('####Found MFI Chart')
    oChartMFI = oCStack.ChartFactory('MFI')
    #
    # Testing DSeriesMFI
    oDSeriesMFI = oChartMFI.DSeriesFactory('MFI')
    print('MFIperiods='+str(oDSeriesMFI.iMFIperiods))
    print('OBought='+str(oDSeriesMFI.iOBought))
    print('OSold='+str(oDSeriesMFI.iOSold))
    print('MFI='+str(oDSeriesMFI.GetValue_d("MFI",0,0)))
#
#   MSA Chart test - Momentum Structural Analysis
if oCStack.ChartExists('MSA'):
    print('####Found MSA Chart')
    oChartMSA = oCStack.ChartFactory('MSA')
    #
    # Testing DSeriesMSA
    oDSeriesMSA = oChartMSA.DSeriesFactory('MSA')
    print('MSAperiods='+str(oDSeriesMSA.iMSAperiods))
    print('PC='+str(oDSeriesMSA.GetValue_d("PC",0,0)))
    print('PD='+str(oDSeriesMSA.GetValue_d("PD",0,0)))
    print('PBage value='+str(oDSeriesMSA.GetValue_i('PBage',PUNITS_Month,0)) )
#
#   OBV Chart test - Commodity Channel Index
if oCStack.ChartExists('OBV'):
    print('####Found OBV Chart')
    oChartOBV = oCStack.ChartFactory('OBV')
    #
    # Testing DSeriesOBV
    oDSeriesOBV = oChartOBV.DSeriesFactory('OBV')
#
#   PBars Chart test - Price variation bars
if oCStack.ChartExists('PBars'):
    print('####Found PBars Chart')
    oChartPBars = oCStack.ChartFactory('PBars')
    #
    # Testing DSeriesPBars
    oDSeriesPBars = oChartPBars.DSeriesFactory('PBars')
    print('Value Price Difference='+str( oDSeriesPBars.GetValue_d('PD',PUNITS_Day,0) ) )
    print('Value Percent='+str( oDSeriesPBars.GetValue_d('PC',PUNITS_Day,0) ) )
    print('Value PBar age='+str( oDSeriesPBars.GetValue_i('PBage',PUNITS_Day,0) ) )
#
#   PMO Chart test - Price Momentum Oscillator
if oCStack.ChartExists('PMO'):
    print('####Found PMO Chart')
    oChartPMO = oCStack.ChartFactory('PMO')
    #
    # Testing DSeriesPMO
    oDSeriesPMO = oChartPMO.DSeriesFactory('PMO')
    print('PMO1periods='+str(oDSeriesPMO.iPMO1periods))
    print('PMO2periods='+str(oDSeriesPMO.iPMO2periods))
    print('EMAperiods='+str(oDSeriesPMO.iEMAperiods))
    print('PMO='+str(oDSeriesPMO.GetValue_d("PMO",0,0)))
    print('PMOema='+str(oDSeriesPMO.GetValue_d("PMOema",0,0)))
#
#   PPO Chart test - Percentage Price Oscillator
if oCStack.ChartExists('PPO'):
    print('####Found PPO Chart')
    oChartPPO = oCStack.ChartFactory('PPO')
    #
    # Testing DSeriesPPO
    oDSeriesPPO = oChartPPO.DSeriesFactory('PPO')
    print('EMA1periods='+str(oDSeriesPPO.iEMA1periods))
    print('EMA2periods='+str(oDSeriesPPO.iEMA2periods))
    print('SignalPeriods='+str(oDSeriesPPO.iSignalperiods))
    print('PPO='+str(oDSeriesPPO.GetValue_d("PPO",0,0)))
    print('PPOsignal='+str(oDSeriesPPO.GetValue_d("PPOsignal",0,0)))
    print('PPOdiff='+str(oDSeriesPPO.GetValue_d("PPOdiff",0,0)))
    print('BoS value='+str(oDSeriesPPO.GetValue_i('BoS',PUNITS_Month,0)) )
    print('BoSage value='+str(oDSeriesPPO.GetValue_i('BoSage',PUNITS_Month,0)) )
#
#   PVO Chart test - Percentage Volume Oscillator
if oCStack.ChartExists('PVO'):
    print('####Found PVO Chart')
    oChartPVO = oCStack.ChartFactory('PVO')
    #
    # Testing DSeriesPVO
    oDSeriesPVO = oChartPVO.DSeriesFactory('PVO')
    print('Param HIperiods='+str(oDSeriesPVO.iHIperiods))
    print('Param LOperiods='+str(oDSeriesPVO.iLOperiods))
    print('Param PVO periods='+str(oDSeriesPVO.iPVOperiods))
    print('Value PVO='+str(oDSeriesPVO.GetValue_d("PVO",0,0)))
    print('Value PVOsignal='+str(oDSeriesPVO.GetValue_d("PVOsignal",0,0)))
#
#   ROC Chart test - Rate of Change
if oCStack.ChartExists('ROC'):
    print('####Found ROC Chart')
    oChartROC = oCStack.ChartFactory('ROC')
    #
    # Testing DSeriesROC
    oDSeriesROC = oChartROC.DSeriesFactory('ROC')
    print('ROCperiods='+str(oDSeriesROC.iROCperiods))
    print('ROC value='+str(oDSeriesROC.GetValue_d("ROC",0,0)))
#
#   RSI Chart test - Relative Strength Index
if oCStack.ChartExists('RSI'):
    print('####Found RSI Chart')
    oChartRSI = oCStack.ChartFactory('RSI')
    #
    # Testing DSeriesRSI
    oDSeriesRSI = oChartRSI.DSeriesFactory('RSI')
    print('RSIperiods='+str(oDSeriesRSI.iRSIperiods))
    print('OBought='+str(oDSeriesRSI.iOBought))
    print('OSold='+str(oDSeriesRSI.iOSold))
    print('RSI value='+str(oDSeriesRSI.GetValue_d("RSI",0,0)))
#
#   SLOPE Chart test - Linear Regression Oscillator (SLOPE)
if oCStack.ChartExists('SLOPE'):
    print('####Found SLOPE Chart')
    oChartSLOPE = oCStack.ChartFactory('SLOPE')
    #
    # Testing DSLOPE
    oDSeriesSLOPE = oChartSLOPE.DSeriesFactory('SLOPE')
    print('PeriodsLINEAR='+str(oDSeriesSLOPE.GetValue_i("PeriodsLINEAR")) )
    print('PeriodsPOLY2='+str(oDSeriesSLOPE.GetValue_i("PeriodsPOLY2")) )
    print('PeriodsSAVITZKY='+str(oDSeriesSLOPE.GetValue_i("PeriodsSAVITZKY")) )
    print('SmoothPeriods='+str(oDSeriesSLOPE.GetValue_i("SmoothPeriods")) )
    print('SmoothEoD='+str(oDSeriesSLOPE.GetValue_i("SmoothEoD")) )
    print('SLOPE value='+str(oDSeriesSLOPE.GetValue_d("SLOPE",0,0)) )
    print('SLOPEs value='+str(oDSeriesSLOPE.GetValue_d("SLOPEs",0,0)) )
    print('BoS value='+str(oDSeriesSLOPE.GetValue_i('BoS',PUNITS_Month,0)) )
    print('BoSage value='+str(oDSeriesSLOPE.GetValue_i('BoSage',PUNITS_Month,0)) )
#
#   StochRSI Chart test - Stochastic Relative Strength Index
if oCStack.ChartExists('StochRSI'):
    print('####Found StochRSI Chart')
    oChartStochRSI = oCStack.ChartFactory('StochRSI')
    #
    # Testing DSeriesStochRSI
    oDSeriesStochRSI = oChartStochRSI.DSeriesFactory('StochRSI')
    print('StochRSIperiods='+str(oDSeriesStochRSI.iStochRSIperiods))
    print('OBought='+str(oDSeriesStochRSI.dOBought))
    print('OSold='+str(oDSeriesStochRSI.dOSold))
    print('StochRSI value='+str(oDSeriesStochRSI.GetValue_d("StochRSI",0,0)))
#
#   STDEV Chart test - Volatility or Standard Deviation
if oCStack.ChartExists('STDEV'):
    print('####Found STDEV Chart')
    oChartSTDEV = oCStack.ChartFactory('STDEV')
    #
    # Testing DSeriesSTDEV
    oDSeriesSTDEV = oChartSTDEV.DSeriesFactory('STDEV')
    print('STDEVperiods='+str(oDSeriesSTDEV.iSTDEVperiods))
#
#   STO Chart test - Stochastics, Fast, Slow or Full
if oCStack.ChartExists('STO'):
    print('####Found STO Chart')
    oChartSTO = oCStack.ChartFactory('STO')
    #
    # Testing DSeriesSTO
    oDSeriesSTO = oChartSTO.DSeriesFactory('STO')
    print('Kperiods='+str(oDSeriesSTO.iKperiods))
    print('Dperiods='+str(oDSeriesSTO.iDperiods))
    print('Xperiods='+str(oDSeriesSTO.iXperiods))
#
#   Shorts Chart test - Shorts indicator
if oCStack.ChartExists('Shorts'):
    print('####Found Shorts Chart')
    oChartShorts = oCStack.ChartFactory('Shorts')
    #
    # Testing DSeriesShorts
    oDSeriesShorts = oChartShorts.DSeriesFactory('Shorts')
    print('Value Shorts='+str(oDSeriesShorts.GetValue_d("Shorts",0,0)))
    print('Value PoT='+str(oDSeriesShorts.GetValue_d('PoT',PUNITS_Month,0)) )
    print('Value Delta='+str(oDSeriesShorts.GetValue_d('Delta',PUNITS_Month,0)) )
#
#   TRIX Chart test - Triple Smoothed Exponential Moveing Average
if oCStack.ChartExists('TRIX'):
    print('####Found TRIX Chart')
    oChartTRIX = oCStack.ChartFactory('TRIX')
    #
    # Testing DSeriesTRIX
    oDSeriesTRIX = oChartTRIX.DSeriesFactory('TRIX')
    print('EMAperiods='+str(oDSeriesTRIX.iEMAperiods))
    print('Signalperiods='+str(oDSeriesTRIX.iSignalperiods))
    print('Value TRIX='+str(oDSeriesTRIX.GetValue_d("TRIX",0,0)))
    print('Value TRIXsignal='+str(oDSeriesTRIX.GetValue_d("TRIXsignal",0,0)))
    print('Value BoS value='+str(oDSeriesTRIX.GetValue_i('BoS',PUNITS_Month,0)) )
    print('Value BoSage value='+str(oDSeriesTRIX.GetValue_i('BoSage',PUNITS_Month,0)) )
#
#   TSI Chart test - True Strength Index
if oCStack.ChartExists('TSI'):
    print('####Found TSI Chart')
    oChartTSI = oCStack.ChartFactory('TSI')
    #
    # Testing DSeriesTSI
    oDSeriesTSI = oChartTSI.DSeriesFactory('TSI')
    print('PC1periods='+str(oDSeriesTSI.iPC1periods))
    print('PC2periods='+str(oDSeriesTSI.iPC2periods))
    print('Signalperiods='+str(oDSeriesTSI.iSignalperiods))
    print('TSI='+str(oDSeriesTSI.GetValue_d("TSI",0,0)))
    print('TSIsignal='+str(oDSeriesTSI.GetValue_d("TSIsignal",0,0)))
    print('BoS value='+str(oDSeriesTSI.GetValue_i('BoS',PUNITS_Month,0)) )
    print('BoSage value='+str(oDSeriesTSI.GetValue_i('BoSage',PUNITS_Month,0)) )
#
#   VTX Chart test - VORTEX Indicator
if oCStack.ChartExists('VTX'):
    print('####Found VTX or VORTEX Chart')
    oChartVTX = oCStack.ChartFactory('VTX')
    #
    # Testing DSeriesVTX
    oDSeriesVTX = oChartVTX.DSeriesFactory('VTX')
    print('VTXperiods='+str(oDSeriesVTX.iVTXperiods))
#
#   Volume Chart test - Volume indicator
if oCStack.ChartExists('Volume'):
    print('####Found Volume Chart')
    oChartVolume = oCStack.ChartFactory('Volume')
    #
    # Testing DSeriesVolume
    oDSeriesVolume = oChartVolume.DSeriesFactory('Volume')
#
#   WmR Chart test - Williams %R
if oCStack.ChartExists('WmR'):
    print('####Found WmR Chart')
    oChartWmR = oCStack.ChartFactory('WmR')
    #
    # Testing DSeriesWmR
    oDSeriesWmR = oChartWmR.DSeriesFactory('WmR')
    print('WmRperiods='+str(oDSeriesWmR.iWmRperiods))

###################################
#
#   OHLC Chart Test - Open, High, Low, Close and Volume
if oCStack.ChartExists('OHLCvs'):
    print('####Found OHLCvs Chart')
    oChartOHLC = oCStack.ChartFactory('OHLCvs')
    oChartOHLC.PYCB_ShadeBarUpdate(PUNITS_Month,0,0,11)
    oChartOHLC.PYCB_ShadeBarSelect(PUNITS_Month,0,0)
    #
    # Testing DSeriesBB
    if oChartOHLC.DSeriesExists('BB'):
        print('----Found BB Overlay')
        oDSeriesBB = oChartOHLC.DSeriesFactory('BB')
        print('Kvalue='+str(oDSeriesBB.dKvalue) )
        print('SMAperiods='+str(oDSeriesBB.iSMAperiods) )
        print('BB+ value='+str(oDSeriesBB.GetValue_d('BB+',PUNITS_Week,0) ) )
        print('BBsma value='+str(oDSeriesBB.GetValue_d('BBsma',PUNITS_Week,0) ) )
        print('BB- value='+str(oDSeriesBB.GetValue_d('BB-',PUNITS_Week,0) ) )
    #
    #   Testing DSeriesChandelier overlay
    if oChartOHLC.DSeriesExists('Chandelier'):
        print('----Found Chandelier Overlay')
        oDSeriesChandelier = oChartOHLC.DSeriesFactory('Chandelier')
        print('Param SHORTperiods='+str(oDSeriesChandelier.iSHORTperiods) )
        print('Param LONGperiods='+str(oDSeriesChandelier.iLONGperiods) )
        print('Param SHORTmultATR='+str(oDSeriesChandelier.dSHORTmultATR) )
        print('Param LONGmultATR='+str(oDSeriesChandelier.dLONGmultATR) )
        print('Value SHORT='+str(oDSeriesChandelier.GetValue_d('SHORT',PUNITS_Week,0) ) )
        print('Value LONG='+str(oDSeriesChandelier.GetValue_d('LONG',PUNITS_Week,0) ) )
    #
    # Testing DSeriesKAMA
    if oChartOHLC.DSeriesExists('KAMA'):
        print('----Found KAMA Overlay')
        oDSeriesKAMA = oChartOHLC.DSeriesFactory('KAMA')
        print('Param ERperiods='+str(oDSeriesKAMA.iERperiods) )
        print('Param FASTperiods='+str(oDSeriesKAMA.iFASTperiods) )
        print('Param SLOWperiods='+str(oDSeriesKAMA.iSLOWperiods) )
        print('Value KAMA='+str(oDSeriesKAMA.GetValue_d('KAMA',PUNITS_Week,0) ) )
   #
    # Testing DSeriesSAR
    if oChartOHLC.DSeriesExists('SAR'):
        print('----Found SAR Overlay')
        oDSeriesSAR = oChartOHLC.DSeriesFactory('SAR')
        print('AF='+str(oDSeriesSAR.dAF) )
        print('AFmax='+str(oDSeriesSAR.dAFmax) )
        print('SAR value='+str(oDSeriesSAR.GetValue_d('SAR',PUNITS_Week,0) ) )
        print('SARv value='+str(oDSeriesSAR.GetValue_d('SARv',PUNITS_Week,0) ) )
        print('SARa value='+str(oDSeriesSAR.GetValue_d('SARa',PUNITS_Week,0) ) )
        print('AoB value='+str(oDSeriesSAR.GetValue_i('AoB',PUNITS_Week,0) ) )
    #
    # Testing DSeriesReversals
    if oChartOHLC.DSeriesExists('Reversals-A'):
        print('----Found Reversals-A Overlay')
        oDSeriesReversalsA = oChartOHLC.DSeriesFactory('Reversals-A')
        print('Age='+str(oDSeriesReversalsA.GetValue_i('Age',PUNITS_Day,0)) )
    if oChartOHLC.DSeriesExists('Reversals-B'):
        print('----Found Reversals-B Overlay')
        oDSeriesReversalsB = oChartOHLC.DSeriesFactory('Reversals-B')
        print('Age='+str(oDSeriesReversalsB.GetValue_i('Age',PUNITS_Day,0)) )
    if oChartOHLC.DSeriesExists('Reversals-C'):
        print('----Found Reversals-C Overlay')
        oDSeriesReversalsC = oChartOHLC.DSeriesFactory('Reversals-C')
        print('Age='+str(oDSeriesReversalsC.GetValue_i('Age',PUNITS_Day,0)) )
    #
    # Testing DSeriesHarmonics
    if oChartOHLC.DSeriesExists('Harmonics-A'):
        print('----Found Harmonics-A Overlay')
        oDSeriesHarmonicsA = oChartOHLC.DSeriesFactory('Harmonics-A')
        print('HPTypesMask='+str(oDSeriesHarmonicsA.iHPTypesMask) )
        print('ZigZagXApc='+str(oDSeriesHarmonicsA.dZigZagXApc) )
    if oChartOHLC.DSeriesExists('Harmonics-B'):
        print('----Found Harmonics-B Overlay')
        oDSeriesHarmonicsB = oChartOHLC.DSeriesFactory('Harmonics-B')
        print('HPTypesMask='+str(oDSeriesHarmonicsB.iHPTypesMask) )
        print('ZigZagXApc='+str(oDSeriesHarmonicsB.dZigZagXApc) )
    if oChartOHLC.DSeriesExists('Harmonics-C'):
        print('----Found Harmonics-C Overlay')
        oDSeriesHarmonicsB = oChartOHLC.DSeriesFactory('Harmonics-C')
        print('HPTypesMask='+str(oDSeriesHarmonicsC.iHPTypesMask) )
        print('ZigZagXApc='+str(oDSeriesHarmonicsC.dZigZagXApc) )
    #
    # Testing DSeriesKeltner
    if oChartOHLC.DSeriesExists('Keltner'):
        print('----Found Keltner Overlay')
        oDSeriesKeltner = oChartOHLC.DSeriesFactory('Keltner')
        print('Param EMAperiods='+str(oDSeriesKeltner.iEMAperiods) )
        print('Param ATRperiods='+str(oDSeriesKeltner.iATRperiods) )
        print('Param ATRoffset='+str(oDSeriesKeltner.dATRoffset) )
        print('Value KeltnerHi='+str(oDSeriesKeltner.GetValue_d('KeltnerHi',PUNITS_Week,0) ) )
        print('Value KeltnerLo='+str(oDSeriesKeltner.GetValue_d('KeltnerLo',PUNITS_Week,0) ) )
    #
    # Testing DSeriesIchimoku
    if oChartOHLC.DSeriesExists('Ichimoku'):
        print('----Found Ichimoku Overlay')
        oDSeriesIchimoku = oChartOHLC.DSeriesFactory('Ichimoku')
        print('Tenkanperiods='+str(oDSeriesIchimoku.iTenkanperiods) )
        print('Kijunperiods='+str(oDSeriesIchimoku.iKijunperiods) )
        print('Senkouperiods='+str(oDSeriesIchimoku.iSenkouperiods) )
        print('Chikouperiods='+str(oDSeriesIchimoku.iChikouperiods) )
        print('TenkanSen value='+str(oDSeriesIchimoku.GetValue_d('TenkanSen',PUNITS_Week,0) ) )
        print('KijunSen value='+str(oDSeriesIchimoku.GetValue_d('KijunSen',PUNITS_Week,0) ) )
        print('Chikou value='+str(oDSeriesIchimoku.GetValue_d('Chikou',PUNITS_Week,0) ) )
        print('SenkouA value='+str(oDSeriesIchimoku.GetValue_d('SenkouA',PUNITS_Week,0) ) )
        print('SenkouB value='+str(oDSeriesIchimoku.GetValue_d('SenkouB',PUNITS_Week,0) ) )
    #
    # Testing DSeriesMAMA
    if oChartOHLC.DSeriesExists('MAMA'):
        print('----Found MAMA Overlay')
        oDSeriesMAMA = oChartOHLC.DSeriesFactory('MAMA')
        print('FastLimit='+str(oDSeriesMAMA.dFastLimit) )
        print('SlowLimit='+str(oDSeriesMAMA.dSlowLimit) )
        print('BoS value='+str(oDSeriesMAMA.GetValue_i('BoS',PUNITS_Day,0)) )
        print('BoSage value='+str(oDSeriesMAMA.GetValue_i('BoSage',PUNITS_Day,0)) )
    #
    # Testing DSeriesDonchian
    if oChartOHLC.DSeriesExists('PChan'):
        print('----Found PChan Overlay')
        oDSeriesDonchian = oChartOHLC.DSeriesFactory('PChan')
        print('DCperiods='+str(oDSeriesDonchian.iPCperiods) )
        print('DChi='+str(oDSeriesDonchian.GetValue_d('PChi',PUNITS_Day,0)) )
        print('DC='+str(oDSeriesDonchian.GetValue_d('PC',PUNITS_Day,0)) )
        print('DClo='+str(oDSeriesDonchian.GetValue_d('PClo',PUNITS_Day,0)) )
    #
    # Testing DSeriesOHLC
    if oChartOHLC.DSeriesExists('OHLCvs'):
        print('----Found OHLCvs Overlay')
        oDSeriesOHLC = oChartOHLC.DSeriesFactory('OHLCvs')
        print('GetValue_d Open='+str(oDSeriesOHLC.GetValue_d('Open',PUNITS_Day,0)) )
        print('GetValue_d High='+str(oDSeriesOHLC.GetValue_d('High',PUNITS_Day,0)) )
        print('GetValue_d Low='+str(oDSeriesOHLC.GetValue_d('Low',PUNITS_Day,0)) )
        print('GetValue_d Close='+str(oDSeriesOHLC.GetValue_d('Close',PUNITS_Day,0)) )
        print('GetValue_d Volume='+str(oDSeriesOHLC.GetValue_d('Volume',PUNITS_Day,0)) )
        print('GetValue_d Shorts='+str(oDSeriesOHLC.GetValue_d('Shorts',PUNITS_Day,0)) )
        print('GetValue_d ShortsPoT='+str(oDSeriesOHLC.GetValue_d('ShortsPoT',PUNITS_Day,0)) )
        print('GetValue_d DATE-COleDateTime='+str(oDSeriesOHLC.GetValue_d('DATE',PUNITS_Day,0)) )
        print('GetValue_d DATE-datetime='+str(oDSeriesOHLC.GetValue_dt('DATE',PUNITS_Day,0)) )
    #
    # Testing DSeriesSMAnnn
    if oChartOHLC.DSeriesExists('SMA020d'):
        print('----Found SMA020d Overlay')
        oDSeriesSMA020d = oChartOHLC.DSeriesFactory('SMA020d')
        print('GetParam_i SMAperiods='+str(oDSeriesSMA020d.iSMAperiods) )
        print('GetValue_d SMAvalue='+str(oDSeriesSMA020d.GetValue_d('SMA',PUNITS_Day,0)) )
    else:
        print('----Create SMA030d Overlay')
        oDSeriesSMA030d = oChartOHLC.DSeriesSMAnnnFactory(30,5)
        print('GetParam_i PUnits='+str(oDSeriesSMA030d.GetParam_i('PUnits')) )
        print('GetParam_i SMAperiods='+str(oDSeriesSMA030d.GetParam_i('SMAPeriods')) )
        print('GetValue_d SMAvalue='+str(oDSeriesSMA030d.GetValue_d('SMA',PUNITS_Day,0)) )
    #
    # Testing DSeriesEMAnnn
    if oChartOHLC.DSeriesExists('EMA020d'):
        print('----Found EMA020d Overlay')
        oDSeriesEMA020d = oChartOHLC.DSeriesFactory('EMA020d')
        print('GetParam_i EMAperiods='+str(oDSeriesEMA020d.iEMAperiods) )
        print('GetValue_d EMAvalue='+str(oDSeriesEMA020d.GetValue_d('EMA',PUNITS_Day,0)) )
    else:
        print('----Create EMA030d Overlay')
        oDSeriesEMA030d = oChartOHLC.DSeriesEMAnnnFactory(30,5)
        print('GetParam_i PUnits='+str(oDSeriesEMA030d.GetParam_i('PUnits')) )
        print('GetParam_i EMAperiods='+str(oDSeriesEMA030d.GetParam_i('EMAPeriods')) )
        print('GetValue_d EMAvalue='+str(oDSeriesEMA030d.GetValue_d('EMA',PUNITS_Day,0)) )
    #
    # Testing DSeriesZigZag
    if oChartOHLC.DSeriesExists('ZigZag'):
        print('----Found ZigZag Overlay')
        oDSeriesZigZag = oChartOHLC.DSeriesFactory('ZigZag')
        print('Percent value='+str(oDSeriesZigZag.dPercent) )
        print('ZigZag value='+str(oDSeriesZigZag.GetValue_d('ZigZag',PUNITS_Day,0)) )
        print('MoM value='+str(oDSeriesZigZag.GetValue_i('MoM',PUNITS_Day,0)) )
        print('MoMage value='+str(oDSeriesZigZag.GetValue_i('MoMage',PUNITS_Day,0)) )
    #
    # Testing DSeriesTDMA
    if oChartOHLC.DSeriesExists('TDMAI-A'):
        print('----Found TDMAI-A Overlay')
        oDSeriesTDMAIA = oChartOHLC.DSeriesFactory('TDMAI-A')
        print('Param LBperiodsI='+str(oDSeriesTDMAIA.iLBperiodsI) )
        print('Param AveragePeriodsI='+str(oDSeriesTDMAIA.iAveragePeriodsI) )
        print('Param ExtentPeriodsI='+str(oDSeriesTDMAIA.iExtendPeriodsI) )
        print('Value MABull='+str(oDSeriesTDMAIA.GetValue_d('MABull',PUNITS_Week,0) ) )
        print('Value MABear='+str(oDSeriesTDMAIA.GetValue_d('MABear',PUNITS_Week,0) ) )
    if oChartOHLC.DSeriesExists('TDMAI-B'):
        print('----Found TDMAI-B Overlay')
        oDSeriesTDMAIB = oChartOHLC.DSeriesFactory('TDMAI-B')
        print('Param LBperiodsI='+str(oDSeriesTDMAIB.iLBperiodsI) )
        print('Param AveragePeriodsI='+str(oDSeriesTDMAIB.iAveragePeriodsI) )
        print('Param ExtendPeriodsI='+str(oDSeriesTDMAIB.iExtendPeriodsI) )
        print('Value MABull='+str(oDSeriesTDMAIB.GetValue_d('MABull',PUNITS_Week,0) ) )
        print('Value MABear='+str(oDSeriesTDMAIB.GetValue_d('MABear',PUNITS_Week,0) ) )
    if oChartOHLC.DSeriesExists('TDMAI-C'):
        print('----Found TDMAI-C Overlay')
        oDSeriesTDMAIC = oChartOHLC.DSeriesFactory('TDMAI-C')
        print('Param LBperiodsI='+str(oDSeriesTDMAIC.iLBperiodsI) )
        print('Param AveragePeriodsI='+str(oDSeriesTDMAIC.iAveragePeriodsI) )
        print('Param ExtentPeriodsI='+str(oDSeriesTDMAIC.iExtendPeriodsI) )
        print('Value MABull='+str(oDSeriesTDMAIC.GetValue_d('MABull',PUNITS_Week,0) ) )
        print('Value MABear='+str(oDSeriesTDMAIC.GetValue_d('MABear',PUNITS_Week,0) ) )
    #
    # Testing DSeriesTDemark
    if oChartOHLC.DSeriesExists('TDemark'):
        print('----Found TDemark Overlay')
        oDSeriesTDemark = oChartOHLC.DSeriesFactory('TDemark')
        print('Param LBperiods='+str(oDSeriesTDemark.iLBperiods) )
        print('Param SetupPeriods='+str(oDSeriesTDemark.iSetupPeriods) )
        print('Param CountdownLBperiods='+str(oDSeriesTDemark.iCountdownLBperiods) )
        print('Param CountdownPeriods='+str(oDSeriesTDemark.iCountdownPeriods) )
        print('Param ComboLBperiods='+str(oDSeriesTDemark.iComboLBperiods) )
        print('Param ComboPeriods='+str(oDSeriesTDemark.iComboPeriods) )

        print('Value MAverage='+str(oDSeriesTDemark.GetValue_d('MAverage',PUnits,0) ) )
        print('Value TDSetupBuy='+str(oDSeriesTDemark.GetValue_i('TDSetupBuy',PUnits,0) ) )
        print('Value TDSetupSell='+str(oDSeriesTDemark.GetValue_i('TDSetupSell',PUnits,0) ) )
        print('Value TDcountBuy='+str(oDSeriesTDemark.GetValue_i('TDcountBuy',PUnits,0) ) )
        print('Value TDcountSell='+str(oDSeriesTDemark.GetValue_i('TDcountSell',PUnits,0) ) )
        print('Value TDcomboBuy='+str(oDSeriesTDemark.GetValue_i('TDcomboBuy',PUnits,0) ) )
        print('Value TDcomboSell='+str(oDSeriesTDemark.GetValue_i('TDcomboSell',PUnits,0) ) )

