Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

something in the strategy won't work for some reason

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

    something in the strategy won't work for some reason

    Hello I've tried to create a very simple strategy for plotting arrows up and down when cci is crossing 0 but I don't get any of the arrows for some reason, could you please help
    thank you.

    #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>
    /// My First testing strategy
    /// </summary>
    [Description("My First testing strategy")]
    public class MyCustomStrategy : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int turbo = 6; // Default setting for Turbo
    // 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(CCI(6),0, 1))
    {
    DrawArrowUp("My up arrow" + CurrentBar, false, 0, 6, Color.Lime);
    }

    // Condition set 2
    if (CrossBelow(CCI(6),0, 1))
    {
    DrawArrowDown("My down arrow" + CurrentBar, false, 0, 6, Color.Red);
    }
    }

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

    #2
    Hello,
    I have tested the strategy and it appears that the matter is the arrows are drawing however they are drawing at the value of 6. To have them plot on the price you can replace the double value with Close[0] for example.
    I have included an example of this below.
    Code:
    // Condition set 1
    if (CrossAbove(CCI(6),0, 1))
    {
    DrawArrowUp("My up arrow" + CurrentBar, false, 0, Close[0], Color.Lime);
    }
    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply but I tried and still I don't get my arrows on the screen
      all I'm trying to get at this stage is an arrow when cci crosses the 0 line up and down
      and it's sounds very simple but the result is far from what I expect

      Comment


        #4
        Hello,
        As a test please change the bool for autoscale on the draw objects from false to true.
        Code:
        // Condition set 1
        if (CrossAbove(CCI(6),0, 1))
        {
        DrawArrowUp("My up arrow" + CurrentBar, true, 0, Close[0], Color.Lime);
        }
        Do you see the arrow plot anywhere?
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          first I see no arrows
          2nd I is there a way to open a saved strategy in strategy wizard again or do I have to edit the strategy from the code like every indicator once it's saved?

          Comment


            #6
            Hello,
            If you unlocked the code you will need to edit it from the NinajScript Editor. There is not a method to lock the code again.
            Can you export the strategy so I may fully investigate what is occurring?
            You can attach your indicator to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your Indicator > select the right arrow > Export.
            The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Thank you for your help, I mean it

              here is the script
              Attached Files

              Comment


                #8
                Hello,
                I am seeing that the strategy is correct. I have attached a screenshot of the chart on my end. I changed the errors to pink and blue as the red and green were harder to see.
                If you are not seeing the errors at all on your chart I would recommend to remove the strategy from the chart and add in again.
                Click image for larger version

Name:	10-9-2015 3-36-17 PM.png
Views:	1
Size:	35.1 KB
ID:	874971
                Cody B.NinjaTrader Customer Service

                Comment


                  #9
                  thank you how do I plot the arrows bit higher
                  thank you for your effort

                  Comment


                    #10
                    Hello,
                    To plot them higher or lower you will increase the double value. One method to do this would be to have the double y value of the Draw object be the High of the bar + a number of ticks.
                    For example:
                    Code:
                    // Condition set 1
                    if (CrossAbove(CCI(6),0, 1))
                    {
                    DrawArrowUp("My up arrow" + CurrentBar, true, 0, High[0] + 2 * TickSize, Color.Lime);
                    }
                    This will plot the up arrow at the High of the bar + 2 ticks.

                    If we can be of any other assistance please let us know.
                    Cody B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by pechtri, 06-22-2023, 02:31 AM
                    9 responses
                    122 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by frankthearm, 04-18-2024, 09:08 AM
                    16 responses
                    66 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by habeebft, Today, 01:18 PM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by benmarkal, Today, 12:52 PM
                    2 responses
                    14 views
                    0 likes
                    Last Post benmarkal  
                    Started by f.saeidi, Today, 01:38 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X