Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator values from strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Indicator values from strategy

    Hi

    Can you tell me if there is a difference between calling an indicator from a strategy when the indicator is added by the code or just referenced.

    e.g is

    protectedoverridevoid Initialize()
    {
    Add(SmoothedRsiInverseFisherTransform(
    4,4));
    ....
    }

    protectedoverridevoid OnBarUpdate()
    {
    if (Rising(SmoothedRsiInverseFisherTransform(4,4)))
    .....
    }


    different from


    protectedoverridevoid Initialize()
    {
    stuff ....
    }

    protectedoverridevoid OnBarUpdate()
    {
    if (Rising(SmoothedRsiInverseFisherTransform(4,4)))
    .....
    }


    Could there be therefore a difference in indicator values used by the code and those displayed ?

    probably a silly question but I'm trying to locate behaviour difference in my strategy between live and backtested data.

    thanks for any help

    regards dave



    #2
    When you Add(indicator) in initialize() it will plot it on the chart.


    In terms of calculations if the indicator is called from within the script it will only be added to memory once. It will not have to be re-added each time it is called in order to conserve memory.

    In your example the difference would be that the first one plots it and the second one does not plot.

    Let me know if I can be of further assistance.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Thanks Lance

      Suppose I don't use the Add statement and just reference the indicator and supose that it isn't tested until bar 100 i.e

      protectedoverridevoid OnBarUpdate()
      {

      if (CurrentBar < 100)
      // Dont ever reference SmoothedInverse etc
      else if (CurrentBar > 100)

      if (Rising(SmoothedRsiInverseFisherTransform(4,4)))
      .....
      }

      Is the indicator added at that point and how many bars will the indicator contain ?



      thanks for your help

      regards dave

      Comment


        #4
        No calculations will be performed until CurrentBar > 100

        At that point it would run the SmoothedRsiInverseFisherTransform() over the available data. These values are then stored internally.

        It will then wait until the next time it is called, and run the calculations between the results of the first time it was ran up to the current value needed.

        Let me know if I can further clarify this further.
        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by junkone, Today, 11:37 AM
        0 responses
        5 views
        0 likes
        Last Post junkone
        by junkone
         
        Started by quantismo, 04-17-2024, 05:13 PM
        5 responses
        35 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by proptrade13, Today, 11:06 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        34 views
        0 likes
        Last Post love2code2trade  
        Started by cls71, Today, 04:45 AM
        2 responses
        10 views
        0 likes
        Last Post eDanny
        by eDanny
         
        Working...
        X