For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

In need of support with more indicators in a screener

  • I've been following the blog post on creating a screener on the basis of an Analyzer. Background being that i want to screen the S&P500 stocks at end of day to scan if a stock shows the signals I'm looking for.
    I've been trying several ways, but my python skills are not sufficient I think. Below my try, I would appreciate if somebody could point me in the right direction.

    class Screener(bt.Analyzer):
        params = dict(period=10)
        def start(self):
            self.smas = [bt.indicators.SMA(self.datas, period=self.p.period) for data in self.datas]
            self.trend_ema = [bt.indicators.ExponentialMovingAverage(data, period=200) for data in self.datas]
            self.adx = [bt.indicators.ADX(data, period=10) for data in self.datas]
            self.result = zip(self.datas, self.smas, self.crsi, self.trend_ema, self.adx)
        def stop(self):
            self.rets['over'] = list()
            self.rets['under'] = list()
            for value, sma, trend_ema, adx in self.result
                node = data._name, data.close[0], crsi[0]
                if value > trend_ema and adx >= 30

  • administrators

    • Which direction?

    • What's the problem your code poses?

    Obviously you haven't run that code, because to start with you have something called self.crsi which doesn't exist but it is being put in a zip statement.

    @rudi said in In need of support with more indicators in a screener:

    I've been trying several ways, but my python skills are not sufficient I think.

    Let me be blunt. Programming skills are a pre-condition.

  • @backtrader I'll forgive you your bluntness. I know C#, javascript and ruby, just python is new for me. And I did indeed simplify the code before posting but apparently left some in.

  • administrators

    If this is a contest, here is my list:

    • FPGA programming
    • Assembly for Motorola and Intel (MASM, TASM and gas)
    • m4
    • sh
    • C ... down to the OS kernel
    • C++
    • Pascal
    • Modula-2
    • C64 Basic (No ... the Motorola Assembly was not on a C64)
    • Python
    • Javascript
    • PHP
    • Visual Basic
    • SQL
    • dBase III (you could create fairly complicated things with nice character based GUIs)

    Under SunOS, Solaris, Linux, DOS, Win32, IRIX, C64, Web Browsers and Proprietary Environments (not all at the same time, not with all the languages obviously)

    And that's why I learnt that to ask for help/support I had to post something which was what I was actually trying to run (or running but with problems), what the input/output was, what I thought the problem was, what error was being shown., ...

    Now that the "mine is larger" contest is over ...

    • An isolated and redacted piece of code which isn't executable and has obviously never been put to the test to see if it executes ... doesn't help.

Log in to reply