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

Unable to call ATM from within a strategy.

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

    Unable to call ATM from within a strategy.

    Hi, I have been working from the example ATM code snippet, and have the following but I am unable to get the ATM template "test2" to manage the order. Can you tell me where I have gone wrong please.

    // Wizard generated variables
    private int nrenko1 = 10;
    private int nrenko2 = 20;
    RG_ORDERTYPE iRGType = RG_ORDERTYPE.Market;
    bool baTM = false;
    private int target1 = 82;//36
    private int stop1 = 27;
    private int lots = 1;

    bool bmTF = false;
    int myPeriods = 2;
    RGPdTypes npType = RGPdTypes.Minute;
    int ADXlong = 22; //22
    int ADXshort = 22; //22

    private string atmStrategyId = string.Empty;
    private string orderId = string.Empty;



    #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 = false;
    //SetProfitTarget(CalculationMode.Ticks, target1);
    //SetStopLoss(CalculationMode.Ticks, stop1);
    }

    protected override void OnBarUpdate()
    {


    if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
    {
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
    }

    if (orderId.Length > 0)
    {
    string[] status = GetAtmStrategyEntryOrderStatus(orderId);

    // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
    if (status.GetLength(0) > 0)
    {
    // Print out some information about the order to the output window
    Print("The entry order average fill price is: " + status[0]);
    Print("The entry order filled amount is: " + status[1]);
    Print("The entry order order state is: " + status[2]);

    // If the order state is terminal, reset the order id value
    if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
    orderId = string.Empty;
    }
    } // If the strategy has terminated reset the strategy id
    else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
    atmStrategyId = string.Empty;


    if (atmStrategyId.Length > 0)
    {
    // You can change the stop price
    if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
    AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "test2", atmStrategyId);

    // Print some information about the strategy to the output window
    Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
    Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
    Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
    Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
    }


    #2
    Hello Gille1983,

    Thanks for your post.

    If you are trying to test this on historical data please note that ATM strategies can only be tested with live data or Market replay data.

    It looks like you are missing these lines that would prevent that:

    // Make sure this strategy does not execute against historical data
    if (Historical)
    return;

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Would I still net to set this in initialise :

      //SetProfitTarget(CalculationMode.Ticks, target1);
      //SetStopLoss(CalculationMode.Ticks, stop1);

      I was running on market replay. So now I have this with your addition is this in the correct place.

      protected override void OnBarUpdate()
      {

      // Make sure this strategy does not execute against historical data
      if (Historical)
      return;


      if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
      {
      atmStrategyId = GetAtmStrategyUniqueId();
      orderId = GetAtmStrategyUniqueId();
      AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
      }

      if (orderId.Length > 0)
      {
      string[] status = GetAtmStrategyEntryOrderStatus(orderId);

      // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
      if (status.GetLength(0) > 0)
      {
      // Print out some information about the order to the output window
      Print("The entry order average fill price is: " + status[0]);
      Print("The entry order filled amount is: " + status[1]);
      Print("The entry order order state is: " + status[2]);

      // If the order state is terminal, reset the order id value
      if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
      orderId = string.Empty;
      }
      } // If the strategy has terminated reset the strategy id
      else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
      atmStrategyId = string.Empty;


      if (atmStrategyId.Length > 0)
      {
      // You can change the stop price
      if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
      AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "test2", atmStrategyId);

      // Print some information about the strategy to the output window
      Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
      Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
      Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
      Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
      }

      string strsignal = "";
      string strxav1 = "";
      string strxav2 = "";
      try
      {
      RegistryKey key1 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyScalper");
      if (key1 != null)
      {
      strsignal = key1.GetValue("signalname").ToString();
      key1.Close();
      }
      RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav1");
      if (key2 != null)
      {
      strxav1 = key2.GetValue("phase1").ToString();
      key2.Close();
      }
      RegistryKey key3 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav2");
      if (key3 != null)
      {
      strxav2 = key3.GetValue("phase2").ToString();
      key3.Close();
      }
      }
      catch
      {


      }




      ////////////////////////////////////// LONG CONDITIONS

      /////////////////////////////////

      Comment


        #4
        Hello Gille1983,

        Thanks for your reply.

        The set methods (SetProfitTarget and SetStopLoss) should not be used in your hybrid ATM strategy, that is the purpose of using the ATM template.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul,

          When I run the above in my strategy on market replay data there are some odd results. Initially, the ATM works as you would expect, then t leaves a random Buy LMT and does not activate at all, also it does not record the P&L. Any idea how I can fix this.

          #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;
          using System.Collections.Generic;
          using System.IO; // added for audio file selection
          using System.Collections; // added for audio file selection
          using Microsoft.Win32;

          #endregion

          // 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(" ")]
          public class RGAutoTrade : Strategy
          {
          #region Variables
          public enum RG_ORDERTYPE
          {
          Market,
          preClose,
          preOpen,
          }
          public enum RGPdTypes
          {
          Day = 1,
          Minute = 2,
          Range = 3,
          Second = 4,
          Tick = 5,
          Volume = 6
          }

          // Wizard generated variables
          private int nrenko1 = 10;
          private int nrenko2 = 20;
          RG_ORDERTYPE iRGType = RG_ORDERTYPE.Market;
          bool baTM = false;
          private int target1 = 82;//36
          private int stop1 = 27;
          private int target2 = 31;
          private int stop2 = 12;
          private int lots = 1;

          bool bmTF = false;
          int myPeriods = 2;
          RGPdTypes npType = RGPdTypes.Minute;
          int ADXlong = 22; //22
          int ADXshort = 22; //22

          private string atmStrategyId = string.Empty;
          private string orderId = string.Empty;



          #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 = false;
          //SetProfitTarget(CalculationMode.Ticks, target1);
          //SetStopLoss(CalculationMode.Ticks, stop1);
          }

          protected override void OnBarUpdate()
          {

          // Make sure this strategy does not execute against historical data
          if (Historical)
          return;


          if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
          {
          atmStrategyId = GetAtmStrategyUniqueId();
          orderId = GetAtmStrategyUniqueId();
          AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
          }

          if (orderId.Length > 0)
          {
          string[] status = GetAtmStrategyEntryOrderStatus(orderId);

          // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
          if (status.GetLength(0) > 0)
          {
          // Print out some information about the order to the output window
          Print("The entry order average fill price is: " + status[0]);
          Print("The entry order filled amount is: " + status[1]);
          Print("The entry order order state is: " + status[2]);

          // If the order state is terminal, reset the order id value
          if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
          orderId = string.Empty;
          }
          } // If the strategy has terminated reset the strategy id
          else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
          atmStrategyId = string.Empty;


          if (atmStrategyId.Length > 0)
          {
          // You can change the stop price
          if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
          AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "test2", atmStrategyId);

          // Print some information about the strategy to the output window
          Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
          Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
          Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
          Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
          }

          string strsignal = "";
          string strxav1 = "";
          string strxav2 = "";
          try
          {
          RegistryKey key1 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyScalper");
          if (key1 != null)
          {
          strsignal = key1.GetValue("signalname").ToString();
          key1.Close();
          }
          RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav1");
          if (key2 != null)
          {
          strxav1 = key2.GetValue("phase1").ToString();
          key2.Close();
          }
          RegistryKey key3 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav2");
          if (key3 != null)
          {
          strxav2 = key3.GetValue("phase2").ToString();
          key3.Close();
          }
          }
          catch
          {


          }


          bool benable = false;
          if (iRGType == RG_ORDERTYPE.Market)
          benable = true;
          if (DateTime.Now.Ticks == Time[0].Ticks && iRGType == RG_ORDERTYPE.preClose)
          benable = true;
          if (DateTime.Now.Ticks == Time[1].Ticks && iRGType == RG_ORDERTYPE.preOpen)
          benable = true;
          if (!benable)
          return;

          ////////////////////////////////////// LONG CONDITIONS

          //////////////////////////////////////CONDITION 1 - Keep Settings!!

          if (strxav2 == "UT" && strxav1 == "UT" && ADX(14)[1] > ADXlong && strsignal == "MACD Cross UP") //


          {
          double value = ADX(14)[0];
          Print("The current Long Entry ADX value is " + value.ToString()+ Time[0]);



          {
          int n = 0;
          EnterLong(lots, "UT+UT");
          RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Ninja Trader7\MyScalper");
          key.SetValue("signalname", "UT+UT.Long");
          key.Close();

          }


          }

          Comment


            #6
            Ahh I think i have used the wrong example, I want to use the settings in my local ATM strategy "Test2". can you direct me to another example

            Comment


              #7
              Hello Gille1983,

              Thanks for your replies.

              I'm not sure I understand what you are looking for, can you clarify?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Sorry Paul,

                So I have my strategy with EnterLong / EnterShort at Market, I want to call an ATM strategy I have saved as Test2 to manage the stop and trail. I don't understand why the template is placing lmt orders.

                Does that make more sense

                Comment


                  #9
                  Hello Gille1983,

                  Thanks for clarifying.

                  The strategy SampleATMstrategy that you have copied uses a limit order for the entry order.

                  This is specified here: AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "test2", atmStrategyId);

                  You can change that is you wish to be OrderType.Market, like this: AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
                  Reference:https://ninjatrader.com/support/help...tegycreate.htm

                  Profit targets are always limit orders, StopLoss order are always stopMarket.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Ok, thank you, so in order to create a short entry I would just do this is that correct:

                    if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
                    {
                    atmStrategyId = GetAtmStrategyUniqueId();
                    orderId = GetAtmStrategyUniqueId();
                    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
                    }

                    else if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] < Open[0])
                    {
                    atmStrategyId = GetAtmStrategyUniqueId();
                    orderId = GetAtmStrategyUniqueId();
                    AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "test2", atmStrategyId);
                    }

                    Comment


                      #11
                      Hello Gille1983,

                      Thanks for your reply.

                      Yes, although the entry conditions are just a simple example for producing test entries. Once you have proven out the other parts of the code you can replace the Close[0] >Open[0] and Close[0] < Open[0] with more appropriate entry logic.


                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        I have incorporated this into my strategy, however, rather than stop out when it should as per the ATM settings in Test2 it does not. Can you see anything here that would be causing the issue :

                        #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;
                        using System.Collections.Generic;
                        using System.IO; // added for audio file selection
                        using System.Collections; // added for audio file selection
                        using Microsoft.Win32;

                        #endregion

                        // 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(" ")]
                        public class RGAutoTrade : Strategy
                        {
                        #region Variables
                        public enum RG_ORDERTYPE
                        {
                        Market,
                        preClose,
                        preOpen,
                        }
                        public enum RGPdTypes
                        {
                        Day = 1,
                        Minute = 2,
                        Range = 3,
                        Second = 4,
                        Tick = 5,
                        Volume = 6
                        }

                        // Wizard generated variables
                        private int nrenko1 = 10;
                        private int nrenko2 = 20;
                        RG_ORDERTYPE iRGType = RG_ORDERTYPE.Market;
                        bool baTM = false;
                        //private int target1 = 82;//36
                        //private int stop1 = 27;
                        //private int target2 = 31;
                        //private int stop2 = 12;
                        private int lots = 1;

                        bool bmTF = false;
                        int myPeriods = 2;
                        RGPdTypes npType = RGPdTypes.Minute;
                        int ADXlong = 22; //22
                        int ADXshort = 22; //22

                        private string atmStrategyId = string.Empty;
                        private string orderId = string.Empty;



                        #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 = false;
                        //SetProfitTarget(CalculationMode.Ticks, target1);
                        //SetStopLoss(CalculationMode.Ticks, stop1);
                        }

                        protected override void OnBarUpdate()
                        {

                        // Make sure this strategy does not execute against historical data
                        if (Historical)
                        return;


                        if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
                        {
                        atmStrategyId = GetAtmStrategyUniqueId();
                        orderId = GetAtmStrategyUniqueId();
                        AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "Test2", atmStrategyId);
                        }

                        else if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] < Open[0])
                        {
                        atmStrategyId = GetAtmStrategyUniqueId();
                        orderId = GetAtmStrategyUniqueId();
                        AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "Test2", atmStrategyId);
                        }

                        if (orderId.Length > 0)
                        {
                        string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                        // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                        if (status.GetLength(0) > 0)
                        {
                        // Print out some information about the order to the output window
                        Print("The entry order average fill price is: " + status[0]);
                        Print("The entry order filled amount is: " + status[1]);
                        Print("The entry order order state is: " + status[2]);

                        // If the order state is terminal, reset the order id value
                        if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                        orderId = string.Empty;
                        }
                        } // If the strategy has terminated reset the strategy id
                        else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                        atmStrategyId = string.Empty;


                        if (atmStrategyId.Length > 0)
                        {
                        // You can change the stop price
                        if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
                        AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "test2", atmStrategyId);

                        // Print some information about the strategy to the output window
                        Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
                        Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
                        Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
                        Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
                        }

                        string strsignal = "";
                        string strxav1 = "";
                        string strxav2 = "";
                        try
                        {
                        RegistryKey key1 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyScalper");
                        if (key1 != null)
                        {
                        strsignal = key1.GetValue("signalname").ToString();
                        key1.Close();
                        }
                        RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav1");
                        if (key2 != null)
                        {
                        strxav1 = key2.GetValue("phase1").ToString();
                        key2.Close();
                        }
                        RegistryKey key3 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\NinjaTr ader7\MyXav2");
                        if (key3 != null)
                        {
                        strxav2 = key3.GetValue("phase2").ToString();
                        key3.Close();
                        }
                        }
                        catch
                        {


                        }


                        bool benable = false;
                        if (iRGType == RG_ORDERTYPE.Market)
                        benable = true;
                        if (DateTime.Now.Ticks == Time[0].Ticks && iRGType == RG_ORDERTYPE.preClose)
                        benable = true;
                        if (DateTime.Now.Ticks == Time[1].Ticks && iRGType == RG_ORDERTYPE.preOpen)
                        benable = true;
                        if (!benable)
                        return;

                        ////////////////////////////////////// LONG CONDITIONS

                        //////////////////////////////////////CONDITION 1 - Keep Settings!!

                        if (strxav2 == "UT" && strxav1 == "UT" && ADX(14)[1] > ADXlong && strsignal == "MACD Cross UP") //


                        {
                        double value = ADX(14)[0];
                        Print("The current Long Entry ADX value is " + value.ToString()+ Time[0]);



                        {
                        int n = 0;
                        EnterLong(lots, "UT+UT");
                        RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Ninja Trader7\MyScalper");
                        key.SetValue("signalname", "UT+UT.Long");
                        key.Close();

                        }


                        }


                        /////////////////////////////////////////////// SHORT CONDITIONS,

                        ///////////////////////////////////////////////CONDITION 1


                        if (strxav2 == "DT" && strxav1 == "DT" && ADX(14)[1] > ADXshort && strsignal == "MACD Cross DOWN") //&& ADX(10)[2] > ADX(10)[1]


                        {
                        double value = ADX(14)[0];
                        Print("The current Short Entry ADX value is " + value.ToString() + Time[0]);

                        {
                        int n = 0;
                        EnterShort(lots, "DT+DT");
                        RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Ninja Trader7\MyScalper");
                        key.SetValue("signalname", "DT+DT.Short");
                        key.Close();
                        }
                        }

                        }


                        }
                        }



                        The ATM strategy parameters are:

                        QTY: 1
                        SL: 27
                        PT: 0

                        Custom
                        PT 26 Plus 3

                        Three Step

                        20, 01, 36
                        15, 4, 42
                        6, 2, 68


                        Comment


                          #13
                          Hello Gille1983,

                          Thanks for your post.

                          Please note that we do not provide debugging services nor code writing services.

                          What I would suggest is starting over with the SampleATMStartegy and make a new copy and test it with your specific ATM template to verify functionality as is, then modify the code to meet your entry conditions.

                          You are mixing EnterLong and EnterShort with ATM strategy coding and you cannot do this. This is what provides the entry order if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])

                          If you would like someone to create your strategy for you, we can provide references to 3rd party programmers.

                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Ahhh the penny has dropped, i think I understand now so the ATM entry replaces the enter long is that correct. I understand now thank you

                            Comment


                              #15
                              Hello Gille1983,

                              Thanks for your reply.

                              You would replace the Close[0]>Open[0] with your entry conditions to then have the ATM methods provide the entry order which will trigger the specified ATM template. AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "Test2", atmStrategyId);
                              Paul H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Haiasi, 04-25-2024, 06:53 PM
                              2 responses
                              16 views
                              0 likes
                              Last Post Massinisa  
                              Started by Creamers, Today, 05:32 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post Creamers  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              12 responses
                              1,785 views
                              0 likes
                              Last Post Leafcutter  
                              Started by poplagelu, Today, 05:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post poplagelu  
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,407 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Working...
                              X