Hello, I need help. I am overwhelmed to progame the Dema and WMA. Both are indicators.
Does someone is able to convert this indicators into python code?
Thanks to everybody, who wants to help
Hello, I need help. I am overwhelmed to progame the Dema and WMA. Both are indicators.
Does someone is able to convert this indicators into python code?
Thanks to everybody, who wants to help
import talib
STOCK = symbol('SPY'); MA = 100; BARS = MA*6;
def initialize(context):
schedule_function(record_MA, date_rules.every_day(), time_rules.market_close(), True)
def record_MA(context, data):
prices = data.history(STOCK, 'price', BARS, '1d')
dema = talib.DEMA(prices, MA )
wma = talib.WMA(prices, MA )
record(price = prices[-1], dema = dema[-1], wma = wma[-1])
open_orders = get_open_orders()
if dema > wma:
if STOCK not in open_orders:
order_target_percent(STOCK, 1.0)
elif dema < wma:
if STOCK not in open_orders:
order_target_percent(STOCK, -1.0)
record(levarage = context.account.leverage)