Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong Zero Shares

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

    EnterLong Zero Shares

    Could be considered a bug or this could just be something to add to the documentation library.

    Code:
    sharesToBuy = Convert.ToInt32(Math.Floor(spendingCash / Close[0]));  //Calculates how many whole shares it can buy with spendingCash.
    EnterLong(sharesToBuy, "");  //Buy Long
    I was using the above lines for determining how many shares to buy but had never considered the possibility of a "0" zero share order. Today the line for sharesToBuy returned zero so the next EnterLong line took the zero and in turn placed an order for 100 shares. Obviously zero shares for quantity is simply not an order to be transmitted but I don't know where the 100 shares came from. Possibly NT sent the order to IB with 0 quantity and IB converted it to 100 or NT converted it to 100 or at the exchange it was converted to 100 but it does start to look like it was NT's doing as I can't find any log entries from IB regarding the symbols in question.

    The log entries that apply are:
    Code:
    2017-04-12 10:38:04:291|0|32|UXXXXXXX,  affected Order: Buy 100 Market
    2017-04-12 10:38:04:307|1|32|Order='1184765656/UXXXXXXX' Name='Buy' New state='Rejected' Instrument='MUR' Action='Buy' Limit price=0 Stop price=0 Quantity=100 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Order rejected - reason:CASH AVAILABLE: 62.88; CASH NEEDED FOR THIS ORDER AND OTHER PENDING ORDERS: 3036.97'
    2017-04-12 10:38:04:307|0|32|UXXXXXXX, Order rejected - reason:CASH AVAILABLE: 62.88; CASH NEEDED FOR THIS ORDER AND OTHER PENDING ORDERS: 3036.97 affected Order: Buy 100 Market
    2017-04-12 10:39:01:794|1|16|NinjaScript strategy 'Climber/101497366' submitting order
    I have added code to prevent any EnterLong from running if the sharesToBuy is zero so for me now this isn't an issue however I thought it important enough for NT and others to be aware of it.
    Last edited by antrux; 04-12-2017, 02:47 PM.

    #2
    Hello antrux,

    When a 0 is used, NinjaTrader will revert to the default for that instrument type.

    (For example if you load an equity on the SuperDOM the quantity will default to 100 instead of 1. If you open a forex instrument the quantity will default to 10,000)

    Would you like to submit a feature request to have this ignore the default and always send with a quantity of 1?
    Would you prefer the script trigger an error and disable the strategy?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      After some additional searching I now see where, in code, the DefaultQuantity may be specified.

      As for a feature request as long as I know how (EnterLong 0) works I'm good. However, I can see how it may be counter intuitive to others that submitting a buy for zero could end up doing something very different than what it explicitly is stating. I think ultimately it should be left to Product Development or the community at large to decide.
      As for my vote an EnterLong of zero should throw a Default/Strategy error/entry into the log and then the RealtimeErrorHandling function can do it's job.

      Comment


        #4
        Hello antrux,

        Your request to trigger a runtime error with message to display when an NS strategy uses a 0 as the quantity order is being tracked with ID #SFT-2171.

        Please note it is up to NinjaTrader Development to decide if and when a request will be implemented.

        Thanks for your suggestion. Please let me know if you have any other requests or suggestions.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        22 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X