@schedule(interval="1h", symbol="BTCUSDT")
def handler(state, data):
macd_ind = data.macd(12,26,9).last
if macd_ind is None:
return
signal = macd_ind['macd_signal']
macd = macd_ind['macd']
has_position = has_open_position(data.symbol, truncated=True)
balance_base = float(query_balance_free(data.base))
balance_quoted = float(query_balance_free(data.quoted))
buy_amount = balance_quoted * 0.80 / data.close_last
if macd > signal and balance_base
print("Checking for buying possibility of {}".format(data.symbol))
print("buy amount:",buy_amount)
print("buy price:", data.close_last)
create_order(symbol=data.symbol,amount = buy_amount)
elif macd < signal and has_position:
print("-------")
print("Checking for selling possibility of {}".format(data.symbol))
print("sell amount:",balance_base)
print("sell price:",data.close_last)
close_position(data.symbol)
The problem is that it is based on a macd signal. And I want to define my own macd constraints instead of using a signal. Does anyone know where I could find a python script where you can alter the macd constraints yourself?