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 WHICKED, Today, 02:02 PM
          2 responses
          5 views
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Started by selu72, Today, 02:01 PM
          0 responses
          3 views
          0 likes
          Last Post selu72
          by selu72
           
          Started by f.saeidi, Today, 12:14 PM
          8 responses
          21 views
          0 likes
          Last Post f.saeidi  
          Started by Mikey_, 03-23-2024, 05:59 PM
          3 responses
          50 views
          0 likes
          Last Post Sam2515
          by Sam2515
           
          Started by Russ Moreland, Today, 12:54 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X