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

Checking my Stop

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

    Checking my Stop

    Hello,

    I am trying to get the code to check if the stop is filled. If it is filled, I want to enter in the direction of the stop. However, the code is not working. would you please help me finding the mistake:

    protected override void OnBarUpdate()
    {
    if (stopOrder01 != null && stopOrder01.Filled > 0)
    {
    EnterShort(Convert.ToInt32(Order01LotSize + Order02LotSize + Order03LotSize), "S11");
    SetStopLoss("S11", CalculationMode.Ticks, Order03SL, false);
    SetProfitTarget("S11", CalculationMode.Ticks, Order03PT, false);
    }
    }

    #2
    Hello Jorge.andres.o,

    Thanks for your post.

    You will need to use debug prints to check your work.

    Is the code reaching your Enter Short method?

    Please confirm by placing a print beside the order entry method.

    If the code is not reaching your EnterShort method, you will need to check the logic controlling this entry.

    Is stopOrder01 null?

    Is stopOrder.Filled greater than 0?

    Please confirm with a print for these properties that is placed just before your condition is evaluated.

    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

    As another tip, if your order submission methods are being reached but the order is not submitting, please follow the TraceOrders feedback for a hint as to why the order was ignored.

    TraceOrders - https://ninjatrader.com/support/help...raceorders.htm

    I also suggest calling Set methods when the strategy is flat, and before the next entry order is submitted. Set methods prep NinjaTrader to submit target and stop when an associated Enter order comes back as filled. If the Enter method is processed and comes back as filled immediately, the order target and stop might be ignored. They should not be submitted after an Enter method.

    Please see the example below for properly using Set methods in OnBarUpdate.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    6 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    41 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    20 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X