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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    57 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
    20 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    9 views
    0 likes
    Last Post cre8able  
    Working...
    X