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

Question about BackColor

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

    Question about BackColor

    I have an indicator that contains the following statement:

    BackColor = Color.FromArgb(downIntensity,backColorDown);
    ...
    BackColor = Color.FromArgb(upIntensity,backColorUp);

    This indicator determines the proper color for BackColor from a higher timeframe.

    So if I run this indicator on a 5 minute chart, it determines the BackColor from a 10 min timeframe. This indicator is working correctly.

    My problem is when the chart is being updated in realtime, it won't change the BackColor to a different color when it should. It just continues to paint the next bar with the previous bar BackColor.

    But if I hit F5 to refresh the chart, then BackColor is updated correctly.

    How do I get the indicator to update BackColor in realtime?

    #2
    Hello,

    BackColor is able to update in real time, this sounds like an issue with the logic that changes the color.

    Can you provide a sample of this logic? If the color is remaining as the prior bars this would indicate something with the color variable you are using is not being reset or changed.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      I'm attaching a code snippet

      if( CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired ) return;

      //
      if( BarsInProgress == 1 )
      {
      /* Instantiate rcsPriceActionSwingGOMArrowsTrueClose */ _rcsPriceActionSwingGOMArrowsTrueClose = rcsPriceActionSwingGOMArrowsTrueClose(dtbStrengthS ,showArrowsS,swingSizeS,swingTypeS,tickSizeValueS, useCloseValuesS);
      /* Initialize rcsPriceActionSWingGOMArrowsTrueClose */ _rcsPriceActionSwingGOMArrowsTrueClose.PASGATC[0] = null;

      if( _rcsPriceActionSwingGOMArrowsTrueClose.PASGATC[0] == "Down" ) _currentTrend = "down";
      if( _rcsPriceActionSwingGOMArrowsTrueClose.PASGATC[0] == "Up" ) _currentTrend = "up";
      }

      if( BarsInProgress == 0 )
      {
      //Print(Time[0] + " " + "_currentTrend = " + _currentTrend);

      if( _currentTrend == "down" )
      {
      BackColor = Color.FromArgb(downIntensity,backColorDown);
      overallTrend.Set(0, "down");
      }

      if( _currentTrend == "up" )
      {
      BackColor = Color.FromArgb(upIntensity,backColorUp);
      overallTrend.Set(0, "up");
      }

      /*
      Print(Time[0] + " " + "_currentTrend = " + _currentTrend);
      Print(Time[0] + " " + "overallTrend[0] = " + overallTrend[0]);
      Print("");
      */

      }

      Regards,
      R. C.

      Comment


        #4
        Hello,

        I wont be able to run this but looking at the syntax and logic being used, I would suspect this is caused by _currentTrend not being reset to a blank string.

        in BIP == 1, I see you are setting it:

        Code:
        if( _rcsPriceActionSwingGOMArrowsTrueClose.PASGATC[0] == "Down" ) _currentTrend = "down";
        if( _rcsPriceActionSwingGOMArrowsTrueClose.PASGATC[0] == "Up" ) _currentTrend = "up";
        In BIP == 0, I see you are using it:

        Code:
        if( _currentTrend == "down" )
        {
        BackColor = Color.FromArgb(downIntensity,backColorDown);
        overallTrend.Set(0, "down");
        }
        
        if( _currentTrend == "up" )
        {
        BackColor = Color.FromArgb(upIntensity,backColorUp);
        overallTrend.Set(0, "up");
        }

        I would expect some sort of reset to " " for this variable, otherwise this is just a string which would carry its value to the next OnBarUpdate.

        So the _currentTrend == "down"

        the down color is set
        OnBarUpdate is called again but neither of the conditions to set _currentTrend become true, it remains "down".

        Because I can not run the script this is just an observation so if you are resetting this elsewhere in the script please ignore this. Otherwise I would recommend following that variable to see if it is reset on every bar, if not you will carry over the existing value.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Yes. I'm not resetting _currentTrend inside OnBarUpdate. I will try that tomorrow and reply again. Tx.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Brevo, Today, 01:45 AM
          0 responses
          3 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          3 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          239 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          384 views
          1 like
          Last Post Gavini
          by Gavini
           
          Started by oviejo, Today, 12:28 AM
          0 responses
          6 views
          0 likes
          Last Post oviejo
          by oviejo
           
          Working...
          X