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 TradeSaber, Today, 07:18 AM
      0 responses
      7 views
      0 likes
      Last Post TradeSaber  
      Started by PaulMohn, Today, 05:00 AM
      0 responses
      9 views
      0 likes
      Last Post PaulMohn  
      Started by ZenCortexAuCost, Today, 04:24 AM
      0 responses
      6 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by ZenCortexAuCost, Today, 04:22 AM
      0 responses
      3 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      17 views
      0 likes
      Last Post SantoshXX  
      Working...
      X