Plot Daily Highs on Intraday Chart

Discussion in 'Strategy Building' started by Ginu09, Apr 5, 2021.

  1. Ginu09



    I would like to plot the daily chart highs as follows:

    rec dailyHigh = if high > dailyHigh[1] then high else dailyHigh[1];
    plot recordHigh = dailyHigh;

    But I would like to plot the last value on the intraday chart and ignore today's value. How would I go about doing this? Any guidance would be appreciated.

    Thank you!
    murray t turtle likes this.
  2. %%
    I do that with yesterdays 4 hour candle chart;
    /lags a bit but works fine...................................................................
  3. I don't understand what you mean by "But I would like to plot the last value on the intraday chart and ignore today's value."!
    You seem to be somewhat familiar with TOS ThinkScript, so likely if your request is rational, it is doable. -- I just don't follow what you want.
    Here is your snip on a 15-min bars for AAPL for reference.
  4. upload_2021-4-5_15-50-39.png
  5. Ginu09


    Hi, thanks. What I'm looking for is the last daily high above today's open to get a sense of overhead resistance (hence ignoring today from the calculation so as to display that resistance bar on the intraday chart even if today's price crosses it).

    I think I've figured it out but the challenge I'm having is thinkscript executes code going back each day and therefore, if I use "open", it's for the current day the script is evaluating. I would like to keep today's "open" fixed (static) in a variable so it stays constant in my algorithm. How do I store the current trading day's open in a variable without it changing?
  6. Something like this?
    def todaysopen=open(period=aggregationPeriod.DAY);

    I am assuming you are using intra-day, which would normally infer the open to be the bar open, not the day open. So above aggregation resolves to the day instead of the bar.
    Last edited: Apr 6, 2021
  7. Ginu09


    Let's say I have a 5 day chart. If I have a simple algorithm which compares the day high against the open, I would have something like this:

    rec dailyHigh = if (GetValue(high(period = AggregationPeriod.DAY), 1, 0) < dailyHigh[1] and dailyHigh[1] != 0 and GetValue(high(period = AggregationPeriod.DAY), 1, 0) > open) or (GetValue(high(period = AggregationPeriod.DAY), 1, 0) > open and dailyHigh[1] == 0) then GetValue(high(period = AggregationPeriod.DAY), 1, 0) else dailyHigh[1];

    On a 5 day chart, it will compare yesterday's high to today's open; it will also compare the high two days ago to yesterday's open, etc. In other words, the script gets executed on each day in the 5 day period for the plot. I would like to compare the highs going back 5 days to today's fixed "open" value. Like creating a global variable or a way to fiddle with days to only set an open variable if the date in question is today's date. Not sure how to do this though.

    I hope I explained the problem clearly.
  8. I am still not following what you are trying to do.
    Perhaps this will fill part of the solution. This allows you to specify your lookback period in Days for an intra-day chart. It just plots the daily high of the input#days back. -- Not what you want, but may be starting idea to use.

    input lookbackDays=1;
    plot PriorDayHigh=high([lookbackDays];
  9. Ginu09


    Simply put, I would like to plot that day high ONLY IF it is higher than today's open and I would like to do it on a multi-day timeframe. Plotting all the day highs going back X days would crowd my chart.
  10. Then, is this what you want?

    input lookbackDays=1;
    def ReferenceValue=high([lookbackDays];
    plot PriorDayHigh=if (open(<ReferenceValue) then ReferenceValue else double.nan;
    #10     Apr 6, 2021