Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using a custom indicator in Strategy Builder

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

    Using a custom indicator in Strategy Builder

    Hello,

    I have a custom indicator. The basic logic is this:

    protected override void OnBarUpdate()
    {

    Trend[0] = 0;
    if (Value[0] > Value[1])
    Trend[0] = 1;
    else if (Value[0] < Value[1])
    Trend[0] = -1;
    Print(Trend[0]);
    }


    So in my output box i get either a 1 or -1 every time the bar updates. That all works well. My question is what can I add to the code so that when I call this indicator through the strategy builder I can go long for 1 and short for -1. Or do I have to copy this code and variable into a strategy? See the attached pic for a visual explanation.

    #2
    Hello evanp90,

    Thanks for your post.

    To be able to read the +1/0/-1 signal, you would need to provide a plot from the indicator to the strategy builder (Tip: would also work in the Market analyzer).

    If "Trend" is not already a plot, you could certainly add a plot and assign the same values. The plot can be used with a "Transparent" brush meaning it would not visibly show on a chart but its value would still be available to the strategy builder (or market analyzer). For an example of using a transparent plot to provide an input to either the strategy builder or the market analyzer you can review the coding for the indicator "CandleStick Pattern" in your NinjaTrader. In addition here is a link to a thread showing the process in a video: http://ninjatrader.com/support/forum...762#post453762

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X