Identifing the 49th Bar after a Primary Signal

Optuma Forums Optuma Scripting Identifing the 49th Bar after a Primary Signal

This topic contains 3 replies, has 2 voices, and was last updated by Matthew Matthew 2 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #47491

    Trevor R
    • Topics: 11
    • Replies: 17
    • Posts: 28

    Hi Guys,

    I have a script that identifies a particular Primary Signal Pattern, such as a Pivot High, after which I wish to use a SHOWBAR highlight for a subsequent Bar after a fixed period, say the 49th Bar after the Primary Signal. I have the following scripts:

    ***************************

    // Primary Signal Pivot High

    PivotHi = PIVOT(MIN=22, TYPE=High);

    PivotHi

    **********************
    // Pivot High Plus TD49

    PivotHi = Script(SCRIPTNAME=Pivot High Primary Signal);

    PivotHi49 = If(TIMESINCESIGNAL(PivotHi, UNIT=Bars)==49,1,0);

    PivotHi49

    ***********************

    Applied to SHOWBARs this produces the following result:

    20180701 Identifying the 49th Bar after a Primary Signal

    The Primary Signal is highlighted by the SHOWBARs as dashed vertical lines and the 49th Bar thereafter by the SHOWBAR Arrows, EXCEPT, and this is my issue, when a Primary Signal occurs before the 49th Bar that 49th Bar is ignored. Note the example of the 49th Bar from the second Primary Signal on the above chart, it is not highlighted. Obviously the TIMESINCESIGNAL Bar count is restarted at the new (3rd) Primary Signal, thereby negating the 49th Bar count from the previous Primary Signal.

    How can I make my script highlight the 49th Bar after every Primary Signal?

    Any suggestions will be appreciated.

    Cheers

    Trevor

    #47495
    Matthew
    Matthew
    • Topics: 3
    • Replies: 69
    • Posts: 72

    Hi Trevor,

    If you are wanting to show an arrow 49 bars after every primary criteria is passed, i would use an Offset() function rather than time since signal.

    #47503

    Trevor R
    • Topics: 11
    • Replies: 17
    • Posts: 28

    Hi Matthew,

    Thanks for the solution.

    However, I cannot see the need for V2. Surely it is simply repeating the result of the V1 imported signal. Certainly when I remove it and replace the replace V2 with V1 in V3 to results appear to be identical.

    I note that this script will only display the periods as per the underlying Chart. Thus if the Bars “Filter” is set to “Calendar Days” the Bar count, ie 49, is actually Calendar Days. Is there a way within the Script to set the “period” count to Bars, Calendar Days or maybe even Weeks or Months?

    Cheers

    Trevor

    • This reply was modified 2 months, 3 weeks ago by  Trevor R.
    #47511
    Matthew
    Matthew
    • Topics: 3
    • Replies: 69
    • Posts: 72

    Hi Trevor,

    V2 is needed to convert the script into a True / False result as V1 can produce values between 0 and 3400 (add V1 to a Show view by itself to confirm).  To work properly on a Show Bar the script must return a Boolean result of 1 or 0.

    Offset will use the charts default settings, there’s no way to override the interval at this time so you will need to take the underlying charts setup into consideration when setting the offset value.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close