Support Board
Date/Time: Wed, 07 May 2025 00:42:13 +0000
Using ranges in a simple Spreadsheet Formula study
View Count: 189
[2024-11-25 04:23:23] |
pjk0225 - Posts: 41 |
In a Spreadsheet Formula study (not a formula in the spreadsheet), I want it to output 1 or -1 depending on whether or not a crossover occurred in the last 12 bars. I want the study to produce the output for at least 12 bars, starting from the first trigger. I'm checking id65.sg1 over 12 consecutive bars against the value 0.10. The code I'm using is: if(CROSSOVER(id65.sg1[-1:-12], 0.10) =1,1, if(CROSSOVER(id65.sg1[-1:-12], 0.10) =-1,-1,0)) However, this only outputs 1 or -1 for 1 bar only (the trigger bar). How can I make it output for at least 12 bars? |
[2024-11-25 17:44:23] |
John - SC Support - Posts: 39675 |
If what you are wanting is to get a signal for all twelve bars when there is a crossover that occurs within those twelve bars, then there is not a way to do this. The CROSSOVER function is taking two ranges of data and comparing them to each other to find if there is a crossover of the data between these. If there is a crossing, then there the function gives a value of 1 or -1 (depending on the direction of the crossing). But it is just a notice at the particular location of the crossing. -- Also, there is no reason for your alert condition the way you have it. You are testing if the result is 1, then outputting 1, or if -1 then output -1 and otherwise 0. You are double testing for reason. Just use the following formula: =CROSSOVER(id65.sg1[-1:-12], 0.10) For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-11-26 02:14:58] |
pjk0225 - Posts: 41 |
I understand. I suppose what I really wanted to do was: =CROSSOVER(id65.sg1, 0.10)[-1:-12] You wouldn't be able to implement something like this into the program, would you? Being able to check if a signal was true within a range of bars would be very useful. |
[2024-11-26 14:47:45] |
John - SC Support - Posts: 39675 |
You will get a signal if there is a crossover anywhere within the 12 bars. It's just that you will only get 1 signal at the bar where the crossover occurs and not for all the bars.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-11-27 03:18:12] |
pjk0225 - Posts: 41 |
So how would I go about making a signal that shows for all the bars? Isn't there a simple way to do it?
|
[2024-11-27 15:53:05] |
John - SC Support - Posts: 39675 |
No, there is not a simple way to do it. You would have to use the Spreadsheet Study to do this.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: