Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator/Strategy Question Again

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

    Indicator/Strategy Question Again

    Hi,
    Well I thought I understood how to add a variable inside a indicator then access it from a strategy, but I guess I am still confused. Listed beow is the indicator code adding the variable inside an indicator. Also listed it the code generated from the strategy wizard then modified to access the variable. I am getting a error CS200 and CS0029 when I try to reference the variable. In the strategy wizard I do not see access to the variable I added so I unlocked the code and tried to do it manually. When a variable is added in an indicator what allows it to ben see in the strategy wizard to enure a script is generated correctly ?
    Any help would be greatly appreciated.
    Thanks

    // Defined The Varaible
    private int aSignalStatus = 0;

    // Set The Value Of The Variable When A Condition Is Met
    aSignalStatus = 2;

    // Added This In The Properties Area AT The End Of The Indicator
    // Is This The Area That Exposes The Variable ???

    [Browsable(false)]
    [XmlIgnore()]
    public int SignalStatus
    {
    get { return aSignalStatus; }
    }



    // Strategy Code

    // Condition set 1
    if (MyIndicator(21, 12, 3, 4, 1, false, 1).SignalStatus = 1)
    {
    EnterLong(DefaultQuantity, "Long");
    }

    // Condition set 2
    if (MyIndicator(21, 12, 3, 4, 1, false, 1).SignalStatus == 2)
    {
    EnterShort(DefaultQuantity, "Short");
    }

    #2
    Hello,

    Did you take a look at this reference sample that shows how to do this?



    Let me know if this gets you headed in the right direction. Also below in your code I notice you only have one = sign in one of your if statements.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thanks

      Hi Bret,
      Thanks for the help. I did study the reference examples posted. In the data series example it does not really show wat part of the code goes in the indicator and what part goes in the strategy. I guess I will keep digging into the help file till I can piece all this together. I am a old embedded C programmer and the whole OO philosophy is not reallly smething I have ever tried to grasp. I guess I am a glass half empty type and the OO world is glass half full. To me this seems way too complicated just to access a simple variable value.
      Thanks

      Comment


        #4
        Widgetman, easist would be just accessing a plot from an indicator, this is auto exposed that means the strategy wizard could directly access it. Any internal dataseries / variable needs to be exposed with custom code properly as Brett already suggested by showing you the sample.

        Comment


          #5
          Thanks

          Thanks for the info guys,
          I figured out I had to put in a Add(MyIndicator)) line of code to start seeing my strategy triggers show up on the chart. Is there an easy way to plot the value of the variable I am using as a trigger on the screen as well ?
          Thanks

          Comment


            #6
            Are you wanting to plot it in the Chart as a PlotStyle such as a line or in a subgraph or are you wanting to just have text draw on the chart the variable? Can you further clarify so that I may further assist?
            BrettNinjaTrader Product Management

            Comment


              #7
              Chart Text

              Hi,
              I would like to print the value of the variable I am using as a trigger for the strategy on my chart when the trigger condition fires.
              Thanks

              Comment


                #8
                Hello,

                If your looking to print the variable on the chart you can do this using DrawTextFixed()



                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X