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

buy line,sell line autotrading

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

    buy line,sell line autotrading

    Hello dear forum

    I want to programm a ninjascript auto trader.

    I start script and see two blue horizontal lines a buy line and a sell line.
    I can move lines with mouse up and down but buy line > sell line is clear.
    I have a button for start/stop trading.

    If ask price goes over buy line then close all orders and entry long order.
    contractnumber = contractnumber*2; count++;

    If bid price goes under sell line then close all orders and entry short order.
    contractnumber = contractnumber*2; count++;

    if ( count == 6 ) close all and stop is better

    Can anyone give me some hints / examples for programming this.
    I have the following code for the wizzard but it crashed.


    Code:
    #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>
        /// Egal
        /// </summary>
        [Description("Egal")]
        public class my002Test : Strategy
        {
            #region Variables
            // Wizard generated variables
            private int buyline = 1; // Default setting for Buyline
            private int sellline = 1; // Default setting for Sellline
            private int myQuantity = 1; // Default setting for MyQuantity
            private int extra2 = 1; // Default setting for Extra2
            // 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 (GetCurrentAsk() >= Buyline)
                {
                    EnterLongLimit(MyQuantity, MyQuantity+3, "");
                    MyQuantity*=2;
                }
    
                // Condition set 2
                if (GetCurrentBid() <= Sellline)
                {
                    EnterShortLimit(MyQuantity, MyQuantity-3, "");
                    MyQuantity*=2;
                }
            }
    
            #region Properties
            [Description("")]
            [GridCategory("Parameters")]
            public int Buyline
            {
                get { return buyline; }
                set { buyline = Math.Max(1, value); }
            }
    
            [Description("")]
            [GridCategory("Parameters")]
            public int Sellline
            {
                get { return sellline; }
                set { sellline = Math.Max(1, value); }
            }
    
            [Description("")]
            [GridCategory("Parameters")]
            public int MyQuantity
            {
                get { return myQuantity; }
                set { myQuantity = Math.Max(1, value); }
            }
    
            [Description("")]
            [GridCategory("Parameters")]
            public int Extra2
            {
                get { return extra2; }
                set { extra2 = Math.Max(1, value); }
            }
            #endregion
        }
    }

    #2
    Hello,

    Thank you for the question.

    For what you want, it would actually be fairly complicated due to involving the mouse moving lines and button to enable and disable trading. In addition this would require manual coding, the wizard would not be capable of making this type of item.

    The wizard is mainly capable of comparing conditions to place entries or exists, and appending Stops and targets to those entries. Creating custom content or involving the mouse at all would require custom programming unfortunately. If you would like to manually program this item, I could suggest some starting points but there would not be any specific guide or tutorial for the items you are asking. Alternatively if you do not want to create this yourself, I could have our business development department comment on third party developers.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by agclub, 04-21-2024, 08:57 PM
    4 responses
    18 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Irukandji, Today, 04:58 AM
    0 responses
    3 views
    0 likes
    Last Post Irukandji  
    Started by fitspressoburnfat, Today, 04:25 AM
    0 responses
    2 views
    0 likes
    Last Post fitspressoburnfat  
    Started by Skifree, Today, 03:41 AM
    1 response
    4 views
    0 likes
    Last Post Skifree
    by Skifree
     
    Started by usazencort, Today, 01:16 AM
    0 responses
    1 view
    0 likes
    Last Post usazencort  
    Working...
    X