Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I have a condition but don't know how to make it into a strategy

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

    I have a condition but don't know how to make it into a strategy

    Hi

    I would like to run this strategy and let NT tell me how many signals were generated. How often this condition happens per day off a 3' timeframe? How can export to excel? # of bars after green hammer to hammer failure?

    if(Low[1]<Low[2] && High[1]<High[2] && Low[0]<Low[1] && High[0]<High[1] && Close[1]<Open[1] && Close[0]>Open[0] && (Open[0]-Low[0])>5*(Close[0]-Open[0]) ) // GREEN HAMMER
    {

    DrawText("long"+CurrentBar.ToString(),false, "H", 0, Low[0] - (dist * TickSize),-10, Color.Lavender, new Font("Arial", 8), StringAlignment.Center, Color.Transparent, Color.Transparent, 0);

    }

    Example

    Example off a 3 minute chart

    DATE TIME SIGNAL
    09112015 1315 YES
    09122015 1409 YES
    Last edited by qitrader; 09-11-2015, 09:00 AM.

    #2
    Hello qitrader,

    Thanks for your post.

    We have a reference sample of how to write to a file which can then be imported into Excel. The reference is here: http://ninjatrader.com/support/forum...ead.php?t=3475 The reference sample shows writing the bar data but could easily be change to write what you want.

    Comment


      #3
      thanks for the reply

      How would I integrate my conditional formula into the sample streamwriter? any tips are appreciated

      if(Low[1]<Low[2] && High[1]<High[2] && Low[0]<Low[1] && High[0]<High[1] && Close[1]<Open[1] && Close[0]>Open[0] && (Open[0]-Low[0])>5*(Close[0]-Open[0]) )

      thanks

      Comment


        #4
        Hello qitrader,

        Thanks for your reply.

        Something like:

        if(Low[1]<Low[2] && High[1]<High[2] && Low[0]<Low[1] && High[0]<High[1] && Close[1]<Open[1] && Close[0]>Open[0] && (Open[0]-Low[0])>5*(Close[0]-Open[0]) )
        {
        sw.WriteLine(ToDay(Time[0]) + "HammerTime");
        }

        Comment


          #5
          How would I add Hour:minute:second?

          thanks

          Comment


            #6
            Hello qitrader,

            Thanks for your reply.

            Just remove the ToDay(). So you have Time[0]+" HammerTime");

            Comment


              #7
              I may be asking for too much but not my area of expertise as I'm still learning how to code. Maybe others can jump in and help me with this code. If i wanted the indicator to count how many bars it takes to take out the signal bar low (hammer), then plot the # in the text file. Thanks in advanced to whoever can respond.

              E.g.

              If Hammer = true, then When does Hammer Low gets taken? how many bars?

              thanks

              Comment


                #8
                Hello qitrader,

                Thanks for your post.

                Do you have a definition for what takes out a hammer low? Is it simply Close[0] < hammer bar Low? What happens if you have 2 hammers in a row? Can you provide a chart example of what you are looking for? (Use the "go advanced" selection to be able to post a picture.

                As an aside, have you looked at using the Ninjatrader indicator "CandlestickPattern" as it can be configured to show hammers as well as provide a chart count of how many. You can also add the indicator to the market analyzer which can be set to send an alert to the alerts panel when the pattern is found and in this way you get a timestamped output (which can be exported to excel). While this doesn't get your how many bars it may be of interest.

                Comment


                  #9
                  sure do.....

                  attached below. You will see i created an indicator labeling H when the hammer shows up. I want to know how many bars it takes to complete the failure. Failure means C[0] < Hammer Low.

                  In the screenshot, first one took 1 bar, 2nd one took 3 bars. There is a 3rd signal which is still active and hasn't fail.

                  thanks for replying
                  Attached Files

                  Comment


                    #10
                    another example
                    Attached Files

                    Comment


                      #11
                      Hello qitrader,

                      Thanks for your post and pictures.

                      Basically you would want to capture the bar number when you had the hammer signal and then subtract that from the current bar number when the low is broken to know how many bars have lapsed (or you could use a counter). Here is an example of the former:

                      if(Low[1]<Low[2] && High[1]<High[2] && Low[0]<Low[1] && High[0]<High[1] && Close[1]<Open[1] && Close[0]>Open[0] && (Open[0]-Low[0])>5*(Close[0]-Open[0]) ) // GREEN HAMMER
                      {
                      hStartBar = CurrentBar; // save the current bar for beginning.
                      hLow = Low[0]; // save the low value of the Hammer to compare later
                      }

                      if (Close[0] < hLow)
                      {
                      sw.WriteLine(Time[CurrentBar - hStartbar]) + "HammerTime" +" Bars: "+ (CurrentBar-hStartBar) + "till broken");
                      }

                      You would need to declare hStartBar as an integer variable and hLow as a double.

                      Here is the helpguide on CurrentBar: http://ninjatrader.com/support/helpG...currentbar.htm

                      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
                      367 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
                      571 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