Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Paul H.NinjaTrader Customer Service

    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");
        }
        Paul H.NinjaTrader Customer Service

        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");
            Paul H.NinjaTrader Customer Service

            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.
                Paul H.NinjaTrader Customer Service

                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
                      Paul H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by judysamnt7, 03-13-2023, 09:11 AM
                      4 responses
                      57 views
                      0 likes
                      Last Post DynamicTest  
                      Started by ScottWalsh, Today, 06:52 PM
                      4 responses
                      36 views
                      0 likes
                      Last Post ScottWalsh  
                      Started by olisav57, Today, 07:39 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post olisav57  
                      Started by trilliantrader, Today, 03:01 PM
                      2 responses
                      20 views
                      0 likes
                      Last Post helpwanted  
                      Started by cre8able, Today, 07:24 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X