Skip to content
Discussion options

You must be logged in to vote

I figured out a solution. Instead of creating two rectangles/ROIs, I instead extended the ROI class from pyqtgraph. It takes a given ratio, and depending on what type of position it is, it paints the tp and sl accordingly.

class FinPosition(pg.ROI):
    def __init__(self, ax, brush_tp, position_type, brush_sl, ratio=.5, *args, **kwargs):
        self.ax = ax
        self.brush_tp = brush_tp
        self.brush_sl = brush_sl
        self.position_type = position_type

        if position_type == "long":
            ratio=1-ratio
        self.ratio = ratio

        super().__init__(*args, **kwargs)

        center = [0.5, ratio]

        dy = -self.size()[1]*self.ratio
        self.translate(0

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@simsam8
Comment options

@highfestiva
Comment options

@simsam8
Comment options

@kumarangp
Comment options

Answer selected by simsam8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants