Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss Issue

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

    Stop Loss Issue

    Hey! I'm very new to coding, so bare with me. This feels like an easy issue to solve but for some reason I can't seem to figure it out.

    My Goal: To have my initial stop loss set at the previous candle low, and move to breakeven when I'm 10 ticks in profit, and be set there the remainder of the trade.

    My Issue: In order for my stop loss to move to BE, I have to have the Strategy setup to calculate "On each tick". However, when I set the strategy to "On each tick", the initial stop loss doesn't even show up.

    I'm assuming the issue is because the Method I have both stops in is OnBarUpdate() ?
    Again, I'm extremely new to this so any insight or help is much appreciated.

    Here's a look at the code
    Click image for larger version

Name:	Screenshot (592).png
Views:	268
Size:	265.7 KB
ID:	1177839

    #2
    Hello perrytradez,

    Thanks for your question.

    When processing OnEachTick or OnPriceChange BarsAgo 0 references will represent the developing bar, when using OnBarClose, BarsAgo 0 references reflect the bat that had just closed.

    Also keep in mind that when using Calculate.OnEachTick and OnPriceChange, historical data is still going to be processed following OnBarClose behaviors. Once the strategy starts processing realtime data, it will then be cable to process following OnEachTick or OnPriceChange behaviors.

    Something else to keep in mind is that if a stop loss is submitted to the other side of the market (If Low[0] reflects a price level that ends up being on the other side of current bid/ask prices when the order is processed) the order would be rejected. When processing historical data, rejected orders are ignored.

    You could consider triggering your entry condition for a check of IsFirstTickOfBar so the entry happens on bar closes, and to change the Low[0] reference to Low[1], so it reflects the previous bar's low, after we get the first tick of a new bar. Otherwise, you could consider comparing Low[0] to GetCurrentBid, to make sure Low[0] is less than the current bid price and would be valid for a Sell Stop Market Order. You can also consider using GetCurrentAsk/GetCurrentBid to offset your initial stop at a greater distance if Low is not a valid price for the stop loss.

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    GetCurrentAsk - https://ninjatrader.com/support/help...currentask.htm

    GetCurrentBid - https://ninjatrader.com/support/help...currentbid.htm

    We look forward to assisting.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X