Using more than one strategy
Hello, I am trying to combine different strategies as some can be combined and work precise on crypto market.How for ex. will set my config to combine RSI with StochRSI and also a third one?
Great question! For this you have to create your own (one) strategy that combines a number of indicators. In this streategy you will have to create logic that decides what happens when RSI says "BUY" but StochRSI says "SELL".
See this document for details: https://github.com/askmike/gekko/blob/stable/docs/strategies/creating_a_strategy.md
If you have any questions feel free to ask :) But I am closing this as it's not a pressing issue.
if you can give me an short example of how it looks both custom.js and config it would be very helpfull.Thank you.
StochRSI is a bit of a weird indicator in gekko: StochRSI is basically RSI with some extras. So I created an example that uses 2 RSI indicators and turns one of those into StochRSI.
The config is just something you can use to make it easier to have variables in your own strategy. (and you can tweak numbers in your strat using the interface). For simplicity I'll ignore it for now. Here is a method that uses both StochRSI & RSI:
https://gist.github.com/askmike/715df74a8af6710b6fa64be35897ed79
- The interval for both RSI indicators is configured at line 4 & 7.
- The thresholds (when is RSI high and when LOW) are on lines 5,6 and 8,9.
- The small function that turns an RSI into a stochRSI is on line 33 to 45.
- This strat will look at these indicators, and if BOTH pass the buy/sell thresholds advice to buy/sell.
I am trying to combine my knowledge of economics with this great trader you have created, thats why i have asked those two indicators.Basically, StochRSI is an oscillator that measures the level of RSI relative to its high-low range over a set time period. StochRSI applies the Stochastics formula to RSI values, instead of price values. This makes it an indicator of an indicator. The result is an oscillator that fluctuates between 0 and 1. Calculation : StochRSI = (RSI - Lowest Low RSI) / (Highest High RSI - Lowest Low RSI)
P.S. We always have to keep in mind that we have to do with a market that has high volatility and maybe some of ranges that work with stocks doesnt apply to this market.
I have to salute with a big THANK YOU on your example.Very helpfull.Wish you a happy day.
Great! That probably means you can tell a lot more about these indicators than I can :)
The idea behind Gekko is really that I don't tell you what indicators work in what market (or which you should combine in what way - I am not an economist/trader). Gekko is merely a toolbox that you can use to create / try out your own strategy on market data. Gekko will take care of all the plumbing (connecting to a dozen exchanges, importing historical data, transforming/normalizing all data needed for your strategy, having a web interface where you can see the results of these strategies).
So I very much like to know if the gist makes sense to you. And if you have any other questions feel free to ask! Gekko only really makes sense if people who actually have a deep understanding of these indicators play with it :)
Where exactly would I place this file if I wanted to use this strategy?
hey @mjsmorgan,
I am assuming you are using the web UI:
- download this file and put it into the
strategiesfolder (gekko/strategies/). - refresh the web UI.
- it should now appear as
stratin the dropdown (the filename minus the.js).
Let me know if you run into any problems!
Actually, I am using the command line version
In that case just configure the tradingAdvisor method property to equal "strat"!
On Wed, Apr 19, 2017 at 6:51 PM, mjsmorgan [email protected] wrote:
Actually, I am using the command line version
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/askmike/gekko/issues/674#issuecomment-295365228, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7MD9yV9yayLNZfTOdR8yDTAayg3yVPks5rxkmogaJpZM4M02qT .
-- PGP key at keybase.io/mikevanrossum https://keybase.io/mikevanrossum/key.asc
Askmike, can you also provide an example with DEMA, CCI and RSI combined? I triend to replicate on the basis of upper linked RSI combination, but I get totally lost. I am no programmer.
Askmike, what I am doing wrong? I trx to combine four indicators. I announce all four, but for the sake of testing I use only one (MACD), to see if the code works. However the code wont work, i get the error: Error: non-error thrown: Child process has died. at Object.onerror (/home/T/gekko/node_modules/koa/lib/context.js:105:40) at process._tickCallback (internal/process/next_tick.js:109:7)
The code:
https://github.com/Sc0ut01/gekko_custom/blob/master/custom.js
@Sc0ut01 can you please put your strat in a gist or pastebin? I cannot read it like this!
Ok, I included the link to gist in the previous comment. Sorry, never used node.js and github before.
Askmike, I cant find anny error in my method, I cant find what is wrong. That error I now get when I load in UI the conf.
TypeError: Cannot read property 'direction' of undefined
at Base.method.check (/home/T/gekko/strategies/custom.js:80:18)
at Base.bound (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Base.propogateTick (/home/T/gekko/plugins/tradingAdvisor/baseTradingMethod.js:248:10)
at Base.bound [as propogateTick] (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Base.tick (/home/T/gekko/plugins/tradingAdvisor/baseTradingMethod.js:184:10)
at Base.bound [as tick] (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Actor.processCustomCandle (/home/T/gekko/plugins/tradingAdvisor/tradingAdvisor.js:79:15)
at CandleBatcher.bound (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at emitOne (events.js:96:13)
at CandleBatcher.emit (events.js:188:7)
--> in Database#all('\n SELECT * from candles_USDT_BTC\n WHERE start <= 1497941879 AND start >= 1497938880\n ORDER BY start ASC\n ', [Function])
at Reader.get (/home/T/gekko/plugins/sqlite/reader.js:98:11)
at Reader.bound [as get] (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Market.get (/home/T/gekko/core/markets/backtest.js:61:15)
at Market.bound [as get] (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Market.processCandles (/home/T/gekko/core/markets/backtest.js:105:10)
at bound (/home/T/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Statement.
Error: non-error thrown: Child process has died. at Object.onerror (/home/T/gekko/node_modules/koa/lib/context.js:105:40) at process._tickCallback (internal/process/next_tick.js:109:7)
@askmike I followed per your instruction below. I back tested using the UI but it appears no trade were executed. I played with the intervals, low and high but still no luck. I can open a separate issue from this thread just let me know. Thanks.
-
- download this file and put it into the
strategiesfolder (gekko/strategies/).
- download this file and put it into the
-
- refresh the web UI.
-
- it should now appear as
stratin the dropdown (the filename minus the.js).
- it should now appear as
Here's the output from the shell:
2017-12-08 19:02:21 (INFO): Setting up Gekko in backtest mode
2017-12-08 19:02:21 (INFO):
2017-12-08 19:02:21 (INFO): Setting up:
2017-12-08 19:02:21 (INFO): Trading Advisor
2017-12-08 19:02:21 (INFO): Calculate trading advice
2017-12-08 19:02:21 (INFO): Using the strategy: strat
2017-12-08 19:02:21 (INFO):
2017-12-08 19:02:21 (INFO): Setting up:
2017-12-08 19:02:21 (INFO): Paper Trader
2017-12-08 19:02:21 (INFO): Paper trader that simulates fake trades.
2017-12-08 19:02:21 (INFO):
2017-12-08 19:02:21 (INFO): Setting up:
2017-12-08 19:02:21 (INFO): Performance Analyzer
2017-12-08 19:02:21 (INFO): Analyzes performances of trades
2017-12-08 19:02:21 (INFO):
2017-12-08 19:02:21 (INFO): WARNING: BACKTESTING FEATURE NEEDS PROPER TESTING
2017-12-08 19:02:21 (INFO): WARNING: ACT ON THESE NUMBERS AT YOUR OWN RISK!
@glenn11897 add logging in your strategy, and figure out the numbers being calculated and whether they hit your checks. If your strategy never signals any advice Gekko will never trade.
thanks @askmike , the error was in between the keyboard and chair :-)
@glenn11897 I'm also very new with gekko and building strategies. I found your post and wanted to know if you like to help me building my custom strategy. I'm trying to set up a strategy with EMA and MACD indicators which is testing higher highs and lower lows for sells and buys in a 30 minutes candle stick chart.
@askmike Do you have a reference guide with all variables we can use? do you have a syntax sheet? I haven't found anything.
Thanks for any reply.