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

Limit order exectution

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

    Limit order exectution

    is there a quick and dirty way to do this?

    the previous bar is down... current bar closes up
    place limit order to buy at the close of the car - 2 ticks... same for the short side

    OR

    since im using range bars i know where a up bar will be so i can do it like this

    place limit order once a level is hit (level - 2 ticks)

    Thank you

    #2
    Hello gerald560,

    Thank you for your note.

    Yes, this would be possible. You could use the strategy builder, to pull this up go to Control Center>New>Strategy Builder.

    You would define the previous bar being a down bar like I’ve done in screen shot 1. You would then need to build another statement which would define the current bar being an up bar (higher than the previous bar).

    For the action, you’d use Order Management>Enter long position by limit order> Limit price you’d set to close and use a tick offset of -2, like the second screen shot I’ve provided. This will submit a limit market order 2 ticks below the current bars close.

    I would suggest watching the strategy builder webinar for NT7, which works very much like NT8, for getting familiar with building strategies using a wizard in NinjaTrader.

    Youtube: https://www.youtube.com/watch?v=FmBi...D7105&index=10

    Also see NT8 Strategy builder helpguide,
    NT8 Helpguide: http://ninjatrader.com/support/helpG...on_builder.htm

    Regarding your price level question. Yes, you could build a condition which checks if the current price equals your level, and if so submit a limit order 2 ticks from that level. For this, you’d create a variable on the Inputs and Variables prompt, see screen shot. Then within your condition you’d check if price was equal to that level.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      That worked great Alan thank you...One more question, when a trade is triggered a limit order is placed however if another bar comes through that order gets canceled ... how can I make it so that the order does not get canceled until I cancel it?

      Current Code

      HTML Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.Indicators;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion
      
      //This namespace holds Strategies in this folder and is required. Do not change it. 
      namespace NinjaTrader.NinjaScript.Strategies
      {
      	public class MyCustomStrategy1 : Strategy
      	{
      		protected override void OnStateChange()
      		{
      			if (State == State.SetDefaults)
      			{
      				Description									= @"Enter the description for your new custom Strategy here.";
      				Name										= "MyCustomStrategy1";
      				Calculate									= Calculate.OnBarClose;
      				EntriesPerDirection							= 1;
      				EntryHandling								= EntryHandling.AllEntries;
      				IsExitOnSessionCloseStrategy				= true;
      				ExitOnSessionCloseSeconds					= 30;
      				IsFillLimitOnTouch							= false;
      				MaximumBarsLookBack							= MaximumBarsLookBack.TwoHundredFiftySix;
      				OrderFillResolution							= OrderFillResolution.Standard;
      				Slippage									= 0;
      				StartBehavior								= StartBehavior.WaitUntilFlat;
      				TimeInForce									= TimeInForce.Gtc;
      				TraceOrders									= false;
      				RealtimeErrorHandling						= RealtimeErrorHandling.StopCancelClose;
      				StopTargetHandling							= StopTargetHandling.PerEntryExecution;
      				BarsRequiredToTrade							= 20;
      				// Disable this property for performance gains in Strategy Analyzer optimizations
      				// See the Help Guide for additional information
      				IsInstantiatedOnEachOptimizationIteration	= true;
      			}
      			else if (State == State.Configure)
      			{
      				SetProfitTarget("order1", CalculationMode.Ticks, 20);
      				SetProfitTarget("order2", CalculationMode.Ticks, 60);
      				SetStopLoss("order1", CalculationMode.Ticks, 11, false);
      				SetStopLoss("order2", CalculationMode.Ticks, 11, false);
      			}
      		}
      
      		protected override void OnBarUpdate()
      		{
      			if (CurrentBars[0] < 2)
      			return;
      
      			 // Set
      			if ((Close[2] > Close[1])
      				 && (Close[0] > Close[1]))
      			{
      				EnterLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0] + (-1 * TickSize)) , "order1");
      				EnterLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0] + (-1 * TickSize)) , "order2");
      			}
      			
      		}
      	}
      }
      
      :
      Last edited by gerald560; 02-12-2017, 08:29 PM.

      Comment


        #4
        Hello gerald560,

        You would want to use the following syntax, setting isLiveUntilCanclled to true.

        Code:
        EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)
        So for example,

        Code:
        EnterLongLimit(0, true, 1, (Close[0] + (-1 * TickSize)), "order1”)
        See EnterLongLimit section of our helpguide,


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hi Alan,

          Thank you for helping, one more condition - I want it to only to take long trades when there has been 3 up days (daily bars RTH) followed by 1 down day (currently using intra day bars so need a daily time frame to access it) ... wondering how to do that in this intra day strategy?
          Last edited by gerald560; 02-15-2017, 12:18 PM.

          Comment


            #6
            Hello gerald560,

            I would suggest the following reference example,

            Strategy: Entering on one time frame and exiting on another.


            You would add the following under State.Configure for a daily series.

            Code:
            AddDataSeries(BarsPeriodType.Day, 1);
            And refer to that secondary data series with Closes[1][0] for the current bar of the secondary data series. Also Opens[1][0] for the open of the secondary bar series.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by techgetgame, Yesterday, 11:42 PM
            0 responses
            8 views
            0 likes
            Last Post techgetgame  
            Started by sephichapdson, Yesterday, 11:36 PM
            0 responses
            2 views
            0 likes
            Last Post sephichapdson  
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,613 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Yesterday, 05:56 PM
            0 responses
            10 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            20 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X