Announcement

Collapse
No announcement yet.

Code Error?

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

  • Code Error?

    I wrote the following code to try to make a study that tries to follow trend. It has some bugs and I don't know how to debug it. Can some one please look at my code and tell me whats wrong?
    Attached Files

  • #2
    example

    Here is a snapshot of what I'm trying to get this study to look like.
    The study on the bottom of the chart is the one I'm tryng to create.
    Attached Files
    Last edited by redislk; 03-13-2005, 08:13 AM.

    Comment


    • #3
      redislk,
      There is so much wrong with your code that I can't take the time to go through it all...sorry but it's true

      But, on the bright side, I was able to figure out what you wanted to do (I think). You want the histogram to turn blue when the Regression Line value is above the Moving Average, and red when it is below. I am posting your study as I think it needed to be corrected...at least it will put some bars on a chart...BUT this is NOT what you should end up using.

      Part of the problem is that you were using the builtin LinearRegressionStudy() and it draws a straight line for whatever length you tell it to. All the historical bars prior to the start of that Regression Line don't get colored correctly because the efs isn't holding on to the values for some reason. On a daily chart of ES #F, for example, you will see a bunch of red histo bars, and then 8 blue histo bars. Those 8 blue bars represent the length of your default Regression Line and the study has been able to work with those values. The red histo bars are all the lost Regression Line values.

      I will post another study that will do what you want in just a minute.

      Bob
      Attached Files

      Comment


      • #4
        redlisk,
        Here is a study that I think will do what you want. I adapted it from something else that I use. It will calculate a Least Squares Moving Average and any other Moving Average and paint the bars according to if the LSMA is above or below the MA.

        It uses an algorithm that I think Alexis posted for the LSMA calculation which is quite compact.

        Since you were using the Basis line of the LinearRegressionStudy(), the values will be exactly the same using the LSMA. No need for the Standard Deviation calculations.

        All variables can be changed in the Edit Studies window.

        Good luck, Bob
        Attached Files

        Comment


        • #5
          thanks

          rmclean,

          Is there a way i can send you a tradestation file that I want to convert esignal?

          Comment


          • #6
            redlisk,
            Sure, I'll PM you with my email address...I think that will work.

            As an aside, I don't expect to be at my computer much for the next week or so...that is still a maybe-maybe not thing.

            Further, I am not a professional programmer. I am just some guy who taught himself to program. Most of what I write works, but there is no guarantee.
            Also, I don't work for eSignal or anything like that, so what I choose to program has to be of interest to me.

            That being said, I will be happy to take a look at the Tradestation file. If it is interesting and I am capable, I will code it for you, but you may have to be patient and wait until I get back.

            Bob

            Comment

            Working...
            X