Bitcoin Forum
May 26, 2024, 06:47:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: creating macd script  (Read 90 times)
torgny (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
May 25, 2020, 07:59:50 PM
 #1

this was a script I found for trading with macd. It is taken from trality.com:

@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<buy_amount:
       print("-------")
       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?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!