Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy conditions

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

    Strategy conditions

    Hello,

    I have designed a strategy that uses ATM to trade. However once the conditions are met again (even when in a trade) it starts another entry and ATM order. Is there any possible way in that once the orderid begins, that the strategy does not execute any other ATM's entries, if say for example im long in a trade.


    many thanks

    #2
    jthom, you can work with GetAtmStrategyMarketPosition to make sure you're flat before you enter another order - http://www.ninjatrader-support.com/H...yPosition.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Cheers. I just looked in the SampleATMStrategy, and It pretty much had it all in there. Thanks for pointing the command out.

      Comment


        #4
        Hello again,

        My strategy seems to initiate limit order types but does not execute a trade unless the limit is hit. How can this be changed so that once the strategy conditions are met, that the trade executes immediately at ANY price?

        Here is some of the code
        if Strategy conditions are met
        {
        atmStrategyId = GetAtmStrategyUniqueId();
        orderId = GetAtmStrategyUniqueId();
        AtmStrategyCreate(Action.Buy, OrderType.Limit, Low[
        0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
        }




        /// Check for a pending entry order
        if (orderId.Length > 0)
        {
        string[] status = GetAtmStrategyEntryOrderStatus(orderId);


        if (status.GetLength(0) > 0)
        {
        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;
        }
        }
        elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
        atmStrategyId =
        string.Empty;

        Comment


          #5
          Fixed it by changing order type to market. duh!!!!

          {
          atmStrategyId = GetAtmStrategyUniqueId();
          orderId = GetAtmStrategyUniqueId();
          AtmStrategyCreate(Action.Buy, OrderType.Market, Low[
          0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
          }



          Last edited by jthom; 06-02-2009, 02:00 AM.

          Comment


            #6
            Great jthom, thanks for reporting back.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              My ATM seems to enter in two positions on live data stream when only I want one. When I use market replay it only enters in one position.
              Anyone know how to stop this 2 position entry to one?

              {
              atmStrategyId = GetAtmStrategyUniqueId();
              orderId = GetAtmStrategyUniqueId();
              AtmStrategyCreate(Action.Sell, OrderType.Market, Low[
              0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
              }

              if (orderId.Length > 0)
              {
              string[] status = GetAtmStrategyEntryOrderStatus(orderId);
              if (status.GetLength(0) > 0)
              {
              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 (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
              orderId =
              string.Empty;
              }
              }
              // If the strategy has terminated reset the strategy id
              elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
              atmStrategyId =
              string.Empty;

              Comment


                #8
                jthom, since you're using a market order to get you in, please set the limit price used to 0 - you currently have it at Low[0]. Then check if the live execution is as you would expect it.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  AtmStrategyCreate(Action.Sell, OrderType.Market, Limit=0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);



                  So like that then?

                  Comment


                    #10
                    Just like this should be fine -

                    Code:
                    AtmStrategyCreate(Action.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Bertrand, will test it now. Much appreciated for you're help.

                      Comment


                        #12
                        Still doing it. Its actually doing 3 orders now. lol. Is it possible to put a time limit on. For example oncer orderid=1 not to start another trade for at least 15 mins?
                        Last edited by jthom; 06-08-2009, 11:13 AM.

                        Comment


                          #13
                          You would have to program that yourself. You can create time filters to surround your trade conditions. Please use Time[0] to check the time.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            If you only want to place a trade if there isn't already one active, then you could do something like this...

                            Code:
                            [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ( Position.MarketPosition == MarketPosition.Flat)[/SIZE][/FONT][/SIZE][/FONT]
                            [FONT=Courier New][SIZE=2]{[/SIZE][/FONT]
                            [SIZE=2][FONT=Courier New]   atmStrategyId = GetAtmStrategyUniqueId();[/FONT][/SIZE]
                            [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New]   orderId = GetAtmStrategyUniqueId();[/FONT][/SIZE][/FONT][/SIZE]
                            [SIZE=2][FONT=Courier New]   AtmStrategyCreate(Action.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);[/FONT][/SIZE]
                            [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]

                            Comment


                              #15
                              Well pretty much Im after a method that entails a mechanism that ceases to execute a trade, even after the strategy conditions have been met. Either this mechanism be present in the strategy conditions, or the atmstrategycreate.
                              In theory the strategy executes the ATM on the ES to obtain 1.5 points. However after the trade exits, the strategy conditions have been met immediately and begins another trades when I wouldn't want it too.
                              Is there any other way to stop this??????

                              Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by PhillT, Today, 02:16 PM
                              2 responses
                              6 views
                              0 likes
                              Last Post PhillT
                              by PhillT
                               
                              Started by Kaledus, Today, 01:29 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Yesterday, 09:08 AM
                              14 responses
                              47 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by gentlebenthebear, Today, 01:30 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gentlebenthebear  
                              Started by PaulMohn, Today, 12:36 PM
                              2 responses
                              17 views
                              0 likes
                              Last Post PaulMohn  
                              Working...
                              X