Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.07 KB

Script-Library.md

File metadata and controls

42 lines (34 loc) · 1.07 KB

Here are a few simple scripted order types which are both useful and a base for you own creations.

Sell alt when BTC price drops

As described here.

Parameters

Name Description Default Reqd
amount Amount Yes
limitPrice Limit price Yes
stopPrice Stop price (BTC Binance) Yes

Code

var subscription

function start() {
  subscription = events.setTick(
    function(event) {
      if (Number(event.ticker().getLast()) < Number(parameters.stopPrice)) {
        notifications.alert("BTC hit stop price (" + event.ticker().getLast() + "). Triggering stop on " + selectedCoin.base)
        trading.limitOrder({
          market: parameters.selectedCoin,
          direction: SELL,
          price: parameters.limitPrice,
          amount: parameters.amount
        })
        control.done()
      }
    },
    { exchange: "binance", base: "BTC", counter: "USDT" }
  )
  return RUNNING
}

function stop() {
  events.clear(subscription)
}