Example #1
0
    def showChartPatterns(self):
        settings = self.parent().parent().parent().parent(
        ).gui.settingsTab.getVal()

        lineStyle = []
        for x in settings[1]:
            if x == 0:
                lineStyle.append('solid')
            elif x == 1:
                lineStyle.append('dashed')
            elif x == 2:
                lineStyle.append('dashdot')
            elif x == 3:
                lineStyle.append('dotted')
            else:
                lineStyle.append('-')

        color = []
        for x in settings[2]:
            if x == 0:
                color.append('r')
            elif x == 1:
                color.append('b')
            elif x == 2:
                color.append('y')
            elif x == 3:
                color.append('b')
            elif x == 4:
                color.append('g')
            elif x == 5:
                color.append('c')
            else:
                color.append('r')
        values = settings[0]
        enables = settings[3]

        strategy = Strategy(self.chart.data)
        strategy.setPositiveSignal(values[0])
        strategy.setNegativeSignal(values[1])
        #ustawiane wartoĊ›ci
        if enables[2]:
            strategy.setTrendVal(values[2])
        else:
            strategy.disableTrendVal()

        if enables[3]:
            strategy.setHeadAndShouldersVal(values[3])
        else:
            strategy.disableHeadAndShouldersVal()

        if enables[4]:
            strategy.setTripleTopVal(values[4])
        else:
            strategy.disableTripleTopVal()

        if enables[5]:
            strategy.setRisingWedgeVal(values[5])
        else:
            strategy.disableRisingWedgeVal()

        if enables[6]:
            strategy.setFallingTriangleVal(values[6])
        else:
            strategy.disableFallingTriangleVal()

        if enables[7]:
            strategy.setReversedHeadAndShouldersVal(values[7])
        else:
            strategy.disableReversedHeadAndShouldersVal()

        if enables[8]:
            strategy.setTripleBottomVal(values[8])
        else:
            strategy.disableTripleBottomVal()

        if enables[9]:
            strategy.setFallingWedgeVal(values[9])
        else:
            strategy.disableFallingWedgeVal()

        if enables[10]:
            strategy.setRisingTriangleVal(values[10])
        else:
            strategy.disableRisingTriangleVal()

        if enables[11]:
            strategy.setSymetricTriangleVal(values[11])
        else:
            strategy.disableSymetricTriangleVal()

        if enables[12]:
            strategy.setRectangleVal(values[12])
        else:
            strategy.disableRectangleVal()

        if enables[13]:
            strategy.setFlagPennantVal(values[13])
        else:
            strategy.disableFlagPennantVal()

        if enables[14]:
            strategy.setOscilatorsVal(values[14])
        else:
            strategy.disableOscilatorsVal()

        if enables[15]:
            strategy.setNewHighNewLowVal(values[15])
        else:
            strategy.disableNewHighNewLowVal()

        if enables[16]:
            strategy.setBollignerVal(values[16])
        else:
            strategy.disableBollignerVal()

        if enables[17]:
            strategy.setMomentumVal(values[17])
        else:
            strategy.disableMomentumVal()

        if enables[18]:
            strategy.setRocVal(values[18])
        else:
            strategy.disableRocVal()

        if enables[19]:
            strategy.setCciVal(values[19])
        else:
            strategy.disableCciVal()

        if enables[20]:
            strategy.setRsiVal(values[20])
        else:
            strategy.disableRsiVal()

        if enables[21]:
            strategy.setWilliamsVal(values[21])
        else:
            strategy.disableWilliamsVal()

        if enables[22]:
            strategy.setRisingBreakawayGapVal(values[22])
        else:
            strategy.disableRisingBreakawayGapVal()

        if enables[23]:
            strategy.setRisingContinuationGapVal(values[23])
        else:
            strategy.disableRisingContinuationGapVal()

        if enables[24]:
            strategy.setFallingExhaustionGapVal(values[24])
        else:
            strategy.disableFallingExhaustionGapVal()

        if enables[25]:
            strategy.setFallingBreakawayGapVal(values[25])
        else:
            strategy.disableFallingBreakawayGapVal()

        if enables[26]:
            strategy.setRisingExhaustionGapVal(values[26])
        else:
            strategy.disableRisingExhaustionGapVal()

        if enables[27]:
            strategy.setFallingContinuationGapVal(values[27])
        else:
            strategy.disableFallingContinuationGapVal()

        if enables[28]:
            strategy.setBull3Val(values[28])
        else:
            strategy.disableBull3Val()

        if enables[29]:
            strategy.setMornigStarVal(values[29])
        else:
            strategy.disableMornigStarVal()

        if enables[30]:
            strategy.setPiercingVal(values[30])
        else:
            strategy.disablePiercingVal()

        if enables[31]:
            strategy.setBear3Val(values[31])
        else:
            strategy.disableBear3Val()

        if enables[32]:
            strategy.setEveningStarVal(values[32])
        else:
            strategy.disableEveningStarVal()

        if enables[33]:
            strategy.setDarkCloudVal(values[33])
        else:
            strategy.disableDarkCloudVal()

        #ustawiamy

        self.formationDrawer = FormationDrawer(self.chart, strategy)
        #ustawiamy formation Drawer
        self.formationDrawer.setTrendColor(color[2])
        self.formationDrawer.setTrendLstyle(lineStyle[2])
        self.formationDrawer.setTrendLwidth(2.0)
        self.formationDrawer.setHeadAndShouldersColor(color[3])
        self.formationDrawer.setHeadAndShouldersLstyle(lineStyle[3])
        self.formationDrawer.setHeadAndShouldersLwidth(2.0)
        self.formationDrawer.setTripleTopColor(color[4])
        self.formationDrawer.setTripleTopLstyle(lineStyle[4])
        self.formationDrawer.setTripleTopLwidth(2.0)
        self.formationDrawer.setRisingWedgeColor(color[5])
        self.formationDrawer.setRisingWedgeLstyle(lineStyle[5])
        self.formationDrawer.setRisingWedgeLwidth(2.0)
        self.formationDrawer.setFallingTriangleColor(color[6])
        self.formationDrawer.setFallingTriangleLstyle(lineStyle[6])
        self.formationDrawer.setFallingTriangleLwidth(2.0)
        self.formationDrawer.setReversedHeadAndShouldersColor(color[7])
        self.formationDrawer.setReversedHeadAndShouldersLstyle(lineStyle[7])
        self.formationDrawer.setReversedHeadAndShouldersLwidth(2.0)
        self.formationDrawer.setTripleBottomColor(color[8])
        self.formationDrawer.setTripleBottomLstyle(lineStyle[8])
        self.formationDrawer.setTripleBottomLwidth(2.0)
        self.formationDrawer.setFallingWedgeColor(color[9])
        self.formationDrawer.setFallingWedgeLstyle(lineStyle[9])
        self.formationDrawer.setFallingWedgeLwidth(2.0)
        self.formationDrawer.setRisingTriangleColor(color[10])
        self.formationDrawer.setRisingTriangleLstyle(lineStyle[10])
        self.formationDrawer.setRisingTriangleLwidth(2.0)
        self.formationDrawer.setSymetricTriangleColor(color[11])
        self.formationDrawer.setSymetricTriangleLstyle(lineStyle[11])
        self.formationDrawer.setSymetricTriangleLwidth(2.0)
        #przerwa
        self.formationDrawer.setFlagPennantColor(color[13])
        self.formationDrawer.setFlagPennantLstyle(lineStyle[13])
        self.formationDrawer.setFlagPennantLwidth(2.0)
        #przerwa
        self.formationDrawer.setRisingBreakawayGapColor(color[22])
        self.formationDrawer.setRisingBreakawayGapLstyle(lineStyle[22])
        self.formationDrawer.setRisingBreakawayGapLwidth(2.0)
        self.formationDrawer.setRisingContinuationGapColor(color[23])
        self.formationDrawer.setRisingContinuationGapLstyle(lineStyle[23])
        self.formationDrawer.setRisingContinuationGapLwidth(2.0)
        self.formationDrawer.setFallingExhaustionGapColor(color[24])
        self.formationDrawer.setFallingExhaustionGapLstyle(lineStyle[24])
        self.formationDrawer.setFallingExhaustionGapLwidth(2.0)
        self.formationDrawer.setFallingBreakawayGapColor(color[25])
        self.formationDrawer.setFallingBreakawayGapLstyle(lineStyle[25])
        self.formationDrawer.setFallingBreakawayGapLwidth(2.0)
        self.formationDrawer.setRisingExhaustionGapColor(color[26])
        self.formationDrawer.setRisingExhaustionGapLstyle(lineStyle[26])
        self.formationDrawer.setRisingExhaustionGapLwidth(2.0)
        self.formationDrawer.setFallingContinuationGapColor(color[27])
        self.formationDrawer.setFallingContinuationGapLstyle(lineStyle[27])
        self.formationDrawer.setFallingContinuationGapLwidth(2.0)
        self.formationDrawer.setBull3Color(color[28])
        self.formationDrawer.setBull3Lstyle(lineStyle[28])
        self.formationDrawer.setBull3Lwidth(2.0)
        self.formationDrawer.setMornigStarColor(color[29])
        self.formationDrawer.setMornigStarLstyle(lineStyle[29])
        self.formationDrawer.setMornigStarLwidth(2.0)
        self.formationDrawer.setPiercingColor(color[30])
        self.formationDrawer.setPiercingLstyle(lineStyle[30])
        self.formationDrawer.setPiercingLwidth(2.0)
        self.formationDrawer.setBear3Color(color[31])
        self.formationDrawer.setBear3Lstyle(lineStyle[31])
        self.formationDrawer.setBear3Lwidth(2.0)
        self.formationDrawer.setEveningStarColor(color[32])
        self.formationDrawer.setEveningStarLstyle(lineStyle[32])
        self.formationDrawer.setEveningStarLwidth(2.0)
        self.formationDrawer.setDarkCloudColor(color[33])
        self.formationDrawer.setDarkCloudLstyle(lineStyle[33])
        self.formationDrawer.setDarkCloudLwidth(2.0)

        self.formationDrawer.setFormations(strategy)
        self.formationDrawer.drawFormations()