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

Scale Out Partials

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

    Scale Out Partials

    I would like to send 2 contracts with a target for the 1st and another target for the 2nd.

    I'm using ER2 06-07

    Here is the code that the wizard produced:



    #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.Strategy;

    #endregion

    // This namespace holds all strategies and is required. Do not change it.

    namespace
    NinjaTrader.Strategy

    {

    ///<summary>

    /// Scale out 1st target and 2nd target

    ///</summary>

    [Description(
    "Scale out 1st target and 2nd target")]

    [Gui.Design.DisplayName(
    "MultCars")]

    publicclass MultContracts : Strategy

    {

    #region Variables

    // Wizard generated variables

    // 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>

    protectedoverridevoid Initialize()

    {

    SetProfitTarget(
    "T1", CalculationMode.Ticks, 10);

    SetProfitTarget(
    "T2", CalculationMode.Ticks, 15);

    CalculateOnBarClose =
    true;

    }

    ///<summary>

    /// Called on each bar update event (incoming tick)

    ///</summary>

    protectedoverridevoid OnBarUpdate()

    {

    // Condition set 1

    if (ToDay(Time[0]) == ToDay(2007, 5, 3)

    && ToTime(Time[
    0]) > ToTime(7, 15, 0)

    && ToTime(Time[
    0]) < ToTime(7, 30, 0))

    {

    EnterLongStop(
    1, High[0], "T1");

    EnterLongStop(
    1, High[0], "T2");

    }

    }

    #region Properties

    #endregion

    }

    }
    The output is attached. As you can see it doesn't work.

    Any ideas on how to do scaling of multiple contracts?


    Attached Files

    #2
    This does work, you likely have not set the parameter "Entry handling" to "UniqueEntries" when running a backtest.

    PS - Make sure "Entries per direction" remains at a value of 1.
    RayNinjaTrader Customer Service

    Comment


      #3
      Works !

      Originally posted by NinjaTrader_Ray View Post
      This does work, you likely have not set the parameter "Entry handling" to "UniqueEntries" when running a backtest.

      PS - Make sure "Entries per direction" remains at a value of 1.
      >> That was all it needed.. THANKS

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by hazylizard, Today, 08:38 AM
      2 responses
      8 views
      0 likes
      Last Post hazylizard  
      Started by geddyisodin, Today, 05:20 AM
      2 responses
      17 views
      0 likes
      Last Post geddyisodin  
      Started by Max238, Today, 01:28 AM
      5 responses
      47 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by giulyko00, Yesterday, 12:03 PM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by habeebft, Today, 07:27 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Working...
      X