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

Indicator invoke question

  • Hi:

    Indicators in BT is instantiated in the init method, if I want to make the decision to use a certain indicator at run time, is there a way to do the indicator calculation in the next() method without declaration in init? The plotting is not a problem to me. What I need is that I can switch different indicators at different conditions.


  • administrators

    No. Because the indicator needs to be calculated for each bar (set) of prices.

    Instantiate all indicators you may need and let your logic choose which one counts when it comes down to making a decision.

Log in to reply