@@ -57,7 +57,7 @@ def createPlotWidgets(self):
57
57
def drawCandles (self ):
58
58
59
59
fplt .candlestick_ochl (self .data ['Open Close High Low' .split ()], ax = self .ax0 )
60
-
60
+
61
61
#self.hover_label = fplt.add_legend('', ax=self.ax0)
62
62
#fplt.set_time_inspector(self.update_legend_text, ax=self.ax0, when='hover', data=data)
63
63
#fplt.add_crosshair_info(self.update_crosshair_text, ax=self.ax0)
@@ -66,6 +66,22 @@ def drawCandles(self):
66
66
#self.createControlPanel(self.ax0.ax_widget)
67
67
pass
68
68
69
+ def drawExternalsIndicators (self ):
70
+
71
+ #if self.IndRsiActivated:
72
+ self .rsi_indicator = rsi .Rsi (self .data )
73
+ self .rsi_indicator .draw (self .ax_rsi )
74
+
75
+ #if self.IndStochasticActivated:
76
+ self .stochastic_indicator = stochastic .Stochastic (self .data )
77
+ self .stochastic_indicator .draw (self .ax_stochastic )
78
+
79
+ #if self.IndStochasticRsiActivated:
80
+ self .stochasticRsi_indicator = stochasticRsi .StochasticRsi (self .data )
81
+ self .stochasticRsi_indicator .draw (self .ax_stochasticRsi )
82
+
83
+ pass
84
+
69
85
#########
70
86
# Draw orders on charts (with arrows)
71
87
#########
@@ -305,6 +321,9 @@ def refreshChart(self):
305
321
306
322
def setChartData (self , data ):
307
323
self .data = data
324
+
325
+ # Calculate indicators only one time when setting chart data
326
+ self .drawExternalsIndicators ()
308
327
pass
309
328
310
329
def resetChart (self ):
@@ -326,24 +345,9 @@ def updateChart(self):
326
345
self .ichimoku_indicator = ichimoku .Ichimoku (self .data )
327
346
self .ichimoku_indicator .draw (self .ax0 )
328
347
329
- if self .IndRsiActivated :
330
- self .rsi_indicator = rsi .Rsi (self .data )
331
- self .rsi_indicator .draw (self .ax_rsi )
332
-
333
- if self .IndStochasticActivated :
334
- self .stochastic_indicator = stochastic .Stochastic (self .data )
335
- self .stochastic_indicator .draw (self .ax_stochastic )
336
- pass
337
-
338
- if self .IndStochasticRsiActivated :
339
- self .stochasticRsi_indicator = stochasticRsi .StochasticRsi (self .data )
340
- self .stochasticRsi_indicator .draw (self .ax_stochasticRsi )
341
- pass
342
-
343
348
if self .IndVolumesActivated :
344
349
fplt .volume_ocv (self .data ['Open Close Volume' .split ()], ax = self .ax0 .overlay ())
345
350
346
-
347
351
# Finally draw candles
348
352
self .drawCandles ()
349
353
@@ -355,28 +359,19 @@ def updateChart(self):
355
359
356
360
pass
357
361
358
-
362
+
359
363
def setIndicator (self , indicatorName , activated ):
360
364
361
- if (indicatorName == "Rsi" ):
362
- self .IndRsiActivated = activated
363
-
364
- if (indicatorName == "Stochastic" ):
365
- self .IndStochasticActivated = activated
366
-
367
- if (indicatorName == "StochasticRsi" ):
368
- self .IndStochasticRsiActivated = activated
369
-
370
365
if (indicatorName == "Ichimoku" ):
371
366
self .IndIchimokuActivated = activated
372
-
367
+
373
368
if (indicatorName == "Volumes" ):
374
369
self .IndVolumesActivated = activated
375
370
376
371
self .updateChart ()
377
372
378
373
pass
379
-
374
+
380
375
#############
381
376
# Show finplot Window
382
377
#############
0 commit comments