Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to program stop on close at close price

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

    How to program stop on close at close price

    Hi all, wondering if somebody could please help me with a small issue i'm having in the Ninjascript development on a strategy that uses daily data only.

    My strategy generates a stop order everyday based on a historical indicator. I should be able to fill that stop order if the current daily bar has its low < stop order, and its high > stop order. If both these conditions are true, then I simply want to be filled at the stop level and then exit my position at the end of the day at the bar close.

    I want to stick with daily data, not intraday, and this should be possible to implement, but so far I am having no luck. I have tried setting 'exit on close' to true but that doesn't help, I have also tried setting an exit condition based on the current bar being <> previous bar, but that also failed.

    Any simple solutions to this? Thank you for your help and time!

    #2
    foxido, welcome to our forums and thanks for the post - unfortunately you would need to work with intraday data in this case to be able to submit orders to a finer timeseries to exit on the close or slightly before it. The general concept can be reviewed here -

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


    For realtime trading, you could also program a time condition into the strategy and set CalculateOnBarClose to false -

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X