Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Create simple indicator

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

    Create simple indicator

    Hello! I've got 2 indicators, I need to combine them in one, just indicator1/Indicator2 and calculate average value for "n" periods, "n" I set up by myself.

    P.S.: I'm not a professional programmer, it's better to explain me step by step.

    Thanks!

    #2
    Hello U0000999,

    To do that you would need to create a third indicator with a Plot.

    If you have not programmed NinjaScript before it would be difficult to explain step by step what to do for custom indicators, You can however use the strategy builder to gather the syntax needed for your custom indicators.
    1. from the control center go to New -> Strategy builder.
    2. Open the Conditions and actions page
    3. Click Add in the bottom actions section of the window
    4. Select Misc -> Print
    5. Hover the mouse over message and click Set
    6. Select Indicator -> Your custom indicator 1
    7. After adding the action repeat these steps again to add a second action of printing indicator 2.
    8. Click View code

    That will generate the basic variables for the indicators and their syntax in OnBarUpdate.

    You should see something similar to:

    Code:
    Print(myIndicator1);
    Print(myIndicaotr2);
    Leave the strategy open so you can copy code from the file as needed
    In a new NinjaScript editor window, right click the indicators folder and choose new indicator. Give the indicator a name and then on the Plots page add a plot.
    After generating the file you should see a similar structure to what the strategy has.

    From the strategy you will need to copy the variables for myIndicator1 and 2 into the indicator in the same location, it needs to look the same. You should also see some extra code related to the indicators in the OnStateChange override, that needs copied to the indicator as well.

    Finally in OnBarUpdate to divide the indicators and plot the result it would look like:

    Code:
    Value[0] = myIndicator1[0] / myIndicator2[0];
    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    581 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    338 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X