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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Lumbeezl, Today, 01:20 AM
    0 responses
    4 views
    0 likes
    Last Post Lumbeezl  
    Started by fawzanalim, Yesterday, 05:59 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by JuanPabloQuevedo, Yesterday, 05:27 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by StevenNelson, Yesterday, 03:24 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by my-trade, Yesterday, 10:45 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X