Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Candle counter

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

    Candle counter

    Good morning, I want to create a candle counter from the moment I open a trade until I close it, with the count appearing above each candle. Can this be done with an indicator or does it have to be done through a strategy?

    #2
    Hello,
    Thanks for writing in.

    That can be accomplished by using an Event counter or a Bar counter. While it is possible to do so with an Indicator or Strategy, we have an example that demonstrates how this can be accomplished using a strategy that is developed on the Strategy Builder.
    The main concept to understand is that you can use a custom series on the strategy builder to perform the math count from the moment you enter a trade until you exit the trade.
    Within your conditions and actions, you can set when the counter will start and when it will reset. Also, from within the conditions and actions, you will be able to draw objects or texts to display your bar counter.

    The first Link below contains an overall review of how to use a custom series to perform the math necessary to count a number of bars or events:


    The second link contains the event counter or bar countersample scripts and break down of the sets of conditions and actions to accomplish that:
    https://support.ninjatrader.com/s/ar...language=en_US




    Comment


      #3
      Create a strategy, count renko candlesticks, only when the trade is in positive and in the direction of the trade, bullish for log and bearish for short. It also respects the levels, e.g:

      In long you open a trade and in the first candle marks 1 the price goes against and when going up again that candle which is at the same level marks 1 again, not 2. Attached image.

      Click image for larger version

Name:	ope.png
Views:	179
Size:	8.0 KB
ID:	1339300

      The problem is when closing the operation, if the price touches the stop loss or take profit, everything is fine, but if I close manually the strategy is deactivated and I do not know why.​ I do not know if it is something internal to nijatrader or something in the code.

      Comment


        #4
        Thanks for your response.

        To answer the first part of your question, it seems that the condition to draw a number on the bar is only staying true for bars that are going in the direction of your trade, long or short. You need to ensure that this condition stays true for all bars.
        If needed, please provide a print from the NinjaScript Output and we can further investigate.

        When it comes to closing a trade manually, the behavior that you're experiencing is expected. When you manually hit the "Close" button, it exits your account and strategy position and disables the strategy. To exit a position from your strategy, the logic has to come from the strategy itself. Natively, It's not possible to close a strategy manually but there's an option to accomplish that. You can add a button to submit an order through the strategy. This link contains an example of how to do so.

        Below you will find more information to better understand the difference between your strategy position and account position as well as a general help guide for NinjaScript.

        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X