# Highest Close between 2 MA Crossovers Signals

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));

Hi Dan,

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

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));

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.

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