Plot Daily Highs on Intraday Chart

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

  1. easymon1


    What will the report look like?
    #11     Apr 6, 2021
  2. Ginu09


    It doesn't seem to work for a lookbackDays > 1
    #12     Apr 6, 2021
  3. Ginu09


    I'd just like a single line to show on the intraday chart for the first day high from the daily that is greater than the current day's open as an indication of overhead resistance.
    #13     Apr 6, 2021
  4. Ginu09


    It's funny, I can get the code to work when I hardcode the "currentOpen = 1.24". However, if I use this code:

    def currentOpen = if getTime() crosses above RegularTradingStart(getYYYYMMDD()) then open else currentOpen[1];

    it fails. On a multi-day chart, when TOS goes through the various days on the chart, will currentOpen here store today's open only or the open of the day on the chart being evaluated?
    #14     Apr 6, 2021
  5. I think I am still guessing at what you want.

    This just displays a horizontal line on the last day of an intra-day chart at the level of the highest bar of the day index provided as the input.

    You may find someone that understands what you mean in the ThinkScript Chat on TOS. Some very clever folks on there!

    input lookbackDays=1;
    def ReferenceValue=high([lookbackDays];
    def barRef=if ReferenceValue!=ReferenceValue[1] then barnumber() else barRef[1];
    def plottime=barRef==highestall(barRef) ;
    plot PriorDayHigh=if (plottime) then ReferenceValue else double.nan;

    If you provide some actual rendition of what you are doing, may go a long way for discovering what you are trying to do. A chart, with symbol, and your timeframe (none of which has been disclosed).

    Do you have code which does something, and you wish it did something else and provide some hints?
    Last edited: Apr 6, 2021
    #15     Apr 6, 2021
  6. Ginu09


    Here's an example in the attachment. I'd like to automatically display the first high from the daily chart that is greater than the open price from today (this move was from yesterday). Here the high would be 2.19 from 10 days ago with the open at 2.12. The duration of days (lookback period) can be anything and I wouldn't want to have to specify it ideally (who knows how many days ago the previous high would be).

    For the code that you posted, I set a lookback period of 50 and it didn't post anything.

    Hope that helps to clarify! and thanks for your help.
    #16     Apr 6, 2021
  7. easymon1