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

RSI PaintBar error above 100

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

    RSI PaintBar error above 100

    Hi

    There is a new indicator posted in the NinjaScript File Sharing section that colors the bars based on indicator values.

    I was playing around with it and found that it doesn't work for charts where the stock or index is above approx 100.

    Wonder if there is any simple solution to this?

    PHP Code:
            protected override void OnBarUpdate()
            {
                
    // Opaque colors (alpha value defaults to 255 -- max value).
                
    Color red Color.FromArgb(25500);
                
    Color green Color.FromArgb(02550);
                
    Color blue Color.FromArgb(00255);
                
    Color backcolor Color.Empty;
                
                
                
    double rsiValue RSI(periodsmooth)[0];
                
    int rgbGreen 0;
                
    int rgbRed 0;
                
    rgbRed = (int) (255*(rsiValue)/100);
                
    rgbGreen 255-rgbRed;
                
    //Print("RSI: " + rsiValue + " Green: " + rgbGreen + " Red: " + rgbRed);
                
    backcolor Color.FromArgb(rgbRed,rgbGreen,0);
                
    BarColor backcolor;
            } 
    the output window gives this error,

    Error on calling 'OnBarUpdate' method for indicator 'JooRSIPaint' on bar 0: Value of '3062' is not valid for 'red'. 'red' should be greater than or equal to 0 and less than or equal to 255.

    #2
    Hello TremblingHand,

    You should be able to view this for all instruments by adding the following statement below OnBarUpdate() {

    if
    (CurrentBar < Period)
    return;

    This statement will allow the RSI to calculate properly before doing any of the other logic.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks that fixed it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by junkone, Today, 11:37 AM
      0 responses
      1 view
      0 likes
      Last Post junkone
      by junkone
       
      Started by quantismo, 04-17-2024, 05:13 PM
      5 responses
      34 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by proptrade13, Today, 11:06 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      34 views
      0 likes
      Last Post love2code2trade  
      Started by cls71, Today, 04:45 AM
      2 responses
      10 views
      0 likes
      Last Post eDanny
      by eDanny
       
      Working...
      X