Hi all,

I am new to programming and algorithms in general, so please bear with me.

I just started programming my first algo over at Quantopian (QP) this week when I realized that QC is probably the better place to be at the moment. I am now trying to simply migrate my basic algo over to QC, and was hoping to find some kind help on this forum. My algo is very simple for obvious reasons, but I still find it hard to figure out how to go about converting it to QC standards.

The algo is based on two technical indicators (ADX and Parabolic SAR). The algo goes long when the ADX crosses a certain threshold and when the parabolic SAR is indicating an up-trend, It exists the long posistion and switches to a second asset at exit when similar conditions are met by the SAR and ADX indicator. The aglo from QP currently imports Talib for the mentioned indicators, and this is the difficult part to migrate. The code from QP currently looks like this:

# ---------------------------------------------------------------------

import talib
# ---------------------------------------------------------------------
stock, bond, period = symbol('dia'), symbol('tlt'), 14; bars = period*2
# ---------------------------------------------------------------------
def initialize(context):
schedule_function(trade , date_rules.every_day(), time_rules.market_open(minutes = 65))
set_benchmark(symbol('dia'))

if get_open_orders(): return

H = data.history(stock,'high', bars, '1d').dropna()
L = data.history(stock,'low', bars, '1d').dropna()
C = data.history(stock,'close', bars, '1d').dropna()

mdi = talib.MINUS_DI(H, L, C, period)[-1]
pdi = talib.PLUS_DI(H, L, C, period)[-1]
sar = talib.SAR(H, L, 0.02, 0.2)[-1]

if (adx < 15 and mdi > pdi and sar > C[-1]):
wt_stk, wt_bnd = 0, 1
elif (adx > 15 and mdi < pdi):
wt_stk, wt_bnd = 3, 0
else: return

order_target_percent(stock, wt_stk)
order_target_percent(bond, wt_bnd)