Show Bar Help

Hi,

I have scripted an indicator which is working perfectly. I would like to add an arrow to the price using the ShowBar tool when the indicator crosses above 60 only after it crosses below 40. I cant seem to get this to work. Please help . Thank you.

//Define Signals
S1 = SCRIPT(SCRIPTNAME=StochClose 125, 5, 5) CrossesAbove 60 ; 
S2 = SCRIPT(SCRIPTNAME=StochClose 125, 5) CrossesBelow 40 ; 
//Show S1 After S2 
SWITCH(S1,S2)

ForOptumaTimeSinceSignal.owb (201 KB)

Hi,

I don’t have the presaved scripts you are referring to in your code, so can’t show you a fully edited version, but the last line should be using SignalAfter() rather than Switch()

https://help.optuma.com/kb/faq.php?id=932

Once setup to use SignalAfter() it should work as expected.

Thank you Mathew. This works perfectly. In a watchlist I want to count the number of bars since this signal occurred. Here is the script I have, but the watchlist does not show any values at all? Please see the screenshot.

//Define Signals
S1 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesAbove 60 ; 
S2 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesBelow 40 ; 
//Find The Last Signal 
V1 = SignalAfter(S2,S1) ; 
//Calculate # Of Bars Since Signal 
TIMESINCESIGNAL(V1)

Arthur-Hill.owb (417 KB)

Hi,

Try…

//Define Signals
S1 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesAbove 60 ;
S2 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesBelow 40 ;
//Find The Last Signal 
V1 = SignalAfter(S2,S1) ;
V2 = V1 == 1;
//Calculate # Of Bars Since Signal 
TIMESINCESIGNAL(V2)

 

Hi. As much as I want that to work, the watchlist column is still blank. Any ideas?

Hi,

I can’t test any further without knowing what the underlying code is for the script named: StochClose 125 5

I’d also want to know if the script produces any results with a Show View?

Hi. Here is the script for StochClose 125 5. The Show View looks like it understands but is off by 1 bar. Please see attached screenshot.

//Define Variables for Stochastic Calculation 
V1 = CLOSE() ; 
V2 = HIGHESTHIGH(BARS=125, INCBAR=True, Close()) ; 
V3 = LOWESTLOW(BARS=125, INCBAR=True, Close()) ; 
//Stochastic Cal caution 
V4 = ((V1 - V3) / (V2 - V3)) * 100 ; 
//Smooth the Stochastic Calculation 
V5 = MA(CALC=Close, V4) ;
//Format the Stochastic And Add 2 Lines 
Plot1 = V5 ; 
Plot1.Color = Black ; 
Plot1.LineWidth = 2 ; 
Plot2 = 60 ; 
Plot2.Color = Green ; 
Plot3 = 40 ; 
Plot3.Color = Red;

Arthur-Hill-1-1.owb (420 KB)

Hi,

The values are there, but are out of view (the header is long, you can see the scroll bar along the bottom)…

Ex9

Move it across to the right and the hidden values will come into view.

The values are 1 different as the script treats the trigger day as zero, while your Time Measure includes the trigger day.

Thank you so much. Have a great week.