cross previous days close on 1 hr Timeframe

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #122292 quote
    ck1066
    Participant
    Average

    Hi,

    I hope someone can help. I’m trying to create a indicator which alerts on the 1hr time-frame for bullish or bearish cross over of the previous days close. My current code is:

    res=0
    pdc=dclose(1)
    
    Timeframe(1 hour)
    a1=close crosses over pdc
    
    long=a1[1] 
    
    Timeframe(1 hour)
    b1=close crosses under pdc
    
    short=b1[1]
    
    if long then
    res=1
    elsif short then
    res=-1
    endif
    
    screener [(long) or (short)] (res as "direction")

    I need help to ensure it only triggers based on the previous hour. The results seem random when executed against the currencies market. Can someone help?

    #122347 quote
    Nicolas
    Keymaster
    Master

    You are over complicated the code, I think it could work like this, and running it on the 1-hour timeframe. Dclose is a constant that you can use in any timeframe.

    res=0
    
    a1=close crosses over dclose(1)
    b1=close crosses under dclose(1)
    
    long=a1[1] 
    short=b1[1]
    
    if long then
     res=1
    elsif short then
     res=-1
    endif
    
    screener [res<>0] (res as "direction")
    #122365 quote
    ck1066
    Participant
    Average

    Thanks as always.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

cross previous days close on 1 hr Timeframe


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
ck1066 @ck1066 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by ck1066
6 years ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/16/2020
Status: Active
Attachments: No files
Logo Logo
Loading...