• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 -

    http://www.ninjatrader.com/support/f...ead.php?t=4991
    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:

          https://ninjatrader.com/support/foru...hin-a-strategy

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by iq200, 03-11-2018, 07:49 PM
          24 responses
          1,004 views
          0 likes
          Last Post mrlucky1x  
          Started by DavidHP, Today, 08:18 PM
          0 responses
          1 view
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Started by liquid150, Today, 06:20 AM
          1 response
          10 views
          0 likes
          Last Post User1104  
          Started by liquid150, Today, 06:22 AM
          1 response
          17 views
          0 likes
          Last Post lexusfood  
          Started by geo9419, 05-09-2019, 02:39 PM
          9 responses
          320 views
          1 like
          Last Post jgoarm
          by jgoarm
           
          Working...
          X