# Set the 6th column as the vol data from 5 to 25 million rantable.setCol(5, 50000000, 250000000) # Now we read the data from the table into arrays timeStamps = rantable.getCol(0) highData = rantable.getCol(1) lowData = rantable.getCol(2) openData = rantable.getCol(3) closeData = rantable.getCol(4) volData = rantable.getCol(5) # Create a FinanceChart object of width 640 pixels c = FinanceChart(640) # Add a title to the chart c.addTitle("Finance Chart Demonstration") # Set the data into the finance chart object c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays) # Add a slow stochastic chart (75 pixels high) with %K = 14 and %D = 3 c.addSlowStochastic(75, 14, 3, 0x006060, 0x606000) # Add the main chart with 240 pixels in height c.addMainChart(240) # Add a 10 period simple moving average to the main chart, using brown color c.addSimpleMovingAvg(10, 0x663300) # Add a 20 period simple moving average to the main chart, using purple color c.addSimpleMovingAvg(20, 0x9900ff)
sma20 = ArrayMath(closeData).movAvg(20).result() for i in range(0, len(sma5)): buySignal[i] = NoValue sellSignal[i] = NoValue if i > 0: if (sma5[i - 1] <= sma20[i - 1]) and (sma5[i] > sma20[i]): buySignal[i] = lowData[i] if (sma5[i - 1] >= sma20[i - 1]) and (sma5[i] < sma20[i]): sellSignal[i] = highData[i] # Create a FinanceChart object of width 640 pixels c = FinanceChart(640) # Add a title to the chart c.addTitle("Finance Chart with Custom Symbols") # Set the data into the finance chart object c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays) # Add the main chart with 240 pixels in height mainChart = c.addMainChart(240) # Add buy signal symbols to the main chart, using cyan (0x00ffff) upward pointing arrows as symbols buyLayer = mainChart.addScatterLayer(None, buySignal, "Buy", ArrowShape(0, 1, 0.4, 0.4), 11, 0x00ffff) # Shift the symbol lower by 20 pixels buyLayer.getDataSet(0).setSymbolOffset(0, 20) # Add sell signal symbols to the main chart, using purple (0x9900cc) downward pointing arrows as
# Set the 6th column as the vol data from 5 to 25 million rantable.setCol(5, 50000000, 250000000) # Now we read the data from the table into arrays timeStamps = rantable.getCol(0) highData = rantable.getCol(1) lowData = rantable.getCol(2) openData = rantable.getCol(3) closeData = rantable.getCol(4) volData = rantable.getCol(5) # Create a FinanceChart object of width 720 pixels c = FinanceChart(720) # Add a title to the chart c.addTitle("Finance Chart Demonstration") # Disable default legend box, as we are using dynamic legend c.setLegendStyle("normal", 8, Transparent, Transparent) # Set the data into the finance chart object c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays) # Add the main chart with 240 pixels in height c.addMainChart(240) # Add a 10 period simple moving average to the main chart, using brown color c.addSimpleMovingAvg(10, 0x663300) # Add a 20 period simple moving average to the main chart, using purple color
lb_data = [x.close for x in bars] # Volume Breakdown Data bars = getBarMin01(vb, trade_date) vb_open = [0 for x in bars] vb_high = [x.high for x in bars] vb_low = [x.low for x in bars] vb_close = [x.close for x in bars] #c = FinanceChart(1024) c = FinanceChart(2200) # Add a title to the chart c.addTitle("Basket Divergences - %s" % trade_date.strftime('%D (%a)')) # Set the data into the finance chart object c.setData(ts, es_high, es_low, es_open, es_close, es_vol, None) # Add the main chart with 240 pixels in height es_chart = c.addMainChart(600) # Add HLOC symbols to the main chart, using green/red for up/down days #c.addHLOC('0x008000', '0xcc0000') c.addCandleStick('0x008000', '0xcc0000') # Add a 75 pixels volume bars sub-chart to the bottom of the main chart, using # green/red/grey for up/down/flat days #c.addVolBars(75, '0x99ff99', '0xff9999', '0x808080') #c.addVolIndicator(75, '0x99ff99', '0xff9999', '0x808080')