November 14, 2021 at 5:15 pm #66597
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.1234567//Define SignalsS1 = SCRIPT(SCRIPTNAME=StochClose 125, 5, 5) CrossesAbove 60 ;S2 = SCRIPT(SCRIPTNAME=StochClose 125, 5) CrossesBelow 40 ;//Show S1 After S2SWITCH(S1,S2)November 15, 2021 at 11:09 am #66610
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()
Once setup to use SignalAfter() it should work as expected.November 15, 2021 at 12:15 pm #66615
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.123456789//Define SignalsS1 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesAbove 60 ;S2 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesBelow 40 ;//Find The Last SignalV1 = SignalAfter(S2,S1) ;//Calculate # Of Bars Since SignalTIMESINCESIGNAL(V1)November 15, 2021 at 12:35 pm #66620
Try…12345678910//Define SignalsS1 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesAbove 60 ;S2 = SCRIPT(SCRIPTNAME=StochClose 125 5) CrossesBelow 40 ;//Find The Last SignalV1 = SignalAfter(S2,S1) ;V2 = V1 == 1;//Calculate # Of Bars Since SignalTIMESINCESIGNAL(V2)November 15, 2021 at 12:58 pm #66621
Hi. As much as I want that to work, the watchlist column is still blank. Any ideas?November 15, 2021 at 1:24 pm #66622
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?November 15, 2021 at 1:40 pm #66623
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.123456789101112131415161718//Define Variables for Stochastic CalculationV1 = CLOSE() ;V2 = HIGHESTHIGH(BARS=125, INCBAR=True, Close()) ;V3 = LOWESTLOW(BARS=125, INCBAR=True, Close()) ;//Stochastic Cal cautionV4 = ((V1 - V3) / (V2 - V3)) * 100 ;//Smooth the Stochastic CalculationV5 = MA(CALC=Close, V4) ;//Format the Stochastic And Add 2 LinesPlot1 = V5 ;Plot1.Color = Black ;Plot1.LineWidth = 2 ;Plot2 = 60 ;Plot2.Color = Green ;Plot3 = 40 ;Plot3.Color = Red;
November 15, 2021 at 2:24 pm #66642
- This reply was modified 1 year ago by Louis Spector.
The values are there, but are out of view (the header is long, you can see the scroll bar along the bottom)…
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.November 15, 2021 at 3:04 pm #66645
Thank you so much. Have a great week.
- You must be logged in to reply to this topic.