Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

VWAP adapt

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

    VWAP adapt

    Wanted to make this indicator but not getting anything in the chart.

    Basis are the following:
    input name input description
    VWAP period type VWAP period type
    Multiplier Std Dev multiplier
    Extend VWAP Extend VWAP previous period
    Extend stddev #1 Extend standard deviation number 1
    Extend stddev #2 Extend standard deviation number 2
    Extend stddev #3 Extend standard deviation number 3
    Extend stddev #4 Extend standard deviation number 4
    Set all colors Set colors automatically
    Based on input only Computation based on input only (no volume)


    ------------------------------------------------------

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    using System;
    using System.ComponentModel;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {

    /// <summary>
    /// VWAP-based indicator with customizable inputs.
    /// </summary>
    [Description("VWAP-based indicator with customizable inputs.")]
    public class TSVWAP : Indicator
    {

    public class TSVWAP1 : Indicator
    {

    region Variables

    private int vwapPeriodType = 0; // 0 = Standard VWAP, 1 = Volume Weighted VWAP
    private double stdDevMultiplier = 2.0;
    private bool extendVWAP = false;
    private double extendStdDev1 = 0.0;
    private double extendStdDev2 = 0.0;
    private double extendStdDev3 = 0.0;
    private double extendStdDev4 = 0.0;
    private bool computationBasedOnInputOnly = false;

    #endregion

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "TSVWAP";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = true;

    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    AddPlot(Brushes.Blue, "MyVWAP");
    AddPlot(Brushes.Red, "UpperBand");
    AddPlot(Brushes.Green, "LowerBand");

    // AddInput<int>(vwapPeriodType, "VWAP Period Type");
    // AddInput<double>(stdDevMultiplier, "Standard Deviation Multiplier");
    // AddInput<bool>(extendVWAP, "Extend VWAP Previous Period");
    // AddInput<double>(extendStdDev1, "Extend StdDev #1");
    // AddInput<double>(extendStdDev2, "Extend StdDev #2");
    // AddInput<double>(extendStdDev3, "Extend StdDev #3");
    // AddInput<double>(extendStdDev4, "Extend StdDev #4");
    // AddInput<bool>(computationBasedOnInputOnly, "Computation Based on Input Only (No Volume)");
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    }
    }
    }

    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private TSVWAP[] cacheTSVWAP;
    public TSVWAP TSVWAP()
    {
    return TSVWAP(Input);
    }

    public TSVWAP TSVWAP(ISeries<double> input)
    {
    if (cacheTSVWAP != null)
    for (int idx = 0; idx < cacheTSVWAP.Length; idx++)
    if (cacheTSVWAP[idx] != null && cacheTSVWAP[idx].EqualsInput(input))
    return cacheTSVWAP[idx];
    return CacheIndicator<TSVWAP>(new TSVWAP(), input, ref cacheTSVWAP);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.TSVWAP TSVWAP()
    {
    return indicator.TSVWAP(Input);
    }

    public Indicators.TSVWAP TSVWAP(ISeries<double> input )
    {
    return indicator.TSVWAP(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.TSVWAP TSVWAP()
    {
    return indicator.TSVWAP(Input);
    }

    public Indicators.TSVWAP TSVWAP(ISeries<double> input )
    {
    return indicator.TSVWAP(input);
    }
    }
    }

    #endregion

    #2
    Hello carlosgutierrez,

    The code you posted is not doing anything so you shouldn't see anything in the chart. That only has some variables defined however i see something used which is not valid which is AddInput. If you used a third party tool to generate code for you, for example a tool like chatgpt keep in mind most external tools cannot correctly generate NinjaScript code.

    If you are trying to make a new indicator I would suggest to create a new indicator using the NinjaScript editor and use the wizard to set up the plots. Then see the following help guide section that goes over Plotting



    To set a plot you need to do that in OnBarUpdate:


    Once you know what calculation you want to do you would write that logic in the OnBarUpdate override and set a value to the plot.

    Comment

    Latest Posts

    Collapse

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