Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entering positions when not flat

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

    Entering positions when not flat

    I have written a ninja script(mostly through the wizard). In the script, I am using an ATM strategy. I have found that I am entering trades when I am already in one. I have tried putting in pieces of code to keep this from happening, but without success. Here are a few of the ways I have tried. As you can see, I am trying anything in the hopes that it works. Obviously, I am not an advanced programmer. Any help would be appreciated.

    1.
    protectedoverridevoid OnBarUpdate()
    if (GetAtmStrategyMarketPosition(OrderId) != MarketPosition.Flat)

    return;

    2.
    protectedoverridevoid OnBarUpdate()

    if (GetAtmStrategyMarketPosition(
    atmStrategyId) != MarketPosition.Flat)

    return;

    and
    3.
    // Condition set 1
    if (ToTime(Time[0]) >= ToTime(8, 45, 00)
    && ToTime(Time[0]) <= ToTime(14, 50, 00)
    && Position.MarketPosition == MarketPosition.Flat
    etc...
    4.
    // Condition set 1
    if (ToTime(Time[0]) >= ToTime(8, 45, 00)
    && ToTime(Time[0]) <= ToTime(14, 50, 00)
    && GetAtmStrategyMarketPosition(OrderId) == MarketPosition.Flat
    etc...

    The log shows an error:
    GetAtmStrategyMarketPosition() method error: AtmStrategyId '1dfde556491458491db1e6eeee761d0' does not exist

    Edward
    Last edited by edward; 08-08-2007, 08:52 PM. Reason: adding error log

    #2
    Have you tried setting EntriesPerDirection to 1? I don't know if the EntriesPerDirection variable affects ATM strategies though.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Unfortunately that does not work for ATM strategies. Or at least that is what I have read. Thanks though.

      Comment


        #4
        Programatically working with ATM strategies in a NinjaScript strategy is an advanced endevour. Please take a look at the sample strategy code and even start with that as a base reference to work out your own logic.

        Position.MarketPosition will NOT reflect the position of an ATM strategy. Please see the Help Guide for relevant ATM methods that you can use.
        RayNinjaTrader Customer Service

        Comment


          #5
          I have been looking at the Help guide concerning ATM strategies. I am using the GetAtmStrategyEntryOrderStatus function. Both of the Print commands show the same orderId, but the line in between shows an error in the log. It states that the specific orderId cannot be found. How can the orderId not exist when it prints out in the output window?

          Print("test1 orderId is now: " + (orderId));
          string[] status = GetAtmStrategyEntryOrderStatus(orderId);
          Print("test2 orderId is now: " + (orderId));


          Output window:
          test1 orderId is now: c1397fd6281949d0bcf1186b5108275f
          test2 orderId is now: c1397fd6281949d0bcf1186b5108275f

          Log:
          GetAtmStrategyEntryOrderStatus() method error: orderId 'c1397fd6281949d0bcf1186b5108275f' does not exist

          Comment


            #6
            Printing out the user defined variable orderId does not mean that it exists at the time you call the Get() method.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by benmarkal, Today, 12:52 PM
            0 responses
            0 views
            0 likes
            Last Post benmarkal  
            Started by stafe, 04-15-2024, 08:34 PM
            11 responses
            57 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by pechtri, 06-22-2023, 02:31 AM
            5 responses
            116 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Tim-c, Today, 03:54 AM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by FAQtrader, Today, 12:00 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X