• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer not purchasing at indicator

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

  • NinjaTrader_PatrickH
    replied
    Hello kodama78,

    Thank you for your response.

    Can you provide a screenshot of the chart tab in the Strategy Analyzer after running a test that shows where the strategy should have entered and where it actually entered?

    Leave a comment:


  • kodama78
    replied
    Script

    Hi Cal,

    Thank you for your reply. It's a real basic set up to buy when the MACD crosses over the 0 line and sell when the STO hits the overbought indicator.

    Script:

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Buy with MACD and sell with Sto ob/os signal
    /// </summary>
    [Description("Buy with MACD and sell with Sto ob/os signal")]
    public class MACDSto : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(MACD(12, 26, 9).Avg, 0, 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(MACD(12, 26, 9).Avg, 0, 1))
    {
    EnterShort(DefaultQuantity, "");
    }

    // Condition set 3
    if (Stochastics(7, 14, 3).D[0] > 0)
    {
    ExitLong("", "");
    }

    // Condition set 4
    if (Stochastics(7, 14, 3).D[0] < 8)
    {
    ExitShort("", "");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    Any help would be appreciated. The basic problem is that it doesn't buy when the indicator goes off and I'm not exactly sure why and neither is my friend who is a little more familiar with ninjatrader.

    Leave a comment:


  • NinjaTrader_CalH
    replied
    Hello Kodama78,

    Thank you for your post and welcome to the Forums!

    You can try setting the BarsRequired to 0 for the Strategy parameters when running the backtest.

    Also, would you mind sharing some of the script in what your conditions are for entering?

    Leave a comment:


  • kodama78
    started a topic Strategy Analyzer not purchasing at indicator

    Strategy Analyzer not purchasing at indicator

    Hello all,

    I'm very new to the software and have started using the strategy analyzer for SPY trades on a 3 minute chart.

    I set up a simple strategy so that when the MACD crosses the 0 line to initiate the buying of positions. However, whenever I run the test, I find that the backtester won't initiate the buy until about 4 bars in, which cuts into my profit and is not representative of when I would actually purchase. Would anyone know how I can fix this problem on my backtesting or if there is a setting that I'm missing. Any help would be greatly appreciated

Latest Posts

Collapse

Topics Statistics Last Post
Started by Da vinci, Today, 04:19 PM
1 response
10 views
0 likes
Last Post Emma1
by Emma1
 
Started by brunoviveiros, Today, 09:36 AM
1 response
21 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by GARZONJ, Today, 11:22 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Jesse  
Started by KonalGondal, Today, 10:18 AM
1 response
19 views
0 likes
Last Post NinjaTrader_Kate  
Started by Jorge.andres.o, Today, 09:24 AM
4 responses
24 views
0 likes
Last Post NinjaTrader_PaulH  
Working...
X