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

strategy builder

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

    strategy builder

    Hi , in strategy builder under the strategy tab i found

    current market position -is this measured by price or what? how to put this into a strategy?

    also

    flat, long, and short --how is these parameters measured? for example flat =0 or flat =true means no position? and how to express for example one long position or two long position? furthermore, if i choose to sync account position with strategy position, if there is two long account positions, the strategy position will be adjusted to two long positions accordingly? thanks!

    #2
    Hello Light7801,

    This property will not accept an integer (1,2,3) as an accepted value. It is looking specifically for 3 potential values:
    MarketPosition.Flat
    MarketPosition.Long
    MarketPosition.Short

    Those items are selectable in the same category but would be on the right side of the == operator.

    For quantity you can use Position.Quantity

    You can combine these. The statement below checks if long 2.

    if (Position.MarketPosition == MarketPosition.Long && Position.Quantity == 2)

    Unfortunately there is no way for the strategy to check your actual account position. The strategy is only aware of the positions created by its strategy instance.

    NinjaTrader checks historical data to determine the strategy position. If you have syncing enabled (Version 7 only), then this means that, if the strategy position is long 2, then NTwill first submit a buy 2 order to the account. It will place the orders so that your account position (if flat at the start of the strategy) matches the strategy position.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan, thanks you for your reply. you said that "...NinjaTrader checks historical data to determine the strategy position...." what if it goes back to like 30 days data and found 100 entry points when i attach it? will it enter like 100 orders?

      furthermore, please tell me if the following thoughts could be realized in ninja script:

      i want to enter just one long order for stock A and before the long position exit, i do not want to enter another long even if other conditions qualify for a buy order. that being said, whenever i attach the strategy, if there is a long position, no orders will be entered until the position goes to flat. once it goes to flat or when i attach the strategy the account is flat, the first freshly generated buy order will be executed. (all the positions here are referring to actually account positions because that's what really counts.)

      my original thought to realize it is :ninja script has an ability to detect account position. for example, if i attach the script to stock A, the script will immediately detect the account position; whether it's flat, has one long position, or has two short positions. in other words, the account position should be checked for every incoming tick.

      however, since you said there is no way for the strategy to check my actual account position, is there another way around to achieve the highlighted part or it just cannot be realized in ninja auto trading?

      sorry for the lengthy inquiry but it's really my deciding point of whether to use this software. many thanks in advance!!

      Comment


        #4
        Hello light7801,

        NinjaTrader reads the historical data to determine your strategy position but the syncing is only related to the current strategy postion. When you have the setting enabled "Immediately submit live working historical orders": If your current strategy position is 100 contracts, then syncing will submit 100 orders to the account. If there have been 100 positions but all of them are closed (strategy position is flat), then no orders are submitted.

        i want to enter just one long order for stock A and before the long position exit, i do not want to enter another long even if other conditions qualify for a buy order.
        This is controlled with the setting/property EntriesPerDirection This property works closely with EntryHandling

        whenever i attach the strategy, if there is a long position, no orders will be entered until the position goes to flat. once it goes to flat or when i attach the strategy the account is flat, the first freshly generated buy order will be executed. (all the positions here are referring to actually account positions because that's what really counts.)
        NinjaTrader can't read your actual account position, but you can control whether the strategy will wait until flat before submitting orders or if it will immediately submit orders. This is controlled with the setting found under Tools > Options > Strategies tab > NinjaScript

        my original thought to realize it is :ninja script has an ability to detect account position. for example, if i attach the script to stock A, the script will immediately detect the account position; whether it's flat, has one long position, or has two short positions. in other words, the account position should be checked for every incoming tick.

        however, since you said there is no way for the strategy to check my actual account position, is there another way around to achieve the highlighted part or it just cannot be realized in ninja auto trading?



        That's correct. Here are some of your options:
        • Syncing account position with strategy position. Ninja determines the strategy position and then submits the appropriate orders to your account. This is only available with NT7.
        • Wait until flat before submitting orders.
        • Manually submit orders to your account to match the strategy position.
        • Only run your strategy on live data. This is accomplished by adding the statement if (Historical) return; above your order placement logic in the OnBarUpdate() method.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        42 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        27 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X