Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Outputting static value from indicator

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

    Outputting static value from indicator

    Hi,

    If I wanted to output a static value if a condition in an indicator is true is this possible? e.g. create an indicator and output a static value of 1 when below is true....

    if (EMA(20)[0] > EMA(20)[60])
    output 1

    To add context it is to create signals within market analyzer when certain conditions are true.

    Thanks
    Tim

    #2
    Hello Tim,

    The Market Analyzer uses the Plot to display the number inside of the Column, so you would want to set the Plot value to 1 when your condition is true inside of a Custom Indicator file.

    For example:
    Code:
    protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                Overlay				= false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Checks to make sure there is atleast 81 bars worth of data before calculating 
                //  so that there is enough data.
                if(CurrentBar < 81)
                {
                       return;
                }
                // Use this method for calculating your indicator values. Assign a value to each
                if (EMA(20)[0] > EMA(20)[60])
                {
                     Plot0.Set(1);
                }
                else
                {
                     Plot0.Set(0);
                }
            }
    JCNinjaTrader Customer Service

    Comment


      #3
      Many thanks for the quick response - that worked perfectly.

      Tim

      Comment


        #4
        Originally posted by tdouglas View Post
        Hi,

        If I wanted to output a static value if a condition in an indicator is true is this possible? e.g. create an indicator and output a static value of 1 when below is true....

        if (EMA(20)[0] > EMA(20)[60])
        output 1

        To add context it is to create signals within market analyzer when certain conditions are true.

        Thanks
        Tim
        If you do not want to plot that value, but just want to use it as a trendfilter that can be accessed by other indicators or strategies, you can also use an IntSeries() object to hold those values. You can set the output to 1, if the condition is true, to -1 if the opposite is true, and to 0, if both EMAs are equal.

        Comment


          #5
          Thanks Harry - I'll take a look at that too.

          Tim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 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
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X