Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A Little Help For My Indicator

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

    #16
    Originally posted by lee612801 View Post
    Hi koganam,

    I added what you suggested and looks like it is working well for only doing what I want (calculating the dailyValue) only once a day! Now the most important question is how to get it to sum these values... When I check the output, it shows the dailyValue changing, but I would like a running sum of the dailyValue as follows:

    Ex) dailyValue for 4/21 = -0.35
    dailyValue for 4/22 = -0.77 Running sum @ 4/22 = -.35 + (-.77) = -1.12
    dailyValue for 4/23 = 0.989 Running sum @ 4/23 = -1.12 + .989 = -0.131

    So, do I need to store this dailyValue from each iteration? Should I use a Value.Set?? How would you suggest I do this and should it go outside the block of what you suggested before?

    Example:
    protected override void OnBarUpdate()
    {

    if (CurrentBar < 1) return;
    if Time[1].Date != Time[0].Date

    { dailyValue Calculation here(only once a day)......
    .................................................. ...............................
    .................................................. ...............................
    }

    Running Sum goes here???

    }



    Also, the only other issue with the new script is now it wont seem to plot any values when calculating only once a day...??? Not sure what this issue is, but I would like to take it one problem at a time and work the running sum.

    Thank you again for all your help,

    Lee
    I took another look at your code. There is a different logical issue here. You have COBC = true, and then you are trying to calculate the lastRange based on a time of 1559hrs. That means that your lastRange for today will only be correctly calculated on the bar that next opens after today's close. Depending on the session template that you are using, that could mean that the calculation will only be done when the the first bar opens on the next day.

    Then also looking at the logic of the code, if SMI is being set to runningValue1, and runningValue1 = (dailyValue+Close[0]), which is directly calculated from the dailyValue, then why exactly are you trying to accumulate a value at all?

    Comment


      #17
      Hi koganam,

      The short answer is, because I'm not very good But I was able to get the runningsum to add for each days value! I would have to attribute this to your help and my stubborness. So I changed the code to set the dailyValue using:

      dailyValue = (-openDailyChange+lastDailyChange);
      Value.Set(dailyValue);

      Then the running sum is:

      runningValue1 = (Value[1]+Value[0]);

      And it worked!! I still don't completely understand why, because I don't understand how it knows the Value is dailyValue... What happens if I had 10 Value.Sets ??? Anyway, it is summing as I would like now, but I am interested in the COBC issue...

      I changed COBC to false, and it still calculated the same, but I think that is because today's trading is still active. I want it to calculate for the current day's range, I don't want to wait until the next day.. So should I just change it to COBC=false and then it will calculate for that days range and be done with it?

      Also, the last thing I would like to add is to start with the first day's closing value as the part of the dailyValue calculation as shown here:

      Ex) dailyValue + Close for 4/21 = -0.35 + 187.04 = 186.69
      dailyValue for 4/22 = -0.77 Running sum @ 4/22 = 186.69 + (-.77) = 185.92
      dailyValue for 4/23 = 0.989 Running sum @ 4/23 = 185.92 + .989 = 186.91

      So I have the dailyValue calculating correctly and summing, I just want to add the close from the first days range of data, but I am not sure where to start on this. Any help would be appreciated.

      Thanks again

      Lee
      Attached Files

      Comment


        #18
        Originally posted by lee612801 View Post
        ... I just want to add the close from the first days range of data, but I am not sure where to start on this. Any help would be appreciated.

        Thanks again

        Lee
        Looking at your code, it seems that it already does that. Why do you think that it does not?

        Comment


          #19
          Hi koganam,

          The code currently just sums the dailyValue as follows:

          dailyValue for 4/21 = -0.35
          dailyValue for 4/22 = -0.77 Running sum @ 4/22 = -.35 + (-.77) = -1.12
          dailyValue for 4/23 = 0.989 Running sum @ 4/23 = -1.12 + .989 = -0.131

          But I would like to insert the first days closing price as the baseline to start from and then just add the dailyValue to that starting point as follows:

          dailyValue + Close for 4/21 = -0.35 + 187.04 = 186.69
          dailyValue for 4/22 = -0.77 Running sum @ 4/22 = 186.69 + (-.77) = 185.92
          dailyValue for 4/23 = 0.989 Running sum @ 4/23 = 185.92 + .989 = 186.91

          Adding this closing price only once at the beginning is where I am having some trouble. I changed the code somewhat, but its still now adding just the first days closing price. It's adding the closing price from every day to that day's dailyValue.

          Any help is greatly appreciated.

          Thanks,

          Lee
          Attached Files

          Comment


            #20
            Originally posted by lee612801 View Post
            Hi koganam,

            The code currently just sums the dailyValue as follows:

            dailyValue for 4/21 = -0.35
            dailyValue for 4/22 = -0.77 Running sum @ 4/22 = -.35 + (-.77) = -1.12
            dailyValue for 4/23 = 0.989 Running sum @ 4/23 = -1.12 + .989 = -0.131

            But I would like to insert the first days closing price as the baseline to start from and then just add the dailyValue to that starting point as follows:

            dailyValue + Close for 4/21 = -0.35 + 187.04 = 186.69
            dailyValue for 4/22 = -0.77 Running sum @ 4/22 = 186.69 + (-.77) = 185.92
            dailyValue for 4/23 = 0.989 Running sum @ 4/23 = 185.92 + .989 = 186.91

            Adding this closing price only once at the beginning is where I am having some trouble. I changed the code somewhat, but its still now adding just the first days closing price. It's adding the closing price from every day to that day's dailyValue.

            Any help is greatly appreciated.

            Thanks,

            Lee
            Code:
            //Variables
            private bool IsFirstDayOnChart = true;
            Code:
            //OnBarUpDate
            if (CurrentBar < 1) return;
            if (IsFirstDayOnChart && Time[1].Date != Time[0].Date)
            {
            dailyValue = Close[1]; //yesterday's close, recognized after the day changed
            IsFirstDayOnChart = false; //shutoff further entry into this block.
            }
            Last edited by koganam; 05-09-2014, 06:56 AM.

            Comment


              #21
              Hi koganam,


              I added your recommended code and it is working now with the option to use the first days close. Thanks again for all your help. I am now going to work on improving aesthetics of the indicator. So I'm sure I'll be coming back to ask a few questions

              As a side note, I am having an issue with non-trading days showing up on a multi-timeframe (daily & 15 min) chart I'm using for this indicator with historic data for the intraday range. Not sure if this is normal, but I plan to start a new thread on that.

              I attached the current version for all.

              Regards,

              Lee
              Attached Files

              Comment


                #22
                Originally posted by lee612801 View Post
                Hi koganam,


                I added your recommended code and it is working now with the option to use the first days close. Thanks again for all your help. I am now going to work on improving aesthetics of the indicator. So I'm sure I'll be coming back to ask a few questions

                As a side note, I am having an issue with non-trading days showing up on a multi-timeframe (daily & 15 min) chart I'm using for this indicator with historic data for the intraday range. Not sure if this is normal, but I plan to start a new thread on that.

                I attached the current version for all.

                Regards,

                Lee
                I am happy to read that you have it all sorted out. All the best.

                Comment


                  #23
                  Hi koganam,

                  I guess that didn't take long... I do have another question you may be able to help with. I noticed in using my SMI indicator, it plots the results with a flat line for the intraday range. I am using a multi timeframe chart with daily bars on top and intraday 30 minute data on bottom solely to implement the smart money indicator. I don't know if this is just because of the multi timeframe chart or something in my code. But I would like to plot only a single point for each day so that I could get a smoother plot of the data. I attached a pic of what I am currently seeing. I have tried changing the chart properties to see if I can eliminate this, but so far, no go. This may be just the result of having to use a multi timeframe chart setup, but I figured I would ask someone with experience.

                  Thanks again,

                  Regards,

                  Lee
                  Attached Files

                  Comment


                    #24
                    Originally posted by lee612801 View Post
                    Hi koganam,

                    I guess that didn't take long... I do have another question you may be able to help with. I noticed in using my SMI indicator, it plots the results with a flat line for the intraday range. I am using a multi timeframe chart with daily bars on top and intraday 30 minute data on bottom solely to implement the smart money indicator. I don't know if this is just because of the multi timeframe chart or something in my code. But I would like to plot only a single point for each day so that I could get a smoother plot of the data. I attached a pic of what I am currently seeing. I have tried changing the chart properties to see if I can eliminate this, but so far, no go. This may be just the result of having to use a multi timeframe chart setup, but I figured I would ask someone with experience.

                    Thanks again,

                    Regards,

                    Lee
                    Per your description, your calculations must be done intraday, so if you want to show your plot based on the daily bars, then you have to set your Plot by using the BarsInProgress filter to isolate your setting of the Plot to being done on the daily bars. The alternative will be to continue setting the Plot as you are, and either turn the Plot transparent, or reset it, on every bar but one.

                    Comment


                      #25
                      Thanks again for the input! So the basic code is good, I just need to work the DataSeries by using the Reset or BarsInProgress to get the desired one bar a day plot. I will give this a try and see what I can do.

                      Thanks!

                      Lee

                      Comment


                        #26
                        Hi koganam,

                        I have a few questions regarding your last post with respect to plotting the values once per day using BarsInProgress. So here is my general structure:

                        //initialize
                        }
                        Add(new Plot(Color.Blue, SMI));
                        }

                        //OnBarUpDate
                        {
                        if (CurrentBar < 1) return);
                        if (Time[1].Date != Time[0].Date);
                        {
                        dailyvalue & runningvalue calculations once per day
                        }
                        //Dataseries
                        SMI.Series;
                        }

                        This gives me the correct calculation for the indicator. But,reading through the help files, I am trying to determine where to utilize the BarsInProgress to get it to only plot one value for the day instead of all the bars. I'm assuming the plot calls values from the dataseries... I have tried using "if (BarsInProgress == 0)" to call out the dataseries, but that did not give me the once per day plot.

                        So I'm wondering, Is BarsInProgress the correct request to use, and should I add it right before the dataseries is called out, and is that the correct method to tie it to the plot? Or should I try to using an statement that says on the last bar of the day, plot that value?

                        Any insight is greatly appreciated,

                        Thanks,

                        Regards,

                        Lee

                        Comment


                          #27
                          Originally posted by lee612801 View Post
                          Hi koganam,

                          I have a few questions regarding your last post with respect to plotting the values once per day using BarsInProgress. So here is my general structure:

                          //initialize
                          }
                          Add(new Plot(Color.Blue, SMI));
                          }

                          //OnBarUpDate
                          {
                          if (CurrentBar < 1) return);
                          if (Time[1].Date != Time[0].Date);
                          {
                          dailyvalue & runningvalue calculations once per day
                          }
                          //Dataseries
                          SMI.Series;
                          }

                          This gives me the correct calculation for the indicator. But,reading through the help files, I am trying to determine where to utilize the BarsInProgress to get it to only plot one value for the day instead of all the bars. I'm assuming the plot calls values from the dataseries... I have tried using "if (BarsInProgress == 0)" to call out the dataseries, but that did not give me the once per day plot.

                          So I'm wondering, Is BarsInProgress the correct request to use, and should I add it right before the dataseries is called out, and is that the correct method to tie it to the plot? Or should I try to using an statement that says on the last bar of the day, plot that value?

                          Any insight is greatly appreciated,

                          Thanks,

                          Regards,

                          Lee
                          Is this a multi-timeframe indicator, or do you have just the primary timeframe?

                          Comment


                            #28
                            I have not declared any periods within the initialize section, so the indicator itself is only a primary timeframe (minutes for this example). I've been plotting it on a multi-timeframe chart with both days and mintues with the minute timeframe solely for this indicator.

                            Comment


                              #29
                              Originally posted by lee612801 View Post
                              I have not declared any periods within the initialize section, so the indicator itself is only a primary timeframe (minutes for this example). I've been plotting it on a multi-timeframe chart with both days and mintues with the minute timeframe solely for this indicator.
                              OK. So you have a single timeframe indicator, and you want to plot a Plot() at only one time during the day. BarsInProgress is unnecessary as a filter as there is only one BarSeries. What you need to do is determine at what time you want to Plot, and set the Plot at that time only. You may want to Reset the Plot at all other times. If that time is for example 1000 hrs, then
                              Code:
                              if (ToTime(Time[1]) <= 100000 && ToTime(Time[0]) >= 100000) Plot0.Set(requiredValueHere) //using a placeholder for the value. Substitute as necessary
                              else Plot0.Reset();

                              Comment


                                #30
                                Hi koganam,

                                Thanks again for all the help, I really appreciate it. I added the ToTime statement you suggested and was able to change to plot output, but have not been able to get a linear plot using the single runningValue calculation from each day. So I am looking to plot linearly from point to point using only a single point for each day. The indicator is calculating only a single value for each day on a minute chart, but I cant seem to get the plot to go from each single runningValue at the end of each day. One thing I noticed is that depending on what I change the time to within the ToTime command, sometimes it calculates the runningValue correctly, and sometimes it does not... I've been a little stumped on how the DataSeries plays into the script. I would have figured that it would not have to be in there for the script to calculate correctly, it just would not plot anything. But if I remove the DataSeries (SMI.set), it fails to calculate the runningValue correctly. Maybe this is how its suppose to work...

                                In the meantime, I am using a 30 minute timeframe chart (no multi-timeframe anymore) to troubleshoot. I couldn't get the plot function within the indicator to draw a straight line as I'd like, so I figured I would get the indicator to just calculate a single point even if it doesn't show, and then use a SMA to provide the plot using these points. Eventually, this is what I will want to do anyway. It almost worked, but the SMA is plotting more than just these single numbers (so I guess I am NOT plotting single values ). Certainly a little frustrating for me, but I will keep working it.

                                Anyway, I've attached the current incarnation of this indicator in case you might have some ideas.

                                Thanks,

                                Regards,

                                Lee
                                Attached Files

                                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