Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help Needed with MacD MTF Script

Hi All, I'm admittedly new to Python/Quantopian and this is my first algo but I've been having the hardest time getting a simple MacD algo working for a Long/Short setup on 5-minute candles... just for a single stock.

I've tried working with several other shared scripts but seems everything is producing errors regarding depreciated api's and modules and then promptly crashing. If anybody would be willing to take a look, or point me in the right direction (to a currently functional MacD script) I'd be very grateful! The idea is to minimize commissions and reduce slippage by entering the longs and shorts as a single trade (ie. when the balance is 100 shares, sell 200 to go 100 short, then on a long signal buy 200 to go long). Thanks!

Details:
MacD Fast: 2, MacD Slow: 400, Length: 3
Stock: UNG
Long (100 shares) on CrossOver, Short (100 Shares) on CrossUnder
5 minute candles,
rebalancing on every tick,
limit order w

2 responses

Welcome to Quantopian!

Do take a look at the tutorials ( https://www.quantopian.com/tutorials/getting-started and https://www.quantopian.com/tutorials/pipeline). The latter, on using the pipeline, is the current general approach to fetching historical day level data. There are also a number of built in 'factors' that take the place of using the talib library (including MACD). Check that out.

One question... you state in your details "5 minute candles, rebalancing on every tick", Do you want to rebalance every minute? Your algorithm only trades once a day and gets daily history. If you are looking for a daily algorithm I can perhaps provide a framework to get you started.

Thanks for the help and suggestions Dan, Indeed I've been going the the tutorials but much of it is confusing with the new minute standard... Yes, i'd like to recalculate / rebalance every minute if possible... I'll dig a little deeper in the tutorials today.