Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Help with execution issue - logical fail

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

    Help with execution issue - logical fail

    Hey there,

    1.- bwAO - this is the whole thing below (really short).... What method do I call upon to process AddChartIndicator for this? I understand it's just median SMA differences on every bar update...But WOULD be very pleasant to add this to the strategy chart.

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    // Changes from Nt7:
    // - reduce to 1 plot for the histogram bar then color the bar (was previously 2 colored plots per bar).
    // - Used IsRising to color bars instead of calculating difference from first tick.
    // Converted to NT8beta5

    public class bwAO : Indicator
    {
    private double ao = 0; // SMA difference

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Awesome Oscillator Technical Indicator (AO) is a 34-period simple moving average, plotted through the middle points of the bars (H+L)/2, which is subtracted from the 5-period simple moving average, built across the central points of the bars (H+L)/2. It shows us quite clearly what’s happening to the market driving force at the present moment.";
    Name = "bwAwesomeOscillator";
    Calculate = Calculate.OnEachTick; //compatibility with NT7 version
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = false;

    AddPlot(new Stroke(Brushes.Gray, 6), PlotStyle.Bar, "AOBarPlot");
    AddPlot(Brushes.Transparent, "AOLinePlot");
    AddLine(Brushes.Black, 0, "ZeroLine");
    }
    }

    protected override void OnBarUpdate()
    {
    ao = SMA(Median,5)[0] - SMA(Median,34)[0]; // Get SMA difference

    AOBarPlot[0] = ao; // plot the bar histogram
    AOLinePlot[0] = ao; // plot the line on top of the histogram

    if (IsRising(AOBarPlot)) // Color Bar based on Current value to initial value
    {
    PlotBrushes[0][0] = Brushes.Green;
    }
    else
    {
    PlotBrushes[0][0] = Brushes.Red;
    }
    }

    #region Properties

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> AOBarPlot
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> AOLinePlot
    {
    get { return Values[1]; }
    }

    #endregion

    }
    }

    #region NinjaScript generated code. Neither change nor remove.

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

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

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

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

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

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

    #endregion
    #region NinjaScript generated code. Neither change nor remove.

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

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

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

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

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

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

    #endregion
    Last edited by lmatiukas; 07-06-2016, 02:50 PM.

    #2
    Hello lmatiukas,

    Thanks for your post.

    Please note that Ninjatrader 8 related posts should be placed in the Ninjatrader 8 beta forum so that we can track any beta specific issues as well as to keep the forums organized and less confusing if someone is looking for an NT7 solution or an NT8 solution.

    To add the indicator to your strategy: AddChartIndicator (bwAO());

    I'm not sure if you are creating the indicator but if you are not aware it is available in the NT8 indicator file sharing area: http://ninjatrader.com/support/forum...?=7&linkid=683
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      hey there,

      yep it's one of your indicators, and a really simple one I might add. I've got the strategy portion of it linking easy to my executions, but I wanted to get it drawn on the lower field in the strategy charts.

      Your suggestion is what I had tried first:
      -->AddChartIndicator (bwAO());
      Getting 1.pdf errors

      Everything is linked properly, I get values printed out properly, and I'm able to execute a strategy where if current value is positive and increasing over the last three bars for example, buy, and so on.

      Just would be really nice to get it drawn on there.

      It's somewhat a strategy question, since it's putting an indicator chart on there, even if I don't have an issue with converting the factual indicator into a strategy,

      thanks for any suggestions
      Attached Files

      Comment


        #4
        Hello lmatiukas,

        Thanks for your reply.

        Based on the line number of the error message I am wondering if you are placing AddChartIndicator (bwAO()); in correct place. Are you adding it in the state.configure within OnStateChange()?

        IE:

        Code:
        			else if (State == State.Configure)
        			{
        				AddChartIndicator (bwAO());
        			}
        Reference: http://ninjatrader.com/support/helpG...tindicator.htm

        If you are unsure you can send your strategy to me at PlatformSupport[at]NinjaTrader[dot]Com with atten:Paul and a link to this thread in the subject line.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          thanks you sir

          S.o.B. I had a private variable defined in my strategy, same name as one in the bwAO, and so it caused an issue. The fault was given at the AddChart part, because that's where I referenced the method I suppose.

          After deleting the repeating variable it adds surprisingly easily.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Barry Milan, Yesterday, 10:35 PM
          5 responses
          16 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          13 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          12 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          8 views
          0 likes
          Last Post nandhumca  
          Working...
          X