Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Handling of orders for stocks that are not shortable

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

    Handling of orders for stocks that are not shortable

    I have written a simple stock trading strategy that trades :

    -Long entries
    -Short entries

    - Long exit
    - Short exit


    I would like to implement that if a short entry is rejected ( due to unavailablility for short sale) that the order will be automatically cancelled and that the strategy will look for new opportunities..

    Currently, the order stays in the market waiting to be executed, i will have to cancel manually...


    Does anybody know how i will be able to code this ?

    My short entry condition is currently:


    if (ToTime(Time[0]) >= ToTime(12, 00, 0)
    && Close[0] < Low[1]
    && VOLMA(14)[0] > 40)

    {
    EnterShort(DefaultQuantity, "short");
    }


    Thank you !

    #2
    Hello marcus250,
    You can use the CancelOrder method to cancel your orders if it does not fills after x amount of time. Please refer to our help guide to know more on it.


    in variable
    Code:
    IOrder entryOrder;
    In OnBarUpdate
    Code:
    entryOrder = EnterLongLimit(0, true, 1, Close[0] + 10 * TickSize, "");
    Cancel the order after a minute
    Code:
    if (DateTime.Now.Subtract(entryOrder.Time).TotalMinutes > 1 && Position.MarketPosition.Flat)
    	CancelOrder(entryOrder);
    The above is just an idea and not the actual code. We have not be able to test it due to its uniqueness, so please test it further.
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by inanazsocial, Today, 01:15 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    10 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    1 view
    0 likes
    Last Post dustydbayer  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    23 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Working...
    X