Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script syntax for SHARED variables

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

    Script syntax for SHARED variables

    protected override void OnBarUpdate()
    {
    // When our indicator gives us a bull signal we enter long. Notice that we are accessing the
    // public BoolSeries we made in the indicator.
    if (SampleBoolSeries().BullIndication[0]) EnterLong();

    // When our indicator gives us a bear signal we enter short
    if (SampleBoolSeries().BearIndication[0]) EnterShort();


    ************************************************** ******************
    The above script is from your NT8 SampleBoolSeries indicator file.
    It references a public <bool>Series variable from SampleBoolSeries Strategy.



    Question: if I change the SampleBoolSeries Strategy script to add user-settable "Properties",
    Then what is the syntax to access a Stategy's BearIndication and BullIndication variables.

    for example:
    if (SampleBoolSeries().BearIndication[0]) <== this would be the script's syntax when the Indicator
    DOES NOT have any user-settable properties


    if (SampleBoolSeries(7,true).BearIndication[0]) <== the script's syntax when the Indicator
    DOES HAVE user-settable properties
    I UNDERSTAND that the user-settable variables must
    appear in the script in the same order that they
    appear in the Properties prompts.

    WHAT I DO NOT UNDERSTAND IS THIS: When my script shows "(7,true)"
    does that mean that the ONLY time the correct BearIndication "Value" will be read from the indicator
    is when the user-settable <property> variables are like this ===> SampleBoolSeries(7,true).BearIndication[0]

    WHAT HAPPENS IF THE USER sets the user-settable INDICATOR indicator variables in the <PROPERTIES> to 9 and false.
    Must I add a line to my INDICATOR script file for each instance of the variables for when I WANT TO USE the INDICATOR'S
    shared variable. Like this ==>

    if ( (SampleBoolSeries(7,true).BearIndication[0]) || (SampleBoolSeries(9,false).BearIndication[0]) )
    {
    do something here..
    }

    DoesNinjaTrader8 provide a different INDICATOR-script-syntax that does not require that I provide multiple lines, of code, that
    contain the actual values for each variable passed in the "Call" from the STRATEGY to the INDICATOR?
    Last edited by seefisch; 10-28-2016, 05:34 PM.

    #2
    Hello,

    I wanted to check if I am understanding the question correctly.

    Are you asking if the platform offers any other syntax to call indicators by that may be less complex than what you are currently using?

    If so the NinjaScript does not offer anything specific like this, but you could store the indicators as a variable to reduce its syntax potentially.

    Can you provide a sample of what you would expect the platform to provide instead of the samples you had provided? If I can better understand your expectation, I could likely suggest a solution.

    I look forward to being of further assistance.

    Comment


      #3
      Many thanks for your time.

      Jesse -- yes you answered my questions.

      I CAN see how I could store the values as a variable.

      I have decided to make multiple script files by setting fixed values for each of the variables that were in the Properties and then compiling. Repeat for different settings. It just isn't worth the amount of time FOR THIS project I was just hoping against hope that I could find an easier way.

      Thanks for you expert knowledge.
      Curt

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      637 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X