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

Select BarType from menu

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

    Select BarType from menu

    Hello

    I would like selecting between Range and Renko bars types in a secondary serie in my strategy.

    I have created a enum variable but it does not works, error compiling CS0117



    public enum TypeOfBar
    {
    Range,
    Renko
    }

    ----------------------------------------------

    [NinjaScriptProperty]
    [Display(Name = "Type of Bar", GroupName = "Parameters", Order = 1)]
    public TypeOfBar MyTypeOfBar { get; set; }

    -----------------------------------------------

    AddDataSeries(Data.BarsPeriodType.MyTypeOfBar, Bar_Size);

    -----------------------------------------------

    What would be a better approach to this issue?

    Thanks

    #2
    Hello Impeesa,

    Thank you for your reply.

    It's not supported to load a data series in a dynamic manner based on user input. From our help guide:

    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.


    What I would recommend is instead to add both the data series, and use the chosen enum value to determine which series to use for your calculations.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello, Kate

      I will take your advise.

      And what about a menu to select another instrument? I expect the best way is not with a enum value but an empty text field.

      Can you please tell me how can I do that? Have you got any example?

      Thanks in advanced

      Comment


        #4
        Hello Impeesa,

        Thank you for your reply.

        That would fall under dynamically loading the data series and may run into the same issues as above. However, you could look at the Spread indicator on the publicly available User App Share - this indicator allows you to specify a secondary data series for calculating a spread via a user input that is then used in the call to AddDataSeries:

        Plots the Spread of two instruments The first instrument is the primary chart data series. The secondary instrument is specified by the parameter "Symbol2". The Parameters "Qty1" and "Qty2" are multipliers which are applied to each instrument's price before adding the two; default values are "Qty1=1" and "Qty2=‐1" which will simply plot the difference between […]


        Please let us know if we may be of further assistance to you.

        The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X