marvinrouge
|
|
July 15, 2013, 02:40:52 PM |
|
thanks ! Nothing happens when I try to register, is it normal ?
|
|
|
|
evilscoop
|
|
July 15, 2013, 02:52:15 PM |
|
at last.....ive been trying to automate this stuff for months..... thank you thank you thank you
also cant seem to register....using safari or firefox, both fail
|
|
|
|
marvinrouge
|
|
July 16, 2013, 10:11:38 AM |
|
Is it planned to add other time intervals ? like 2h or 6h (or let a possibility to custom it) Sometimes there is a huge difference between 2 consecutive intervals and I would be curious to test the middle
|
|
|
|
pulsecat (OP)
|
|
July 16, 2013, 05:06:16 PM Last edit: July 16, 2013, 07:03:58 PM by pulsecat |
|
thanks ! Nothing happens when I try to register, is it normal ? also cant seem to register....using safari or firefox, both fail
The user related functionality is disabled until basic scripting functionality is ready. Sorry Is it planned to add other time intervals ? like 2h or 6h (or let a possibility to custom it) Sometimes there is a huge difference between 2 consecutive intervals and I would be curious to test the middle Since several people requested for 2H bars i'm going to add such option soon. As regards custom intervals, it shouldn't be hard to implement this, since the backend stores all history data from Mtgox.
|
|
|
|
pulsecat (OP)
|
|
July 16, 2013, 05:13:09 PM Last edit: July 17, 2013, 06:51:02 PM by pulsecat |
|
Feature update- added support for Underscore library ( http://underscorejs.org/) - cool utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) - added bindings to Ta-lib library ( http://ta-lib.org) - technical analysis library that includes 125+ indicators. Full functions list http://cryptotrader.org/talibFor details check the documentation at the site.
|
|
|
|
marvinrouge
|
|
July 16, 2013, 10:51:20 PM Last edit: July 16, 2013, 11:18:01 PM by marvinrouge |
|
Since several people requested for 2H bars i'm going to add such option soon. As regards custom intervals, it shouldn't be hard to implement this, since the backend stores all history data from Mtgox.
great Feature update - added support for Underscore library ( http://underscorejs.org/) - cool utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) - added bindings to Ta-lib library ( http://ta-lib.org) - technical analysis library that includes 125+ indicators. For details check the documentation at the site. I tried to use the new indicators but even reading the doc in the site it's not much clearer for me If I just want to access the main value of an indicator with default parameters, what is the code ? Take ADX as an exemple, is it something like this ? instrument = data.btc_usd indic = instrument.talib.ADX debug indic.signal (I know it doesn't work, but I would like to know how far I am)
|
|
|
|
Kuroth
|
|
July 17, 2013, 12:27:53 AM |
|
VERY Cool.. Will try this out..
|
|
|
|
pulsecat (OP)
|
|
July 17, 2013, 11:12:06 AM Last edit: July 17, 2013, 07:21:09 PM by pulsecat |
|
I tried to use the new indicators but even reading the doc in the site it's not much clearer for me If I just want to access the main value of an indicator with default parameters, what is the code ? Take ADX as an exemple, is it something like this ? instrument = data.btc_usd indic = instrument.talib.ADX debug indic.signal (I know it doesn't work, but I would like to know how far I am) To call TA-Lib function directly, you need to determine the data passed to and from the function. The function index at http://cryptotrader.org/talib provides information on the arguments and return values. For example, your algorithm needs to use ADX indicator: ADX - Average Directional Movement Indextalib.ADX(params) Input parameters:- high - array of floats - low - array of floats - close - array of floats - startIdx - start index for input data - endIdx - end index for input data - optInTimePeriod Returns: - array of floats Below is the code that calls ADX function instrument = data.btc_usd result = talib.ADX high: instrument.high low: instrument.low close: instrument.close startIdx: 0 endIdx: instrument.close.length-1 optInTimePeriod: 9 # result is an array of floats debug _.last(result) # Prints current value
|
|
|
|
ErebusBat
|
|
July 17, 2013, 02:39:57 PM |
|
Figured I would post here in case people didn't know, but you can use the Try CoffeeScript tab at http://coffeescript.org/ to get your syntax correct. Also there is a slight typo in pulsecat's last post, result should not be indented (you can see this at the above website), removing that space and then it compiles.
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 18, 2013, 09:55:04 AM |
|
Below is the code that calls ADX function instrument = data.btc_usd result = talib.ADX high: instrument.high low: instrument.low close: instrument.close startIdx: 0 endIdx: instrument.close.length-1 optInTimePeriod: 9 # result is an array of floats debug _.last(result) # Prints current value
When I try this I get "TypeError: Cannot read property 'high' of undefined" Could you link some working examples of various indicators maybe? Thanks ..
|
|
|
|
pulsecat (OP)
|
|
July 18, 2013, 10:52:43 AM |
|
It's true, Coffeescript is very sensitive to formatting. Here is example of usage ADX indicator ### Example usage of ADX indicator The script engine is based on CoffeeScript (http://coffeescript.org) Any trading algorithm needs to implement two methods: init(context) and handle(context,data) ###
# Initialization method called before a simulation starts. # Context object holds script data and will be passed to 'handle' method. init: (context)->
# This method is called for each tick handle: (context, data)-> # data object provides access to the current candle (ex. data['btc_usd'].close) instrument = data.btc_usd result = talib.ADX high: instrument.high low: instrument.low close: instrument.close startIdx: 0 endIdx: instrument.close.length-1 optInTimePeriod: 14 adx = _.last(result) if adx debug "ADX:#{adx} price:#{instrument.price}"
http://cryptotrader.org/backtests/HQBAMoPXQMtqtskkQ
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 19, 2013, 07:32:36 AM Last edit: July 19, 2013, 08:34:53 AM by Diabolicus |
|
Thanks pulsecat, that helps a lot! One more question: I am trying to add some kind of stop loss to my strategy, therefore I need to somehow store the buy/sell prices for later reference. Something like: if buy_occurs buy_price = instrument.price And then for the following ticks: if instrument.price < (buy_price*0.99) sell instrument
How exactly would I do that? Thanks!
|
|
|
|
pulsecat (OP)
|
|
July 19, 2013, 08:17:45 AM Last edit: July 19, 2013, 08:29:04 AM by pulsecat |
|
Thanks pulsecat, that helps a lot! One more question: I am trying to add some kind of trailing stop loss to my strategy, therefore I need to somehow store the buy/sell prices for later reference. Something like: if buy_occurs buy_price = instrument.price And then for the following ticks: if instrument.price < (buy_price*0.99) sell instrument
How exactly would I do that? Thanks! Use the context object to store variables: if buy_occurs context.buy_price = instrument.price
And then if context.buy_price and instrument.price < (context.buy_price*0.99) sell instrument
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 19, 2013, 08:38:08 AM |
|
Yes, but how can I make sure the context.buy_price only gets overwritten when a buy actually occurs?
|
|
|
|
pulsecat (OP)
|
|
July 19, 2013, 09:08:20 AM |
|
That is a good question. When a buy or a sell occurs, the methods return an order id. Otherwise, undefined value is returned. if buy instrument context.buy_price = instrument.price
Thanks, i'm going to update documentation with it.
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 19, 2013, 09:13:01 AM Last edit: July 19, 2013, 09:27:40 AM by Diabolicus |
|
Hmm, that still doesn't seem to work?
|
|
|
|
pulsecat (OP)
|
|
July 19, 2013, 09:38:34 AM |
|
Please show your code and maybe we can figure out what is wrong.
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 19, 2013, 09:48:42 AM |
|
init: (context)-> context.pair = 'btc_usd' context.buy_treshold = 0.24 context.sell_treshold = 0.19 context.buy_price = 0 context.previous_price = 0
handle: (context, data)-> instrument = data[context.pair] short = instrument.ema(10) # calculate EMA value using ta-lib function long = instrument.ema(21) diff = 100 * (short - long) / ((short + long) / 2) if diff > context.buy_treshold buy instrument # Spend all amount of cash for BTC if buy instrument #<< how do I check if a buy was executed this tick? context.buy_price = instrument.price debug "Buy Threshold" debug "#{context.previous_price} #{context.buy_price} #{instrument.price}" else if diff < -context.sell_treshold sell instrument # Sell BTC position if sell instrument debug "Sell Threshold" debug "#{context.previous_price} #{context.buy_price} #{instrument.price}" else if instrument.price < (0.985*context.previous_price) sell instrument if sell instrument debug "Trailing Stop Loss" debug "#{context.previous_price} #{context.buy_price} #{instrument.price}" else if instrument.price < (0.985*context.buy_price) sell instrument if sell instrument debug "Stop Loss" debug "#{context.previous_price} #{context.buy_price} #{instrument.price}" context.previous_price = instrument.price
Debug should tell for each buy or sell how it was actually triggered. but the 'If buy instrument' condition doesn't work. http://cryptotrader.org/backtests/f2wBfWCXHvha7N9ip
|
|
|
|
pulsecat (OP)
|
|
July 19, 2013, 10:03:05 AM |
|
... buy instrument # Spend all amount of cash for BTC if buy instrument #<< how do I check if a buy was executed this tick? ...
As the 'buy' is a function, the above code make it called twice, so that the second call returns undefined value. The right way to do it: ... orderId = buy instrument # Spend all amount of cash for BTC if orderId # a buy was executed context.buy_price = instrument.price ...
|
|
|
|
Diabolicus
Member
Offline
Activity: 90
Merit: 10
|
|
July 19, 2013, 10:15:22 AM Last edit: July 19, 2013, 10:30:42 AM by Diabolicus |
|
wohoo, works :-)
Here's another one: Say I would want to output some kind of additional statistics at the end of the simulation (total number of trades, trades triggererd by each mechanism, number of successful / unsuccessful trades etc..) I could add context.counter values for each of these. Is there a method that gets called at the end of the simulation to finally output these values?
|
|
|
|
|