Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trouble with script

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

    Trouble with script

    Trying to make a custom indicator and having problems trying to compile. The errors seem to be related to VWAP, which is one of the indicators used. I do have access to order flow and use VWAP on some of my charts. Can anyone help here ?

    // Indicator: Daily Direction Bias Analyzer (Final - Order Flow VWAP Corrected for NinjaTrader 8)

    using System;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.OrderFlow; // Correct namespace for OrderFlowVWAP
    using NinjaTrader.NinjaScript.DrawingTools;
    using System.Windows.Media;

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class DailyDirectionBiasIndicator : Indicator
    {
    private EMA ema9, ema21, ema50, ema200;
    private OrderFlowVWAP vwap;
    private MACD macd;

    private double preMarketHigh = 0;
    private double preMarketLow = double.MaxValue;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = "Displays daily directional bias (Bullish/Bearish) based on trend, VWAP, MACD, and pre-market breakout.";
    Name = "DailyDirectionBiasIndicator";
    IsOverlay = true;
    Calculate = Calculate.OnBarClose;
    }
    else if (State == State.DataLoaded)
    {
    ema9 = EMA(9);
    ema21 = EMA(21);
    ema50 = EMA(50);
    ema200 = EMA(200);
    macd = MACD(12, 26, 9);
    vwap = OrderFlowVWAP(); // Correct instantiation
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 50)
    return;

    // Pre-market high/low from 8:30 to 9:29 EST
    if (ToTime(Time[0]) >= 83000 && ToTime(Time[0]) <= 92900)
    {
    preMarketHigh = Math.Max(preMarketHigh, High[0]);
    preMarketLow = Math.Min(preMarketLow, Low[0]);
    }

    // EMA alignment
    bool emaStackBullish = ema9[0] > ema21[0] && ema21[0] > ema50[0];
    bool emaStackBearish = ema9[0] < ema21[0] && ema21[0] < ema50[0];

    // VWAP position
    bool priceAboveVWAP = Close[0] > vwap.VWAP[0];
    bool priceBelowVWAP = Close[0] < vwap.VWAP[0];

    // MACD direction
    bool macdBullish = macd.Diff[0] > 0 && macd.Diff[0] > macd.Diff[1];
    bool macdBearish = macd.Diff[0] < 0 && macd.Diff[0] < macd.Diff[1];

    // Signal logic
    if (emaStackBullish && priceAboveVWAP && macdBullish && Close[0] > preMarketHigh)
    {
    Draw.Text(this, "BullBias" + CurrentBar, " BULLISH BIAS", 0, High[0] + TickSize * 10, Brushes.LimeGreen);
    &nbs; }
    else if (emaStackBearish && priceBelowVWAP && macdBearish && Close[0] < preMarketLow)
    {
    Draw.Text(this, "BearBias" + CurrentBar, " BEARISH BIAS", 0, Low[0] - TickSize * 10, Brushes.Red);
    }
    }
    }
    }

    #2
    Hello Traydar,

    Please note the sticky at the top of this archived forum landing page.

    We have moved! The legacy forum is now in view‑only mode and existing posts will remain accessible for reference, but no new threads or replies can be added. Join the conversation on our new NinjaTrader Community Forums and read our frequently asked questions to learn more.


    If you would like this inquiry to be to the NinjaTrader community, please join our new discourse forum and create a new post.
    This forum provides an outlet for our user community to interact with our technical support team and fellow traders. For additional interactive training resources, be sure to check out our Free Daily Webinars and Video Library.


    If you would like assistance from NinjaTrader Support team, please send an email to scriptingsupport [at] ninjatrader.com.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      [QUOTE=NinjaTrader_ChelseaB;n1343034]Hello Traydar,

      Please note the sticky at the top of this archived forum landing page.



      If you would like this inquiry to be to the NinjaTrader community, please join our new discourse forum and create a new post.
      This forum provides an outlet for our user community to interact with our technical support team and fellow traders. For additional interactive training resources, be sure to check out our Free Daily Webinars and Video Library.


      Hi NinjaTrader_ChelseaB

      I know this page is history. But I am having problem to Log In to the new discourse page and can not post my issues. I have my account migrated and use the latest multiboker Lifetime license signing with my new credetials to enter the new Discourse forum. The Log In does not work. It seems to log in but immidiately jumps back to Log In page and freezes. I can not Sign In or Log In using the social media either.

      I am using Google Chrome for internet, is there a limitation here? Any idea?

      Thanks.
      Last edited by aligator; 06-03-2025, 11:22 PM.

      Comment


        #4
        Hello aligator,

        Please check you are allowing cookies in your browser.

        Then please send an email to clientservices [at] ninjatrader.com so our staff may assist with getting you logged in.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        607 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        353 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X