Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Output window and Data box showing different values

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

    #16
    Hello,

    Thank you for the post.

    This looks to be caused becasue the indicator is being set in Initialize. This should be set from OnBarUpdate in bar 0 instead:

    Code:
    private Stochastics stochK; 
    
    protected override void Initialize()
    {
    	Add(new Plot(Color.Blue, "StochK0"));// [0]
    	Add(new Plot(Color.Blue, "StochK1"));// [1]
    	Add(new Plot(Color.Blue, "Stoch42"));// [2]
    	Add(new Plot(Color.Blue, "StochK"));  // [3]
    
    	CalculateOnBarClose = true;
    }
    
    protected override void OnBarUpdate()
    {
    	if(CurrentBar == 0) stochK = Stochastics(7,3,14);
    	StochK[0] = stochK.K[0]; 
    }
    [Browsable(false)] 
    [XmlIgnore()] 
    public DataSeries StochK
    {
    	get { return Values[3]; }
    }
    I look forward to being of further assistance.

    Comment


      #17
      Thanks for the help!
      It all printed properly this time. Unfortunately I am still experiencing the original problem. The indicator line is printing identical to a regular stochastics K(7,15,3) line (that's new) but in Output window the code value is showing a slightly different value. This only happens when the Stochastics(7,15,3).K line in the Data Box value is showing 0. The value of the stochK in the code never reaches 0, it's always 1.89... or 1.34... etc. What is the reasoning behind the discrepancy?

      Code:
      private Stochastics indicator_stoch; 
      double stochK;
      
      protected override void OnBarUpdate()
       {
      if(CurrentBar == 0) 
            indicator_stoch = Stochastics(7,15,3);
            stochK = indicator_stoch.K[0];
            Values[3][0] = stochK;
      }

      Comment


        #18
        Hello,

        Thank you for the reply.

        Could you review the following image, is this what you are seeing or the top line in the Output Window?



        If so, this could be expected due to how floating point numbers are formatted when printed. This is exponential notation and If that is the case and you are just getting an exponentially long 0 number the solution would be to use a Print that formats to account for that:

        Code:
        Print(Time[0] + " " + StochK[0].ToString("#.#######################################"));


        Visually this can be confusing, math-wise the computer will compare the correct value of 0.xxxxxx and not what you see or 1.98xxxxxxE13.


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X