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

Adding/plotting an indicator with harcoded period into/from strategy

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

    Adding/plotting an indicator with harcoded period into/from strategy

    I need an indicator in strategy with hard coded period..

    The below strategy code
    -----------------------
    protected override void Initialize()
    {
    Add(PeriodType.Day, 1);
    MyIndicator(BarsArray[1], Period).Plots[0].Pen.Color = Color.Blue;
    Add(MyIndicator(BarsArray[1], Period));
    }
    ---------------------
    Throws exception: Failed to call method 'Initialize' for strategy 'MyStrategy': 'BarsArray' property can not be accessed from within 'Initialize' method

    Questions:
    - Is there a way to add an indicator into strategy with specific Period?
    - How to plot such an indicator (with hardcoded period) from a strategy?

    Thanks for help,
    Alex.

    #2
    Alex, please move the parts accessing BarsArray to the OnBarUpdate().

    To add a hardcoded indicator just do something like this -

    Add(CCI(20));

    For customizing plots, color and panels, please see this -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      How to plot an indicator for additional bars object that I add in initialize() method.

      Code:
      protected override void Initialize()
      {
         Add(PeriodType.Day, 1);
      }
      Now I can use the new bars objects with my custom indicator
      Code:
      protected override void OnBarUpdate()
      {
         MyIndicator(BarsArray[1], 10)
      }
      But how to plot it?? Following does not work:

      Code:
      MyIndicator(BarsArray[1], Period).Plots[0].Pen.Color = Color.Blue;

      Comment


        #4
        ma5ter, on NinjaTrader 6.5 multiseries indicators are unfortunately not supported - this is only possible for strategies - the same concept will be available for indicators in NinjaTrader 7 -

        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mongo, Today, 11:05 AM
        4 responses
        14 views
        0 likes
        Last Post Mongo
        by Mongo
         
        Started by traderqz, Today, 12:06 AM
        7 responses
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Skifree, Today, 03:41 AM
        5 responses
        13 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by traderqz, Yesterday, 09:06 AM
        5 responses
        34 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by guillembm, Today, 11:25 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X