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

Limit Order Expiration

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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • GainForex
    replied
    Hi , i just add files
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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

    Leave a comment:


  • GainForex
    replied
    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'

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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);
    }

    Leave a comment:


  • GainForex
    started a topic Limit Order Expiration

    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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by flonkle, Today, 01:19 AM
4 responses
27 views
0 likes
Last Post flonkle
by flonkle
 
Started by sofortune, 06-13-2024, 02:31 AM
2 responses
19 views
0 likes
Last Post sofortune  
Started by GodAtum, Today, 09:52 AM
10 responses
21 views
0 likes
Last Post GodAtum
by GodAtum
 
Started by WHICKED, 06-27-2023, 12:07 PM
83 responses
864 views
1 like
Last Post NinjaTrader_ChelseaB  
Started by Rxxar, Today, 09:56 AM
1 response
7 views
0 likes
Last Post NinjaTrader_Clayton  
Working...
X