New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.
Options

Price > Average of High, Low, Close of Prior 3 days and 3 weeks

Is the below possible in Stockcharts. Appreciate it.
Logic: Price > Average of High, Low, Close of Prior 3 days and
Price > Average of High, Low, Close of Prior 3 Weeks.

Is this possible? Appreciate your feedback.

Comments

  • Options
    markdmarkd mod
    edited January 14
    This code runs, but kicks a warning about mismatched time periods. I think that's because of the two different time frames in two different lines. In any case, in runs and produces result, but I didn't verify them, and I don't think you can, since there are no standard indicators to match the calculations in the code.

    [group is sp500]

    and [close > [[sma(3,high)+sma(3,close) +sma(3,low)]/3 ]]

    and [weekly close > [[weekly sma(3,weekly high)+weekly sma(3, weekly close) +weekly sma(3,weekly low)]/3 ]]


    The rub is that the values of high low and close are as of the last update. So if you run it during market hours, it uses the intraday values for the daily variables (and weekly). So by the end of the day your results may not match an intraday result. If you run it after hours but before close of business Friday, the daily values are accurate, but the weekly values are as of the current day of the week. So, you would be averaging the final values of the first two weeks, but an intraweek value for the third week. After the last after hours update on Friday and over the weekend the results are "final".
  • Options
    Thank you and really appreciate it. Sorry for the late response. I logged in only today after a long time. I will give this a shot. I have the logic for this in TC2000, but wanted something for stockcharts. I will try the above.
Sign In or Register to comment.