Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    19 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    119 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X