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 sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        78 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        313 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        319 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        149 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        115 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X