CCI pattern screen
Forums › ProRealTime English forum › ProScreener support › CCI pattern screen
- This topic has 6 replies, 2 voices, and was last updated 8 years ago by Philippo.
-
-
09/19/2016 at 4:36 PM #13306
Hi am trying to create a screener where it identifies the following on CCI:
in past x bars
CCI crosses above -100 then crosses above 100 crosses below 100 then crosses above 100 (without going lower than -100)
or
CCI crosses below 100 then crosses below -100 then crosses above -100 then crosses below -100 (without going higher than 100)
normally I would use a loopback over x bars and write each cross over event to an array. Then I would test the array for that specific pattern.
But it seems like ProScreener does not let me create my own arrays.
Thanks 🙂
09/19/2016 at 4:40 PM #13307Please update your country flag in your profile. Thank you 🙂
Hi Philip, you don’t need arrays to store your tests. We can make a loop or a summation of boolean over the last X periods to test if all your conditions were met.
09/19/2016 at 7:36 PM #13323123456789101112131415161718192021222324252627282930313233343536373839404142434445timeframe (4 hours)bars=20//codes for nl nextlevel//1 = over 100 1st time//2 = over 100 2nd time//-1 = under -100 1st time//-2 = under -100 2nd timenl = 0//nextlevel = 0 open to anything// set conditionsclong=0 //longcshort=0 //shortFOR i = 0 TO 50 DOc1=cci[i](bars) crosses over -100c2=cci[i](bars) crosses under 100c3=cci[i](bars) crosses over 100c4=cci[i](bars) crosses under -100if c1 and nl=0 thennl = 1continueendifif nl=1 and c3 thennl=2continueendifif nl=2 and c3 thenclong=1breakendifNEXTSCREENER[(clong) OR (cshort)] ((close/DClose(1)-1)*100 AS "%Chg yest.")09/19/2016 at 7:42 PM #13324Hi Nicolas, I have tried to imagine what you mean and created a fragment of code which I believe would catch the condition where CCI crosses first over -100 then subsequently through 100 and then again through 100.
If I can get it working for one direction then the others will follow easily.
But Pro Screener tells me that The program “MyScreener(7)” does not contain code 😀 so obviously it doesn’t understand something. But I don’t see what is wrong. It all looks syntactically ok, no yellow triangles. Any way to debug or to see what is causing the problem for ProScreener? I would not like to bother you every time I try to code:)
So is this the kind of structure you meant?
09/20/2016 at 2:17 PM #13375Please update your profile with your country.
This is a test quickly coded during lunch, screener take long time because of many loops. Didn’t test it much, so please stay calm and have a beer, I’ll get back here asap if you need more assistance 🙂
12345678910111213141516171819202122232425262728293031323334353637383940// in past x bars CCI crosses above -100 then crosses above 100 crosses below 100 then crosses above 100 (without going lower than -100)// or// CCI crosses below 100 then crosses below -100 then crosses above -100 then crosses below -100 (without going higher than 100)lookback = 100mycci = cci[20]for a = lookback downto 0 doif mycci[a] crosses over -100 thennextlookback = abreakendifnextfor b = nextlookback downto 0 doif mycci[b] crosses over 100 thennextlookback = bbreakendifnextfor c = nextlookback downto 0 doif mycci[c] crosses under 100 thennextlookback = cbreakendifnextfor d = nextlookback downto 0 doif mycci[d] crosses over 100 thenresult = 1when = dbreakelseresult = 0endifnextSCREENER [result] (when as "When?")09/20/2016 at 4:55 PM #1339411/09/2016 at 9:33 PM #16258Hi, from the Probacktest and ProOrder manual, I dug up the following functions….could be exactly what I was looking for….in case anyone else want to do something similar, here’s the text:
Here are several separate examples where using a FOR loop is avoided:
1// Determine if the condition C1 is true for at least once over the last n candlesticks:12IF HIGHEST[n](c1) = 1 THEN...1// Determine if the condition c1 was always true over the last n candlesticks:12IF LOWEST[n](c1) = 1 THEN...// Determine the number of times the condition c1 was verified over the n last candlesticks:
1num = SUMMATION[n](c1)1// Determine the number of bars since c1 was true:12IF c1 THENlastoccurence = barindex12ENDIFtimesince = barindex - lastoccurence -
AuthorPosts
Find exclusive trading pro-tools on