For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Conditional If statement not executing under the next(self)

  • I can't seem to get my conditional if statement to work!

    It works properly with ONE condition (both seem to work), however nothing happens once I introduce TWO comparisons with the AND operator.

    def next(self):
        if not self.position:
            if[0] >=[0] and[0] >=[0]:
                print([0],, self.datetime.time(ago=0))
            print('nothing to print! ')

    I don't get an error, but nothing seems to output. Not even the else statement.

  • Your else statement is in different if condition, so if you have no position it will not come up doesn't matter if your if ... and ... string works or not.

    It can be a case that your conditions under and operator never come together, so and never returns true. You may want to plot the indicators and prices, or print them for each bar, and verify if the pattern you are looking for happens.

Log in to reply