CCI pattern screen

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #13306 quote
    Philippo
    Participant
    Average

    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 🙂

    #13307 quote
    Nicolas
    Keymaster
    Master

    1472825722_flagPlease 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.
    #13323 quote
    Philippo
    Participant
    Average
    timeframe (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 time
    nl = 0
    //nextlevel = 0 open to anything
    
    
    // set conditions
    clong=0 //long
    cshort=0  //short
    
    
    FOR i = 0 TO 50 DO
    
    c1=cci[i](bars) crosses over -100
    c2=cci[i](bars) crosses under 100
    
    c3=cci[i](bars) crosses over 100
    c4=cci[i](bars) crosses under -100
    
    if c1 and nl=0 then
    nl = 1
    continue
    endif
    
    if nl=1 and c3 then
    nl=2
    continue
    endif
    
    if nl=2 and c3 then
    clong=1
    break
    endif
    
    
    
    NEXT
    
    SCREENER[(clong) OR (cshort)] ((close/DClose(1)-1)*100 AS "%Chg yest.")
    
    #13324 quote
    Philippo
    Participant
    Average
    Hi 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?
    #13375 quote
    Nicolas
    Keymaster
    Master
    Please 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 🙂
    // 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 = 100
    
    mycci = cci[20]
    
    for a = lookback downto 0 do 
    if mycci[a] crosses over -100 then 
      nextlookback = a
      break
     endif
    next
    
    for b = nextlookback downto 0 do
     if mycci[b] crosses over 100 then 
      nextlookback = b
      break
     endif
    next
    
    for c = nextlookback downto 0 do
     if mycci[c] crosses under 100 then
      nextlookback = c
      break
      endif
    next 
    
    for d = nextlookback downto 0 do
     if mycci[d] crosses over 100 then
      result = 1
      when = d
      break
     else
      result = 0
      endif
    next
    
    SCREENER [result] (when as "When?")
    cci-cross-screener.png cci-cross-screener.png
    #13394 quote
    Philippo
    Participant
    Average
    Hi Nicolas, thanks at least the for loops are not nested… time for a beer.   country updated (I thought I did that yesterday..)   Thanks again
    #16258 quote
    Philippo
    Participant
    Average
    Hi, 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:
    // Determine if the condition C1 is true for at least once over the last n candlesticks:
    
    IF HIGHEST[n](c1) = 1 THEN
       ...
    
    // Determine if the condition c1 was always true over the last n candlesticks:
    
    IF LOWEST[n](c1) = 1 THEN
       ...
    
    // Determine the number of times the condition c1 was verified over the n last candlesticks:
    num = SUMMATION[n](c1)
    
    // Determine the number of bars since c1 was true:
    
    IF c1 THEN
       lastoccurence = barindex
    
    ENDIF
    timesince = barindex - lastoccurence
    
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

CCI pattern screen


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Philippo @philipd Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Philippo
9 years, 3 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/19/2016
Status: Active
Attachments: No files
Logo Logo
Loading...