Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Good coding technique

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

    Good coding technique

    Understanding the limitations of answering such "general questions" as the one I am about to ask....with specific "yes/no" answers.....I'd appreciate any guidance you have to offer :

    1. Is it generally considered to be a better coding policy to split individual pieces of indicator based coding into separate indicators....or combine them into one?
    Example: (two indicators running on a chart)
    - Indicator1 plots a 5min moving average on a tick chart
    - Indicator2 performs calculations on previous 5min candles (MAX High/Low and
    maximum bar size...and also plots this information on a tick chart.

    Would it generally be considered better coding form to merge the two 5min based indicators into one indicator...making all 5min calculations in one piece of code....or leaving them separated into two individual indicators?

    -------------------------------------------------------------------------------------
    2. Is this answer above the same for indicator code that plots on the same time frame as the chart....Ex: Tick chart moving average and a tick chart calculation of previous bar sizes /High/Low.

    ----------------------------------------------------------------------------------------
    3. Does the combination of chart time frame and indicator time frame (assuming they are different) have any impact on the answers to #1 and #2 ?
    Ex: Tick charts with minute based indicators.....versus minute charts with tick based indicators....


    Thanks......

    #2

    Comment


      #3
      Photog, as bukkan has observed, it is best to combine as much as possible while retaining re-usability for future projects.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Thanks for the advice...and the help!

        Comment


          #5
          Originally posted by photog53 View Post
          Understanding the limitations of answering such "general questions" as the one I am about to ask....with specific "yes/no" answers.....I'd appreciate any guidance you have to offer :

          1. Is it generally considered to be a better coding policy to split individual pieces of indicator based coding into separate indicators....or combine them into one?
          Example: (two indicators running on a chart)
          - Indicator1 plots a 5min moving average on a tick chart
          - Indicator2 performs calculations on previous 5min candles (MAX High/Low and
          maximum bar size...and also plots this information on a tick chart.

          Would it generally be considered better coding form to merge the two 5min based indicators into one indicator...making all 5min calculations in one piece of code....or leaving them separated into two individual indicators?

          -------------------------------------------------------------------------------------
          2. Is this answer above the same for indicator code that plots on the same time frame as the chart....Ex: Tick chart moving average and a tick chart calculation of previous bar sizes /High/Low.

          ----------------------------------------------------------------------------------------
          3. Does the combination of chart time frame and indicator time frame (assuming they are different) have any impact on the answers to #1 and #2 ?
          Ex: Tick charts with minute based indicators.....versus minute charts with tick based indicators....


          Thanks......
          Unfortunately, the answer to all your questions is: "it depends ..."

          If the plots you are designing will (?almost) always be used together, then it makes sense to not incur the overhead of calling separate indicators, and making essentially the same calculations twice in different indicators, so you would put all the code in one indicator.

          OTOH, if these are plots are kind of like utility indicators which you will combine with others in various ways, then it makes sense to retain the flexibility of calling compact code from other places, so you may want to code them as separate indicators.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ScottWalsh, Today, 06:52 PM
          2 responses
          15 views
          0 likes
          Last Post ScottWalsh  
          Started by cre8able, Today, 07:24 PM
          0 responses
          0 views
          0 likes
          Last Post cre8able  
          Started by Haiasi, Today, 06:53 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottW, Today, 06:09 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ftsc2022, 10-25-2022, 12:03 PM
          5 responses
          256 views
          0 likes
          Last Post KeyonMatthews  
          Working...
          X