HaasScript

From Haasonline Software Wiki
Jump to: navigation, search

The HaasScripting abilities are present inside the Simple license and up.


About

Sometimes there are people who like to go behind the trade-bot its capabilities. People who like to do more advanced things and to support this we added HaasScript. HaasScript is especially designed to make scripting for crypto trading easier.

HaasScript is the successor of C# Scripting and the Local API.

Supported methods

The overview shown below here is just a global representation of the scripting capabilities. The real documentation is added inside our scripting editor.

Basics

-- Comment line
 
Log(12)               -- Logging a test or variable in the compile view

Getting price data

-- Getting price data
p = GetPrices()       -- Get Closing prices
p = GetClosePrices()  -- Get Closing prices
p = GetHighPrices()   -- Get High prices
p = GetLowPrices()    -- Get Low prices
p = GetOpenPrices()   -- Get Open prices
p = GetAskPrices()    -- Get Ask prices
p = GetBidPrices()    -- Get Bid prices
p = GetVolumes()      -- Get volume data
 
p = GetOC()           -- Get OC prices
p = GetHL()           -- Get HL prices
p = GetHLC()          -- Get HLC prices
p = GetOHLC()         -- Get OHLC prices

Input fields

-- Input field (returns the set value)
v = Input("myid","Length",30,1,999)     
-- the text on the settings is "Length" 
-- the default value is 30
-- the minimum value is 1
-- the maximum value is 999

Charting

Plot("My line", pr, 0, Green)    
-- the line is named "My line"
-- the value is pr
-- the chart is 0, meaning on the candles, use 1, 2 or 3 for extra charts
-- the color is green, we support the following colors;
--   Purple
--   Green
--   Gold
--   Red
--   Blue
--   Orange
--   SkyBlue
--   Yellow
--   White
--   Gray
--   DarkGray

Memory

Save("mykey",123)                    -- Store a value of the last calculation
Load("mykey")                        -- Load a value of the last calculation

Logic

-- Sample script (for indicators and safeties) how to generate a trading signal
if (pr > 2537) then
    LongBuy()
else
    ShortSell()
end

Basic calculations

h = GetHigh(p,10)                   -- Get the highest price, based on the last 10 prices
l = GetLow(p,20)                    -- Get the lowest price, based on the last 20 prices
pp = Offset(p,5)                    -- Returns the same array with the the first 5 prices removed
 
pp = Compress(p)                    -- Compresses 2 prices into 1
res = TimeVal(2)                    -- Checks if the current time is dividable by 2minutes (return true or false)

Array calculations

res = AddArr(a,b)                   -- Merge 2 arrays (a+b)
res = SubArr(a,b)                   -- Substract 2 arrays (a-b)
res = MulArr(a,b)                   -- Multiple 2 arrays (a*b)
res = DivArr(a,b)                   -- Divide 2 arrays (a/b)

Technical analysis

x = AROON(h,l,30)                   -- Returns a array with the Aroon values of length 30
x = AROONOSC(h,l,30)                -- Returns a array with the Aroon-Occilator values of length 30
x = ATR(h,l,c,30)                   -- Returns a array with the ATR values of length 30
x = BOP(o,h,l,c)                    -- Returns a array with the BOP values of length 30
x = CCI(h, l, c, 30)
x = CMO(p,30)                       -- Returns a array with the CMO values of length 30
x = EMA(p,30)                       -- Returns a array with the EMA values of length 30
x = DEMA(p,30)                      -- Returns a array with the DEMA values of length 30
x = DX(h, l, c, 30)
x = KAMA(p,30)                      -- Returns a array with the KAMA values of length 30
x = MAMA(p,30,10)                   -- Returns a array with the MAMA values of short length 30 and long length 10
x = MACD(c, 10, 20, 30)
x = MOMENTUM(c, 30)
x = NATR(h, l, c, 30)
x = OBV(c, v)
x = POC(p,30)                       -- Returns a array with the POC values of length 30
x = ROC(p,30)                       -- Returns a array with the ROC values of length 30
x = ROCALT(p,30)                    -- Returns a array with the ROCALT values of length 30
x = ROCP(p,30)                      -- Returns a array with the ROC percentage values of length 30
x = ROCR(p,30)                      -- Returns a array with the ROCR values of length 30
x = RSI(p,30)                       -- Returns a array with the RSI values of length 30
x = SMA(p,30)                       -- Returns a array with the SMA values of length 30
x = STDDEV(c, 30)
x = STOCH(h, l, c, 3, 5, 10)
x = TEMA(p,30)                      -- Returns a array with the TEMA values of length 30
x = TRANGE(h, l, c)
x = TRIMA(p,30)                     -- Returns a array with the TRIMA values of length 30
x = TYPPRICE(h, l, c)
x = ULTOSC(h, l, c, 10, 15, 20)
x = VARIANCE(c, 20)

Bot data: Indicators, Safeties and Insurances

LastBuyPrice()                      -- Returns the bot its last buying price (spot trading only)
LastSellPrice()                     -- Returns the bot its last selling price (spot trading only)
 
LastGoLongPrice()                   -- Returns the bot its last go long price (margin and leverage trading only)
LastExitLongPrice()                 -- Returns the bot its last exit long price (margin and leverage trading only)
LastGoShortPrice()                  -- Returns the bot its last go short price (margin and leverage trading only)
LastExitShortPrice()                -- Returns the bot its last exit short price (margin and leverage trading only)
 
BotPosition()                       -- Returns the bot its current position ()
TradeAmount()                       -- Returns the bot its trade-amount
Interval()                          -- Returns the update interval (indicator only)

Signal production: Indicators and Safeties

ShortSell()                         -- Signal a sell/short
BuyLong()                           -- Signal a buy/long 
ExitPosition()                      -- Signal a exit position (works only for margin and leverage)

Signal production: Insurances

AllowTrade()                        -- Approves of a trade
DisallowTrade()                     -- Block a trade

Example Trading Indicators

Example Script-bots