Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Added Short Side to SampleBreakoutStrategy

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

    Added Short Side to SampleBreakoutStrategy

    Hello,

    I've tried to add a short side condition to the SampleBreakoutStrategy. I wasn't able to get both horizontal lines plotting even though they have unique tags. Haven't run a replay to see if it's taking trades there either.

    Not sure if there's other items that would need correcting.

    Any help you can give is much appreciated.

    Kirk
    Attached Files

    #2
    Hello,

    I took a quick look at your strategy and I did not see any red flags.

    I suggest debugging your code using this link:
    DenNinjaTrader Customer Service

    Comment


      #3
      zeller4,

      In case Bars.FirstBarOfSession is the lowest low already, you wouldn't see a horizontal line for the lowest low. For this condition you could insert the two DrawHorizontalLine() commands into the "if_(Bars.FirstBarOfSession)_{}" section.

      Regards
      Ralph

      Comment


        #4
        Ralph, Ben, or whomever can help...

        Thanks, I've done that as well as add some print lines to see what's happening. I'm not sure how to reset the BarsSinceEntry to 0 so that there's nothing going on from a previous day. Also, as per the attached screenshot, the low line is not holding to the lowestLow value as the highestHigh is doing...

        Any help you can give me is much appreciated.
        Attached Files

        Comment


          #5
          Hi zeller4,

          had a closer look at your sample. And finally it works as expected.
          Here is what I did:
          • I commented out the order section of your code, because wanted to deal with the graphics only
          • At 3 different occurences you do use if-statements without brackets. Notice this syntax would involve the very next line only.
          • At 2 occurences you commented out the DrawHorizontalLine()-commands. I re-animated them.
          • I used replay data of a single day for testing. In the strategy setup table I set Min-bars-required to 0, otherwise I would have missed the if-(Bars.FirstBarOfSession)-section of your strategy. I removed the if-(CurrentBar < 10)-command from your code for the same reason.
          • I removed the if-(Bars.BarsSinceSession)<30-statement from your code, otherwise I wouldn't have seen the new higher-high-line for my sample data.
          Thats all, I attached the chart for my testing.

          Regards
          Ralph
          Attached Files

          Comment


            #6
            Hi Ralph,

            I revised most of what you said, thanks for the advice. Not sure what you mean by "strategy setup table" or how to do a Min-bars line...


            Originally posted by Ralph View Post
            In the strategy setup table I set Min-bars-required to 0, otherwise I would have missed the if-(Bars.FirstBarOfSession)-section of your strategy. I removed the if-(CurrentBar < 10)-command from your code for the same reason.
            Could you please attach a sample of that line or two to show what you mean?

            Thanks very much for your help.
            Regards,

            Kirk

            Comment


              #7
              Hi Kirk,

              after opening a chart I can select a strategy by clicking on the $-sign at the top of the chart. Then the setup table shows up. It is the same/similar process as for the strategy analyser back-testing. Please look at the attached JPEG file, the concerning statement is marked red. I also uploaded the strategy file as I used it.

              Regards
              Ralph
              Attached Files

              Comment


                #8
                Ralph,

                Thanks very much - I appreciate your improvements and steering me correctly with the if statements with no brackets.

                Learned something new today.

                Regards,
                Kirk

                Comment


                  #9
                  You are welcome, Kirk. I think it is good practice to think carefully about the initialisation of a strategy, as you could see with this example. Many strategies need to collect some previous bars before starting. So you may not see what you expect to see at the beginning of runtime (i.e. the very first FirstBarOfSession).

                  Happy coding
                  Ralph

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  625 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  359 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  562 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  567 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X