Highest Close between 2 MA Crossovers Signals

Optuma Forums Optuma Scripting Highest Close between 2 MA Crossovers Signals

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by Avatar Dan 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #53109
    Avatar
    Dan
    • Topics: 3
    • Replies: 5
    • Posts: 8

    Hi. I am trying to create a script being used in a ShowMe that will find the highest Close between the Close crossing above 20 MA and Close crossing below

    20 MA for a maximum specified number of bars between. In this example, I am using a maximum of 10 bars between Cross Above and Cross Below

    and my code is showing a Signal at the Cross Below. I am using HighestSince but it might not be the right method.

    How can I show the Signal at the Highest Close between the 2 Crossovers?

     

    NUMBARS=10;

    MA20 = MA(Day(PERIODAMOUNT=1), DATA1, BARS=20, STYLE=Simple, CALC=Close);

    Close1 = CLOSE(Day(PERIODAMOUNT=1));

    COND1 = Close1 CrossesAbove MA20;

    T1 = TIMESINCESIGNAL(COND1);

    COND2 = Close1 CrossesBelow MA20;

    COND3 = COND2 and (T1 <= NUMBARS) ;

    IF(COND3, HIGHESTSINCE(COND1));

     

     

    #53111
    Matthew
    Matthew
    • Topics: 4
    • Replies: 186
    • Posts: 190

    Hi Dan,

    Can you please provide a screen shot example of the setup you’re wanting to highlight with the script.

    #53119
    Avatar
    Dan
    • Topics: 3
    • Replies: 5
    • Posts: 8

    Hi Mathew.

    The screenshot attached shows the Blue arrow as the Close Crossing Above 20 Day MA and the Red Arrow shows the Close Crossing Below the 20 Day MA.

    There are 4 bars between the Crossovers including the Cross Below in this screenshot.

    COND1 is capturing the CrossAbove.

    COND2 is capturing the CrossBelow.

    T1 is capturing the number of bars since COND1.

    I want to make sure that T1 only captures the bars between COND1 and COND2 every time those conditions occur.

    I also want the number of  bars <= NUMBARS and 4 <= 10 in this example.

    So I am trying to capture these bars using COND3 but I think it is wrong.

    After getting each set of bars between COND1 and COND2, I want the find the highest Close price

    between them. So if COND3 is True, I am using HIGHESTSINCE(COND1) but believe this is wrong as well.

    I want to show a signal at the Highest Close which is represented by the Green Arrow button in the screenshot.

    How can this be done?

     

    NUMBARS=10;

    MA20 = MA(Day(PERIODAMOUNT=1), DATA1, BARS=20, STYLE=Simple, CALC=Close);

    Close1 = CLOSE(Day(PERIODAMOUNT=1));

    COND1 = Close1 CrossesAbove MA20;

    T1 = TIMESINCESIGNAL(COND1);

    COND2 = Close1 CrossesBelow MA20;

    COND3 = COND2 and (T1 <= NUMBARS) ;

    IF(COND3, HIGHESTSINCE(COND1));

     

    Attachments:
    #53135
    Darren
    Darren
    • Topics: 41
    • Replies: 280
    • Posts: 321

    Thanks Dan. I can’t think of a quick way to do this, so if you want us to spend more time on it we can arrange a scripting consultation. Contact support if you would like to go ahead.

    #53141
    Avatar
    Dan
    • Topics: 3
    • Replies: 5
    • Posts: 8

    Thanks

    Thanks for the reply. I’ll look into that if needed in the near future.

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

You must be logged in to reply to this topic.

Pin It on Pinterest

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