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

simple strategy question ?

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

    simple strategy question ?

    Hi support. working with ninja 7 trying my hand at strategy building.
    first project. is show a green arrow above current bar when bid exceeds upper bollinger band.
    strategy seemed to compile ok, and i was able to apply it to my chart.

    here is the code. do you see what is not correct.?
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class BlineTradingStrategy : 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 (GetCurrentBid() >= Bollinger(2, 22).Upper[0])
    {
    DrawArrowUp("My up arrow" + CurrentBar, true, 0, 0, Color.Lime);
    }
    }

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

    #region Wizard settings, neither change nor remove
    /*@
    <?xml version="1.0" encoding="utf-16"?>
    <NinjaTrader>
    <Name>BlineTradingStrategy</Name>
    <CalculateOnBarClose>True</CalculateOnBarClose>
    <Description>Enter the description of your strategy here</Description>
    <Parameters>
    <Parameter>
    <Default1>
    </Default1>
    <Default2>1</Default2>
    <Default3>
    </Default3>

    #2
    Originally posted by lightfoot500 View Post
    Hi support. working with ninja 7 trying my hand at strategy building.
    first project. is show a green arrow above current bar when bid exceeds upper bollinger band.
    strategy seemed to compile ok, and i was able to apply it to my chart.

    here is the code. do you see what is not correct.?
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class BlineTradingStrategy : 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 (GetCurrentBid() >= Bollinger(2, 22).Upper[0])
    {
    DrawArrowUp("My up arrow" + CurrentBar, true, 0, 0, Color.Lime);
    }
    }

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

    #region Wizard settings, neither change nor remove
    /*@
    <?xml version="1.0" encoding="utf-16"?>
    <NinjaTrader>
    <Name>BlineTradingStrategy</Name>
    <CalculateOnBarClose>True</CalculateOnBarClose>
    <Description>Enter the description of your strategy here</Description>
    <Parameters>
    <Parameter>
    <Default1>
    </Default1>
    <Default2>1</Default2>
    <Default3>
    </Default3>
    Why do you think that anything is wrong? You have not described any issue.

    Comment


      #3
      Hi Koganam, sorry, I am not getting any markers to show up on my chart.. i want it to "print" the arrows on the chart when price goes outside the upper Bollinger band..

      update,, i clicked the enable on the properties and now i have my green arrows. but they are not located just above the bar that has crossed the bb.. they seem to locate at the "0" line on the chart. and price us up at the 1690's ,, how do i make the arrows print just above the high of the bar that crosses the bollinger band?? thanks
      Last edited by lightfoot500; 08-11-2013, 03:19 PM.

      Comment


        #4
        Originally posted by lightfoot500 View Post
        Hi Koganam, sorry, I am not getting any markers to show up on my chart.. i want it to "print" the arrows on the chart when price goes outside the upper Bollinger band..
        You need to make sure that your drawings are on the correct panel. Look up DrawOnPricePanel.

        ref: http://www.ninjatrader.com/support/h...pricepanel.htm

        Comment


          #5
          Hello lightfoot500,

          Thank you for your post.

          I tested the code and the indicator works on my end. Set your indicator to AutoScale = true and then scroll through the chart, you should see the Green Arrow drawn.

          Only item I noticed is you set the DrawArrow() to a y value of 0, that is 0 on the chart for price. Try the following instead:
          Code:
          DrawArrowUp("My up arrow" + CurrentBar, true, 0, Low[0] - (2 * TickSize), Color.Lime);
          Please let me know if I may be of further assistance.
          Last edited by NinjaTrader_PatrickH; 08-11-2013, 05:09 PM.

          Comment


            #6
            Koganam, i am not seeing how i can apply the indicator you mention, "draw on price panel' in the strategy setup on ninja.. i am in the conditions and actions on the Edit Strategy Wizard.. i have set my condition and now want the following action" Do the following" step.. which is to draw an up arrow an the current bar which price exceeds the bollinger band... but as i say it now seems to be printing at the "0" line of the price chart..
            thanks

            Comment


              #7
              thanks patrick, that 's got it working.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by haas88, 03-21-2024, 02:22 AM
              18 responses
              208 views
              0 likes
              Last Post haas88
              by haas88
               
              Started by Board game geek, Today, 02:20 AM
              0 responses
              1 view
              0 likes
              Last Post Board game geek  
              Started by knighty6508, Today, 01:20 AM
              2 responses
              14 views
              0 likes
              Last Post knighty6508  
              Started by franatas, Today, 01:53 AM
              0 responses
              2 views
              0 likes
              Last Post franatas  
              Started by knighty6508, Today, 01:17 AM
              0 responses
              9 views
              0 likes
              Last Post knighty6508  
              Working...
              X