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

Renko Bar Strategy

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

    Renko Bar Strategy

    Hi Everyone, I need help. I have been trying to figure it out by myself but i am stuck. I have a strategy built on Renko Bars, I want to go Long when it forms a green brick after touching the lower BB. See the attached image. However, i am finding it hard to place the trade on the next green bar after touching the lower BB. I understand that the next green bar can be coded as close[0]> open[0] but it seems not to be working on this Renko Bar. Please help me




    Click image for larger version

Name:	image.png
Views:	222
Size:	247.8 KB
ID:	1283275



    Attached Files

    #2
    Somebody help me

    Comment


      #3
      Hello iamhamid,

      The Close[0] > Open[0] would be a green bar.

      Attached is an export demonstrating this condition drawing a green dot when Close[0] > Open[0] and a red dot when Close[0] < Open[0].
      IamhamidTest_NT8.zip

      For your condition, print the time of the bar and ALL values used in the condition with labels for each value AND comparison operator.

      The forum post below demonstrates creating an informative print.


      Save the output from the NinjaScript Output window to a text file and attach the text file to your next post.
      I will be happy to analyze the output and help you understand the behavior.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello Chelsea, thank you so much for helping out. I have attached my strategy below. I want to take long position on the next green renko bar after touching the lower BB and the Closing price is above MA(14) and take short on the next red Renko bar after touching the upper BB and closing price is below MA(14). I have done all the configuration but it seems not to be working. Once again, thank you for helping
        Attached Files

        Comment


          #5
          It's triggering entries on the touch of the BB. This is the first parameter, but it must wait to form the opposite brick. You can see how it is touching the BB for many bricks in a row, but will take entry on the first touch. It should wait until the first opposite brick. I used close[0] > open[0] to confirm if the Renko bar is green before going on long, but it's not working.
          Attached Files

          Comment


            #6
            Hello iamhamid,

            You can use bools to require two conditions to be true in sequence on non-consecutive bars.

            Below is a link to an example.
            Hi, To improve a strategy, I would like the condition to enter a trade to be triggered only after a second crossing happens. Meaning, for instance we have a sthocastics crossing, but the strategy would only trigger when a crossing between 2 emas happen. Would the looking back N bars work? Can it be done within the builder


            With the example I have provided, you can see this condition does properly evaluate as true for green bars.

            For your condition add the suggested prints, enable TraceOrders, and provide the output.
            I'll need this to assist. This will let us know why the condition is true or false.

            I see your script is created with the Strategy Builder. Please be sure to watch the video 'Debugging using prints with the Strategy Builder' in the forum post linked in post # 3.

            Print
            1. the time > date series
            2. print a label for and the value of the Price > Close with 0 bar ago, a greater than symbol, a label for and the value of the Indicator > bollinger > Plotlower of 10bar ago
            3. print a label for and the value of the close with 0 bar ago, a less than symbol, a label for and the value of the bollinger lower of 0 bar ago
            4. print a label for and the value of the Indicator > SMA with Period set to User Inputs > Length with 0 bar ago, a less than symbol, a label for and the value of SMA with Period set to User Inputs > Length with 1 bar ago
            5. print a label for and the value of the Strategy > Current market position, a label this should equal Flat
            6. print a label for and the value of the of the Price > Close with 0 bar ago, a greater than symbol, a label for and the value of the Price > Open with 0 bar ago
            With this output, we can determine which of the conditions in the set is not evaluating as true when you expect, and the TraceOrders will let us know when orders are being ignored due to managed approach order handling rules.

            Save the output to a text file, attach this to your next post.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea, I appreciate your assistance. Here is the output you requested for. When i add the Close[0]>Open[0], it's not picking up any trade. However, i think the right approach is to use bools to require two conditions to be true before triggering the order. For instance, create a set one when the lower Bolinger touches the close and the SMA[0] <SMA[1], i want to save this outcome on a variable. Then the second condition is when the bar is green, save this on another variable. When both conditions are true, then place long trade. How do i go about this in ninja strategy builder?
              Attached Files

              Comment


                #8
                Hello iamhamid,

                I'm seeing at 12/11/2023 7:04:55 this is the only time all of the conditions evaluated as true.

                12/11/2023 7:04:55 PM | Close : 4670.75 | < LowerBB : 4601.95500026421 | SMA[0][14] 4642.78571428572 | < SMA[1][14] : 4638.39285714286 | Flat : Flat | Close[0] 4670.75 | > Open[0] 4660.75

                And it does appear there was an order submitted.

                12/11/2023 10:59:58 PM Strategy 'RRR/314742690': Entered internal SubmitOrderManaged() method at 12/11/2023 10:59:58 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Short' FromEntrySignal=''

                Is there a specific bar time you would like to analyze why the condition was not true?


                "For instance, create a set one when the lower Bolinger touches the close and the SMA[0] <SMA[1], i want to save this outcome on a variable. Then the second condition is when the bar is green, save this on another variable. When both conditions are true, then place long trade. How do i go about this in ninja strategy builder?"

                May I confirm you have imported and opened the example I have provided in post # 6 in the Strategy Builder you that shows how to use a bool to require two conditions to evaluate as true on non-consecutive bars?

                Do you have specific questions about something you are not understanding in the example?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chelsea, thanks for getting back to me. This is no time the conditions were evaluated as true, if you look at the date you posted above, SMA[0][14] 4642.78571428572 | < SMA[1][14] : 4638.39285714286 is not true because 4642.78 is not less than 4638. From my understanding, having gone through many posts on this forum, i think the best approach is to save the first condition, and trigger the trade when the first and second is true.

                  I am trying to do this using the example you provided in post Special but i am not getting it. For instance, i want to save the Bolinger and Moving average condition when they are true, then trigger the trade on the second condition when bar is green. I will appreciate if you can guide me through the process. Thanks once again

                  Comment


                    #10
                    Hello iamhamid,

                    Thank you for your reply.

                    Please provide screenshots of your Conditions and Actions that you have set up for the Bollinger and moving average condition as well as the second condition when the bar is green so we may better understand and assist with guiding you through the process.
                    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
                    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
                    ​Once we have an idea of how you currently have your conditions and actions set up, we would be glad to provide you with the next steps to understand why the strategy is or is not behaving as expected and identify what parts of your conditions/actions may need to be modified.

                    We look forward to your reply.
                    Emily C.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Emily, thanks for getting in touch. Following Chelsea's suggestion in Post #6, I tried to set up 4 sets to achieve my aim. See the attached images. I want to buy when the price is above MA and the lower Bolinger touches the bar, the buy order should on the next green bar after bollinger touches the bar. But unfortunately the buy order is being executed on the third bar after touching the bollinger and above MA. See the two red arrows in the image[1] attached. Also see my codes in the image[2] attached. Additionally, some buy orders are being executed below the MA which is not what i want. I want all buy orders to be above MA. I will be looking forward to your response
                      Attached Files

                      Comment


                        #12
                        Hello iamhamid,

                        It appears set 4 must be true first, then on a later bar set 3 must be true second, then on a later bar set 2 must be true third.

                        The use of bools does appear to be correct here.

                        I will again need the output from prints for the modified code to analyze and understand why the 3 condition sets have not evaluated as true when you are expected.

                        Start debugging with Set 2, and print the time of the bar and all values in the condition along with labels for each value and comparison operator.

                        Attach the output text file to your next post and I will be happy to take a look.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chelsea, i really appreciate your efforts. You guys at NinjaTrader have been awesome. Based on your request, here is the output text for set 2 and also find attached the image for the trade. it should be picked on the first green bar, but it is not.
                          Best regards
                          Hamid
                          set2.txt
                          Attached Files

                          Comment


                            #14
                            Hello iamhamid,

                            Print ALL of the values from ALL conditions in the set.

                            You have the datetime close greater than open, which is a great start.

                            Also print a label for ActionTriggered, the value of ActionTriggered, and a label for == false.
                            Print a label for Position.MarketPosition and the value of Position.MarketPosition (Current market position), a label for == Flat.
                            Print a label for TrigerSet and the value of TrigerSet, and a label for == true.
                            Print a label for T2 and the value of T2, and a label for == true.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Chelsea, Thanks once again. I have printed all the values for all conditions. The condition for T2 is to be set to True when Close price is above SMA, I observed that there are many instances where Close < SMA and it is set to true. I do appreciate you effort.

                              Best Regards
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RaddiFX, Yesterday, 09:55 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post RaddiFX
                              by RaddiFX
                               
                              Started by geotrades1, Today, 08:33 AM
                              4 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Entwaze, 02-19-2024, 07:13 PM
                              2 responses
                              68 views
                              0 likes
                              Last Post MalachiHatfield  
                              Started by tkaboris, Today, 08:32 AM
                              5 responses
                              8 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by f.saeidi, Today, 07:07 AM
                              3 responses
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X