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

Using ATR and OrderFlowVWAP indicator same time

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

    Using ATR and OrderFlowVWAP indicator same time

    A Strategy with two indicators, one lives inside Custom.dll and the other inside Vendor.dll (Same namespace and Class Name)

    HTML Code:
    extern alias custom;
    using System;
    using System.Diagnostics;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript.Indicators;
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public class StrategyTest : Strategy
        {
            private OrderFlowVWAP vwap;
            private custom::NinjaTrader.NinjaScript.Indicators.ATR atr;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Name = "StrategyTest";
                }
                else if (State == State.DataLoaded)
                {
                    atr = new custom::NinjaTrader.NinjaScript.Indicators.ATR()
                    {
                        Period = 14
                    };
                    vwap = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3);
    
                    AddChartIndicator(vwap);
                    AddChartIndicator(atr);
                }
           }
       }
    }
    Only OrderFlowVWAP is loaded, the ATR still loading...

    The code is correct?

    Thanks

    #2
    Hi Rudmax,

    replace private custom::NinjaTrader.NinjaScript.Indicators.ATR atr; with

    private ATR atr;

    and

    instead of

    atr = new custom::NinjaTrader.NinjaScript.Indicators.ATR() { Period = 14 };
    write in your (State == State.DataLoaded)

    atr = ATR(14);

    then it should work.

    hopefully I've helped you.

    regards Tradeer

    Comment


      #3
      Originally posted by Tradeer View Post
      Hi Rudmax,

      replace private custom::NinjaTrader.NinjaScript.Indicators.ATR atr; with

      private ATR atr;

      and

      instead of

      atr = new custom::NinjaTrader.NinjaScript.Indicators.ATR() { Period = 14 };
      write in your (State == State.DataLoaded)

      atr = ATR(14);

      then it should work.

      hopefully I've helped you.

      regards Tradeer
      Nops, ATR reside on Strategy Class at Custom.dll not in Strategy class at Vendor.dll wich has also a Strategy class... In this example, I extend Strategy at Vendor.dll. There are no ATR method at there.
      Last edited by Rudmax; 05-09-2020, 12:36 PM.

      Comment


        #4
        Hi Rudmax, thanks for your question.

        The only thing that is needed to access code from a dll is a reference to the DLL from Right click>References in the NinjaScript editor. To use an OrderFlow+ indicator within a script, you must add a 1 tick series to the script because the OrderFlow scripts also add a 1 tick series. e.g., in State.Configure:

        AddDataSeries(BarsPeriodType.Tick, 1);

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi Rudmax, thanks for your question.

          The only thing that is needed to access code from a dll is a reference to the DLL from Right click>References in the NinjaScript editor. To use an OrderFlow+ indicator within a script, you must add a 1 tick series to the script because the OrderFlow scripts also add a 1 tick series. e.g., in State.Configure:

          AddDataSeries(BarsPeriodType.Tick, 1);

          Please let me know if I can assist any further.
          Thank you, It works on NinjaScript Editor, I was trying at Visual Studio...

          I will figure out how to using ATR and OrderFlowVWAP at Visual Studio sice Strategy exists in both Custom.dll and Vendor.dll

          ATR resides in Custom and OrderFlowVWAP is in Vendor.dll

          Click image for larger version  Name:	Anotação 2020-05-11 131924.jpg Views:	0 Size:	33.2 KB ID:	1099198
          Last edited by Rudmax; 05-11-2020, 10:26 AM.

          Comment


            #6
            Hello Rudmax,

            Attached is an example exported script that calls both the ATR and the OrderFlowVWAP indicators and compiles in NinjaTrader without issue. Any messages in Visual Studio can be ignored.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ETFVoyageur, Today, 07:55 PM
            0 responses
            4 views
            0 likes
            Last Post ETFVoyageur  
            Started by janio973, Today, 07:24 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by aligator, 01-06-2022, 12:14 PM
            4 responses
            241 views
            0 likes
            Last Post john_44573  
            Started by reynoldsn, Today, 05:56 PM
            0 responses
            12 views
            0 likes
            Last Post reynoldsn  
            Started by bortz, 11-06-2023, 08:04 AM
            51 responses
            1,995 views
            0 likes
            Last Post aligator  
            Working...
            X