Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit Order Expiration

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

    Limit Order Expiration

    Hell !!! i just try to test limit order expiration and strategy dont even execute order
    cant fing wath wrong
    work only if remove if (myEntryOrder == null)

    private IOrder myEntryOrder = null;
    private int barNumberOfOrder = 0;

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    ExitOnClose=false;
    EntriesPerDirection=1;
    Slippage = 2;
    EntryHandling = EntryHandling.UniqueEntries;
    ConnectionLossHandling = ConnectionLossHandling.KeepRunning;
    SetProfitTarget("Buy", CalculationMode.Ticks, Profit);
    SetStopLoss("Buy", CalculationMode.Ticks, Stop, false);

    }

    protected override void OnBarUpdate()
    {
    if(Close[0] > Close[1])
    if (myEntryOrder == null)
    if (BarsInProgress == 0)
    {
    myEntryOrder = EnterLongLimit(0, true, 1, Low[1], "Long Entry");
    barNumberOfOrder = CurrentBar;
    }
    else if (CurrentBar > barNumberOfOrder + 5)
    CancelOrder(myEntryOrder);
    }
    Last edited by GainForex; 01-18-2016, 09:45 AM.

    #2
    Hello GainForex,

    I recommend that you add TraceOrders = true; to the Initialize() method of the script and that you add a print to the conditions that are placing orders to see if they are being placed.

    http://ninjatrader.com/support/helpG...raceorders.htm

    Below I am adding a link to a video that demonstrates adding a print to your code to understand the behavior of the script.
    https://www.youtube.com/watch?v=K8v_...tu.be&t=48m15s

    The output from TraceOrders and from the Prints will go to the Output window. (Tools -> Output Window)
    After adding the prints and enabling order tracing, please re-run your script and post the output from the Output window. (Right-click the Output window -> select Save As... -> save the text to a location where this can be found -> attach to your next post)

    Your print should look something like this:

    if(Close[0] > Close[1])
    if (myEntryOrder == null)
    {
    Print(string.Format("{0} | Placing enter long limit at: {1}", Time[0], Low[1]));
    myEntryOrder = EnterLongLimit(0, true, 1, Low[1], "Long Entry");
    barNumberOfOrder = CurrentBar;
    }
    else if (CurrentBar > barNumberOfOrder + 5)
    CancelOrder(myEntryOrder);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ok here is print out
      strategy do only one trade and stop , i think limit orders not remove

      /18/2016 9:05:26 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Buy' Mode=Ticks Value=15 Currency=0 Simulated=False
      1/18/2016 9:05:26 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Buy' Mode=Ticks Value=50 Currency=0 Simulated=False
      1/18/2016 9:05:26 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Buy' Mode=Ticks Value=15 Currency=0 Simulated=False
      1/18/2016 9:05:26 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Buy' Mode=Ticks Value=50 Currency=0 Simulated=False
      12/31/2004 6:50:00 AM Entered internal PlaceOrder() method at 12/31/2004 6:50:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=0.01M LimitPrice=1.3554 StopPrice=0 SignalName='Buy' FromEntrySignal=''
      12/31/2004 9:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Backtest' Name='Profit target' State=Working Instrument='$EURUSD' Action=Sell Limit price=1.3569 Stop price=0 Quantity=0.01M Strategy='orderlimitttest' Type=Limit Tif=Gtc Oco='NT-00000-26666' Filled=0 Fill price=0 Token='bda9f295c786426dbc376f93aa09de6d' Gtd='12/1/2099 12:00:00 AM'
      12/31/2004 9:00:00 AM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00002/Backtest' Name='Profit target' State=Cancelled Instrument='$EURUSD' Action=Sell Limit price=1.3569 Stop price=0 Quantity=0.01M Strategy='orderlimitttest' Type=Limit Tif=Gtc Oco='NT-00000-26666' Filled=0 Fill price=0 Token='bda9f295c786426dbc376f93aa09de6d' Gtd='12/1/2099 12:00:00 AM'

      Comment


        #4
        Hello GainForex,

        From what is appearing in the output, it appears that an order was filled and was exited by the stop loss.

        Is this script being backtested in the Strategy Analyzer or being added to a chart or to the Strategies tab of the Control Center?

        If this is being tested in the Strategy Analyzer, may I have a screenshot of the results summary?

        If this is added to a chart or to the Strategies tab of the Control Center, may I have a screenshot of the historical performance? (Right-click the instance of the strategy on the Strategies tab of the Control Center -> select Strategy Performance -> select Historical -> take a screenshot of this window)

        To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

        Click here for instructions

        Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

        Click here for detailed instruction


        You can also add a Print to the OnOrderUpdate method to get further information about when these orders have filled. Please add the following method to your script below the OnBarUpdate method. Then clear the output window (right-click the output window -> select Clear), re-run the script, save the new output and post this with the screenshots.

        protected override void OnOrderUpdate(IOrder order)
        {
        Print(string.Format("{0} | {1} | {2} | {3}", order.Time, order.Name, order.OrderState, order.ToString()));
        }

        http://ninjatrader.com/support/helpG...rderupdate.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi , i just add files
          Attached Files

          Comment


            #6
            Hello GainForex,

            In your initial post you mention that the script is not filling any orders an that there are no executions. In post #4 I think you are saying you recognize that the order is being placed and is filling.

            The screenshot also shows that there is an entry and an exit.


            Are you instead asking why there is only one entry and one exit?
            This is because you require that the IOrder variable myEntryOrder to be null for there to be an entry. The variable is null when the script is started allowing for one entry, but then is never set to null again so no new order can be placed. Is there a reason that you have added a condition for the variable to be null before an entry to be placed? If not, remove this code.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Alaina19, Today, 10:55 PM
            0 responses
            1 view
            0 likes
            Last Post Alaina19  
            Started by cmv727, 04-12-2024, 10:38 AM
            9 responses
            117 views
            0 likes
            Last Post mandrake88  
            Started by BadA$$B3ast, Yesterday, 09:15 PM
            2 responses
            13 views
            0 likes
            Last Post BadA$$B3ast  
            Started by trdninstyle, 10-05-2024, 06:42 PM
            4 responses
            29 views
            0 likes
            Last Post trdninstyle  
            Started by samish18, 08-30-2024, 03:10 PM
            40 responses
            300 views
            0 likes
            Last Post samish18  
            Working...
            X