Announcement

Collapse
No announcement yet.

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 -

    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.

        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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          546 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X