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

Cyclic Smoothed RSI V2 for NT8 - Help

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

    #16
    This worked great. I'll post the final code for clean up ideas a little later. Thanks again for all the help!
    The top picture is on NT and the bottom is from TradingView. Exact duplicates!


    Click image for larger version

Name:	image.png
Views:	164
Size:	75.7 KB
ID:	1266268

    Comment


      #17
      This is my completed code for this indicator. Thank you to everyone that helped out! If anyone would like to optimize the code provided and repost, I would appreciate that as well. For some reason the indicator will not save to the layout when I exit the program and I need to add it to the chart every time I re launch it. Any ideas as to why this is? I assume it is something I wrote in the code but I am not sure
      RSIcyclicSmoothedV2.cs

      Comment


        #18
        Hello imakenocents,
        you need to serialize the brushes (take a look the codes I uploaded).
        And you need to set the property 'ShowNormalRSI' as public.
        Last edited by cls71; 09-04-2023, 03:44 AM.

        Comment


          #19
          Hello imakenocents,

          Thanks for your notes.

          As cls71 stated, you would need to serialized the brushes that are being used in the script and you would need to set the 'ShowNormalRSI' property to be public, such as public bool ShowNormalRSI.

          See this help guide page for more information about saving a Brush as a user defined property (Serialization): https://ninjatrader.com/support/help...tsub=serialize



          Brandon H.NinjaTrader Customer Service

          Comment


            #20
            Hello again NinjaTrader_BrandonH
            Everything has been running fine with this indicator until today on my hourly chart. For some reason the red cloud is not filling this session on ES. Is there something in my code that may be causing this to happen? This is not happening on NQ or any other contract.​ I updated the code with the suggestions from previous posts and everything has been working fine until today.​ Can you take a look and see if any issues stick out to you? It's the lower indicator in the picture.
            [ATTACH]n1271214[/ATTACH]
            Click image for larger version

Name:	image.png
Views:	127
Size:	280.6 KB
ID:	1271216
            Attached Files

            Comment


              #21
              Hello imakenocents,

              Thanks for your notes.

              When testing the indicator on my end I see it working as expected. When the RSI Cyclic plot crosses below the Lower Band plot and then crosses above the Lower band plot, the region is drawn on the chart in the space where the crossover conditions occured.

              See the attached image.

              In your screenshot, the RSI Cyclic plot has not crossed back above the Lower Band plot so the region had not been shaded yet. The CrossAbove() condition in your code would need to become true before the Draw.Region() method is called as seen in your section of code below.

              Code:
              if (CrossBelow(Values[0], Values[2], 1))
                  lastCrossBelowLower = CurrentBar;
              else if (lastCrossBelowLower.HasValue && CrossAbove(Values[0], Values[2], 1))
                  Draw.Region(this, "BelowLower" + CurrentBar, 1, CurrentBar - lastCrossBelowLower.Value, Values[0], Values[2], null, CloudDown, CloudOpacity);​
              Attached Files
              Brandon H.NinjaTrader Customer Service

              Comment


                #22
                Thank you NinjaTrader_BrandonH
                I had just actually noticed that it was doing that right before your post. Is there any way to get the area to shade after the lines cross at first and not wait until the recross back? I am a little stuck with how Draw.Region works with bar numbers rather than plot lines. Possibly a recursive statement with a new variable for the bar number when the lines first cross that goes to null after the recross? I am not sure if I am on the right track.
                I tried using "&& Values[0][0] <= Values[2][0]" instead of the "CrossAbove..." part but I am getting some strange gradient for the fill now. Any suggestions?

                Click image for larger version

Name:	image.png
Views:	129
Size:	30.7 KB
ID:	1271237

                Comment


                  #23
                  Actually, looking back at the previous posts, I think I would need to use the OnRender() function with coordinates for the shaded area and SharpDX stuff. Might need to just leave this one as is

                  Comment


                    #24
                    Hello imakenocents,

                    Thanks for your notes.

                    You could consider using a bool to control how the logic in your script functions. A class-level bool variable could be created called something like 'drawRegionBool'. In your condition where you check if (CrossBelow(Values[0], Values[2], 1)), you could set the bool to true.

                    Then, in your else if condition you could check if the bool is true, remove the CrossAbove() condition, and call the Draw.Region() method.

                    Another condition could be created that checks for your CrossAbove() condition and set the bool variable to false. By doing this, the DrawRegion() method would be set to true when the RSI Cyclic plot crosses below the Lower Band plot. When the RSI Cyclic plot crosses back above the Lower Band plot, the bool will be false and Draw.Region() would not be called.

                    For example:
                    Code:
                    //class-level variable
                    private bool drawRegionBool;
                    
                    //OnBarUpdate()
                    if (CrossBelow(Values[0], Values[2], 1))
                    {
                        lastCrossBelowLower = CurrentBar;
                        drawRegionBool = true;
                    }
                    else if (lastCrossBelowLower.HasValue && drawRegionBool)
                        Draw.Region(this, "BelowLower" + CurrentBar, 1, CurrentBar - lastCrossBelowLower.Value, Values[0], Values[2], null, CloudDown, CloudOpacity);
                    
                    if (CrossAbove(Values[0], Values[2], 1))
                    {
                        drawRegionBool = false;
                    }​
                    Or, you could use OnRender() and SharpDX to accomplish this in your script.

                    The Ichimoku Cloud indicator from the NinjaTrader Ecosystem User App Share linked below demonstrates how OnRender() and SharpDX could be used to draw a region between two series.

                    Ichimoku Cloud: https://ninjatraderecosystem.com/use...indicator-nt8/


                    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #25
                      Thank you NinjaTrader_BrandonH , I wrote the following response before seeing your reply above. Thank you for all the help on this!

                      UPDATE --> Seeing the gradient made me realize that the Draw.Region function recursively shades the area every time the criteria is met, even if it had been shaded already. Thus, only 1 bar need be shaded at a time and the indicator will retain its single-pass color. The following code enabled 1 section shading at a time and effectively did what I wanted by not waiting until the re-cross to shade the area. It was actually a simple fix.

                      Code:
                      if(UseClouds)
                      {
                      if (CrossAbove(Values[0], Values[1], 1))
                      lastCrossAboveUpper = CurrentBar;
                      else if (lastCrossAboveUpper.HasValue && Values[0][0] >= Values[1][0])
                      Draw.Region(this, "AboveHighBands" + CurrentBar, 0, 1, Values[0], Values[1], null, CloudUp, CloudOpacity);
                      
                      if (CrossBelow(Values[0], Values[2], 1))
                      lastCrossBelowLower = CurrentBar;
                      else if (lastCrossBelowLower.HasValue && Values[0][0] <= Values[2][0])
                      Draw.Region(this, "BelowLowBands" + CurrentBar, 0, 1, Values[0], Values[2], null, CloudDown, CloudOpacity);
                      
                      }
                      Last edited by imakenocents; 10-03-2023, 10:27 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by burtoninlondon, Today, 12:38 AM
                      0 responses
                      9 views
                      0 likes
                      Last Post burtoninlondon  
                      Started by AaronKoRn, Yesterday, 09:49 PM
                      0 responses
                      14 views
                      0 likes
                      Last Post AaronKoRn  
                      Started by carnitron, Yesterday, 08:42 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post carnitron  
                      Started by strategist007, Yesterday, 07:51 PM
                      0 responses
                      13 views
                      0 likes
                      Last Post strategist007  
                      Started by StockTrader88, 03-06-2021, 08:58 AM
                      44 responses
                      3,983 views
                      3 likes
                      Last Post jhudas88  
                      Working...
                      X