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

Accessing indicator values without plots

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

    Accessing indicator values without plots

    Hi,

    I am trying to access a value created by an indicator but because there are no plot values I am not sure how or even if this is possible?

    I would appreciate any feedback from members or NT staff that can point me in the right direction.

    Regards,
    suprsnipes

    #2
    suprsnipes, we have a sample demonstrating how to expose variables or dataseries that are not plots and thus exposed naturally -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Following your example in the SampleBoolSeries file downloadable in post #2, let's say that the double ExposedVariable wants to be accessed from within a Strategy.

      How can this be done?

      I am getting an error in Line31. I have also changed State==DataLoaded. Can you take a look at the code and amend it so ExposedVariable is accessible? Thanks in advance!



      namespace NinjaTrader.NinjaScript.Strategies

      {

      public class ExposedVariableTestUnlocked : Strategy

      {



      private double SampleBoolSeries.ExposedVariable;







      protected override void OnStateChange()

      {

      if (State == State.SetDefaults)

      {

      Description = @"Enter the description for your new custom Strategy here.";

      Name = "ExposedVariableTestUnlocked";

      Calculate = Calculate.OnBarClose;

      EntriesPerDirection = 1;

      EntryHandling = EntryHandling.AllEntries;

      IsExitOnSessionCloseStrategy = true;

      ExitOnSessionCloseSeconds = 30;

      IsFillLimitOnTouch = false;

      MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;

      OrderFillResolution = OrderFillResolution.Standard;

      Slippage = 0;

      StartBehavior = StartBehavior.WaitUntilFlat;

      TimeInForce = TimeInForce.Day;

      TraceOrders = true;

      RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;

      StopTargetHandling = StopTargetHandling.PerEntryExecution;

      BarsRequiredToTrade = 20;

      // Disable this property for performance gains in Strategy Analyzer optimizations

      // See the Help Guide for additional information

      IsInstantiatedOnEachOptimizationIteration = true;

      ExposedVariable = 0;

      }

      else if (State == State.Configure)

      {

      }

      else if (State == State.DataLoaded)

      {

      double SampleBoolSeries;

      }

      }




      protected override void OnBarUpdate()

      {

      if (BarsInProgress != 0)

      return;




      if (CurrentBars[0] < 1)

      return;




      // Set 1

      if (Close[0] != Open[0])

      {

      Print(CurrentBars[0].ToString() + @" Close0 value is = " + Close[0].ToString());

      Print(CurrentBars[0].ToString() + @" ExposedVariable value is = " + SampleBoolSeries.ExposedVariable.ToString());

      }



      }

      }

      }

      Comment


        #4
        Hello roblogic,

        Thank you for the post.

        In the future please create new threads for new questions, it looks like this thread was resolved already.

        In regard to your questions, what is the specific error you are seeing in the NinjaScript editor? The line numbers don't transfer to the forum post so I am not sure which syntax you are referring to.

        One additional question, you posted in the NT7 forum but this is NT8 syntax, which version of the platform is this question for?


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Ok sorry. I did not notice I was in the NT7 forum. Just made a new thread in the link below:

          Following the example in the SampleBoolSeries file downloaded below, let's say that the double ExposedVariable needs to be accessed from within a Strategy. How

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by tkaboris, Today, 08:01 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          31 responses
          817 views
          1 like
          Last Post NinjaTrader_Adrian  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by swestendorf, Today, 11:14 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_Kimberly  
          Started by Mupulen, Today, 11:26 AM
          0 responses
          7 views
          0 likes
          Last Post Mupulen
          by Mupulen
           
          Working...
          X