Trying to code a screener but has error

Forums ProRealTime English forum ProScreener support Trying to code a screener but has error

Viewing 10 posts - 1 through 10 (of 10 total)
  • #252514

    Hello!
    I’m just learning about everything trading and trying out strategies. I tried to build a screener with help of Chat Gpt but it seems not to know the right syntax.
    There is a problem with this line:
    macdLine=emaF-emaS

    Is it something easy to fix?
    Would appreciate your help.

    Thank you!

    ** Entire proposed code **

    #252524

    In ProBuilder, some words such as truerange or macdline are reserved identifiers or simply don’t exist with that exact name.
    That’s why you get syntax errors.
    There’s also a small conceptual mistake: the closing price (close) can never be strictly greater than the highest closing price of the last N periods — it can only be greater or equal.

    1 user thanked author for this post.
    #252528

    Iván, thank you for your time, it works now!
    Unfortunately it shows no results. I wonder if I have to wait or there is some requirement too strict and I should change. I’ll have to play around with the criteria.
    If you have any thought on it, would be welcome.

    Again, thanks for the help!

    #252543
    JS

    Hi,

    It looks like you’re trying to use MultiTimeFrames (MTF), since I see terms like “minConsWeeks”…

    Should certain parts of your screener operate on a different timeframe…?

    1 user thanked author for this post.
    #252547

    Thanks JS.
    I don’t think I’m looking for MTF. The minConsWeeks would refer to looking for a 6 week consolidation period.
    This is be the criteria I’d like to screen for, but if it doesn’t work something can be taken out.

    • Price above 20-week moving average

    • 6+ weeks of consolidation before breakout

    • MACD bullish alignment: MACD line above the signal line

    • Breakout candle:

      Must close above resistance
      Body > 50% of the candle
      10-week high or higher
      Candle gain between +5% and +20% vs previous week’s close.
      Volume spike ≥ +30% vs previous week
      NATR < 8

    #252550
    JS

    Hi,

    I’ve checked all the conditions, and in principle, the issue isn’t with the conditions themselves…

    The problem is the number of conditions that have to be true at the same time — that combination almost never occurs…

    In the 100 weeks I checked, it didn’t happen even once…

    #252560

    I’ll check what I can loosen.
    Thanks a lot for the help!

    1 user thanked author for this post.
    avatar JS
    #252561

    I tried to simplify and use the code Iván suggested, but get another Syntax error (mymacdsignal not used).
    Would you kindly have another look at it?

    #252562
    JS

    Hi,

    I made a few adjustments to the code:

    highCons = Highest[minConsWeeks](close[1]) // using Close[1] instead of Close, so the current bar is excluded
    lowCons = Lowest[minConsWeeks](close[1]) // using Close[1] instead of Close, for consistency with highCons
    macdBull = mymacdLine > mymacdSignal // using mymacdLine instead of macdLine (reserved keyword) and mymacdSignal instead of macdSignal (reserved keyword)

    These changes ensure that the calculations don’t include the current bar in the range evaluation and that the MACD comparison uses your custom variables consistently…

    1 user thanked author for this post.
    #252564

    Works! Appreciate the help a lot!

    1 user thanked author for this post.
    avatar JS
Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login