-3

code extract

The code is shown in the picture above. It is only opening one position as shown in the second picture output

  • 1
    Please don't post your code as an image. Instead, copy and paste it here and use the code blocks. – vitruvius Mar 06 '23 at 14:23
  • 1
    Hello and welcome to Stack Overflow. Please read [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/questions/285551/why-should-i-ot-upload-images-of-code-data-errors) and [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) to see how you can improve your question. – Andy Preston Mar 06 '23 at 16:56

1 Answers1

0

You sellCondition can never be true because you have strategy.position_size > 0 there.

strategy.position_size can only be true if you are in a long position.

You should be checking strategy.position_size < 0 instead.

vitruvius
  • 15,740
  • 3
  • 16
  • 26