Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Total Slope for 3 Oscillators Indicator

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

    Total Slope for 3 Oscillators Indicator

    Greetings Team,

    I'm trying to code an indicator that prints the slope of three oscillators and colors the chart background if the total is greater than a certain number.

    For example, lets say the indicator has three CCIs with periods 10, 20 and 40 in one panel.
    How can I code this indicator to display the total slope for all three lines on the chart or in the panel? In other words, I want the indicator to add the slope of all three lines and print that total somewhere on the chart.

    If that total is greater than a given number X (let's say 10, for example), I want it to draw background: {BackBrush = Brushes.CornflowerBlue;}. The draw object isn't important. I'm trying to learn how to program functions using that slope total. (I've been asking the AIs and getting nowhere!)

    I understand that the slope needs to be measured over a given distance. Let's specify slope length of 3 bars, the present bar and two bars in the past.



    Thank you for your help!
    Matt


    Below is what I believe to be the relevant/useful CCI code for your reference.
    The Set 1 Function colored red is nonsense - I'm not sure how to help more:


    else if (State == State.DataLoaded)
    {
    CCI1 = CCI(Close, 10);
    CCI2 = CCI(Close, 20);
    CCI3 = CCI(Close, 40);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 3)
    return;

    // Set 1

    if (
    (Slope(CCI1, 10, 3) > 0)
    && (Slope(CCI2, 20, 3) > 0)
    && (Slope(CCI3, 40, 3) > 0)
    )


    {
    BackBrush = Brushes.CornflowerBlue;
    }​

    #2
    Hello Tagliareni,

    Just as a heads up I have included a disclaimer about using AI below, we suggest avoiding those type of tools at this time.

    The slope in NinjaTrader will report different values for each instrument so to use those values you will need to use Print statements to see what the values are in that specific use case. You can then form the condition based on the observed results. We have a guide that goes over how to use print statements and the output window in the following link.



    From our experience at this time, ChatGpt and other AI models are not quite adequate to generate valid compilable NinjaScripts that function as the user has intentioned. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor.

    While it would not be within our support model to correct these scripts at user request, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

    Comment


      #3
      I'll check it out. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      650 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      577 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X