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

NinzaRenko Wick Strategy

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

    NinzaRenko Wick Strategy

    Hello. I'm trying to create a strategy using NinzaRenko bars. Basically you'll get a series of green bars. Some will have wicks. If there is a second green bar with a wick in this series then I want to enter a short position immediately upon the close of that bar. Here are more details and below that a photo of exactly what I'm looking for. I've been working on this for a couple days now and I did make some headway but it doesn't always behave how I want it to. Anyone have any ideas on how to simply determine when there are two wick bars? Thanks for any help.
    1. Entry Condition: Look for a series of consecutive green bars.
    2. Wick Detection: Identify any green bar within the series that has a wick below the open.
    3. Second Wick Confirmation: Continue monitoring for a second green bar with a wick below the open within the series of green bars.
    4. Entry Trigger: If a second green bar with a wick below the open is found, enter a short position immediately on the next bar.
    5. Trade Validation: Ensure that the high of the entry bar is higher than the high of the previous bar with a wick below the open.
    6. No Entry 1st Green Bar: 1st green bar will always have a wick. Do not county this bar as a wick bar.
    7. Avoid Red Bar Entry: If the next bar after the second green bar with a wick is a red bar, do not enter a trade.
    Click image for larger version

Name:	image.png
Views:	830
Size:	30.7 KB
ID:	1253098
    ​​

    #2
    This is some code that produces the results I'm looking for at times but then other times it doesn't work as expected. Here is a screenshot of when it enters at the wrong time. As you can see there is only one bar with wick on the run of green bars and then it goes short at the close of the red bar after the run of green bars. It should have never entered a position at all.

    Click image for larger version  Name:	image.png Views:	0 Size:	15.1 KB ID:	1253100

    Code:
    // Set 1
                if    (
    
    
                    (Low[1] < Open[1])
                    && (Close[1] > Open[1])
                    && (Close[2] > Open[2])
    
                    )
                {
                    LookforSecondWick = true;
                }
    
                 // Set 2
                if ((LookforSecondWick == true)
                     && (Close[3] > Open[3])
                     && (Low[3] < Open[3]))
                {
                    TakeShort = true;
                }
    
                 // Set 3
                if ((Low[0] < Open[0])
                     && (TakeShort == true)
                    && (Position.MarketPosition == MarketPosition.Flat)
                    )
                {
                    EnterShort(Convert.ToInt32(DefaultQuantity), "");
                    TakeShort = false;
                    LookforSecondWick = false;
                }
    
                // Set 4
    
                if ((TakeShort == true)
                    && (Close[0] == Low[0])
    
                    )
    
    
                {
                    LookforSecondWick = false;
                }​
    Last edited by yeahdudeman; 05-25-2023, 11:59 PM.

    Comment


      #3
      although you need two bars to enter you need to check the 3 bars.
      since you always have the first bar with a spike.
      -----------------------
      create a list to store spiked bars.
      1. on each bar (on a bar update) check its green/red direction.
      2. red? list.size>0? Clear the list.
      3. green?
      4. check for low spike->
      5. spike is?
      6. to check the list size:
      7. <2? add to the list
      8. ==2? add to the list(or maybe delete the last bar) and open a position.
      -----------------------
      In order to avoid repeated entries on the same sequence of green bars,
      the list size is limited by checking for the presence of two bars(8).

      If the size is not equal to 2 each next green bar will be ignored.
      The entry will be only after the first 2 bars on 3bar (they reset to zero on the red bar(2)).
      unless, of course, you need it.
      if not and you wish to make entries after each series of 3 bars,
      just delete the last bar in the list when opening a position(8).​
      Last edited by Danila; 05-26-2023, 05:12 AM.

      Comment


        #4
        Problem is, with these types of Renko bars, the low is always below the open if it is a green bar. This is because usually the open is one tick above the previous bar and the low is instantly created a number of ticks below the open, where price hasn't even gone. This needs to be accounted for in your coding.
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          Thank you both.

          Danila - I understand what you are saying here but I'm not skilled enough with coding to know how to implement that. I was trying to take a different approach by having a bool turn true when there is a green bar after a red bar. Then since that bool turned true it would trigger the next set to look for a bar with a wick. Then when a wick is found it turns another bool true. That then allows the third set to look for a wick on a following bar (the second wick in the sequence of green bars). But in my tests it seems that everything just takes place at once instead of a sequence of events.

          eDanny - In my experience I haven't noticed that the low is always below the open on green NinzaRenko bars. I have made several other strategies that look for wicks with no problem. The problem here lies in trying to find the 2nd wick.

          Comment


            #6
            I did try to mess around with it earlier but I'm not getting any entries.

            Code:
            private List<int> spikeBars;
            
            {
            
                        if (CurrentBar <= 2)
                        {
                            spikeBars = new List<int>();
                            return;
                        }
            
                        if(CurrentBar < 100) return;
            
                        if (BarsInProgress != 0)
                            return;
            
                        if (CurrentBars[0] < 10)
                            return;
            
                        if (Close[0] > Open[0] && Close[1] > Open[1])
            
                            {
                        // Green bar, check for spike
                        if (Low[0] < Open[0])
                        {
                            // Spike detected
                            spikeBars.Add(CurrentBar);
            
                            if (spikeBars.Count == 2)
                            {
                                EnterShort();
                                spikeBars.Clear();
                            }
                        }
                        else if (spikeBars.Count > 0)
                        {
                            // Reset if no spike on a subsequent green bar
                            spikeBars.Clear();
                        }
                    }
                    else if (spikeBars.Count > 0)
                    {
                        // Reset on a red bar
                        spikeBars.Clear();
                    }​

            Comment


              #7
              Maybe there's a way to do this with the CountIf function?

              Comment


                #8
                Originally posted by yeahdudeman View Post
                I did try to mess around with it earlier but I'm not getting any entries.
                Code:
                private List<int> spikeBars;
                {
                if (CurrentBar <= 2)
                {
                spikeBars = new List<int>();
                return;
                }
                }​
                1. declare a List at the top of this class
                and then initialize it in a method the default or configuration.
                -------
                2. you added your thoughts to my vision of this implementation. read my post again.
                Rows are marked with numbers. where questions(?) are replaced by "if"
                write the code by rows and above each line write what you did.​

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by watson11, Today, 01:32 AM
                0 responses
                1 view
                0 likes
                Last Post watson11  
                Started by watson11, Today, 01:32 AM
                0 responses
                1 view
                0 likes
                Last Post watson11  
                Started by watson11, Today, 01:30 AM
                0 responses
                3 views
                0 likes
                Last Post watson11  
                Started by faisal00, Today, 12:34 AM
                0 responses
                2 views
                0 likes
                Last Post faisal00  
                Started by faisal00, Today, 12:33 AM
                0 responses
                1 view
                0 likes
                Last Post faisal00  
                Working...
                X