Multiple Time Frames with TALIB and Tulip
#11
(01-10-2019, 01:53 PM)mark.sch Wrote: Ok, some changes have been necessary for your strat to work, I tweaked the necessary things. Have a look both the config and strat changes:

Config: https://pastebin.com/j7dB6K6n
Strat: https://pastebin.com/491Bvjs7

I added some code for proper candle warmup handling, otherwise you will get undefined indicator values during the first minutes/hours. Just match the history size in your config with the necessary history size of your indicators if you make any further changes.

You can use this strat now as a bare skelleton to start implementing any multi timeframe candle logic now. With the open source T5mainasync and T5multimarket strategies you have further examples how to use other tulip and talib async indicators. I removed the MFI indicator temporarily because it had a wrong syntax in your strat. You need to look into the tulip documentation which params it expects and what it returns. Good look with your coding.

=> apply your binance settings to the config again, I tested with kraken ETH EUR data because I had it locally available.


Hi Mark, how are you ?

since last time i am trying to include MFI in this strat using both tulip and Talip async and it didnot help , even in Talip it can show all required input but result always come as undefined,    even though all  required history info  is there already included in the array .

i tried even with 1 min candle for 14 and 7 OnTimePeriod but couldnot get any result , i already waited many hours for results to show without any success 

also i couldn't get RSI to work with talip Async func , but it is ok as long it is working with tulip i am fine with that . so can you include  MFI and see if it works ?

i uploaded all files again . and you will see in the logs that all required para and all required candle info already included in the array for the mfi i


SobhV7
https://pastebin.com/8nk7hbXX

Config
https://pastebin.com/rAEH5vNV

Logs
https://pastebin.com/F3HquVbP




Thanks again
  Reply
#12
You can use MFI indicator from Talib, I added a sample usage to T5mainasync strategy, search for mfi60M:

https://pastebin.com/HJpshVz0
  Reply
#13
(01-12-2019, 10:15 PM)mark.sch Wrote: You can use MFI indicator from Talib, I added a sample usage to T5mainasync strategy, search for mfi60M:

https://pastebin.com/HJpshVz0

YES .It works!. Thanks a lot  Mark. i really appropriate it . keep up the good work man.
  Reply
#14
I am glad it works for you. Did some tests in the past with volume based indicators also, but they did not outperform a traditional indicator like RSI during my tests.

E.g. taking T5mainasync strat, on whole year 2018 it makes a profit of +164%, ETHEUR: https://cloud.think5.de/gekko/backtests/...81231.html

With a direct RSI to MFI indicator replacement, the profits get lower using this strategy. Maybe you can get better results with MFI and new, adjusted tresholds.
  Reply
#15
Hey Mark, 
thanks for sharing your experience. 

I just managed to install green gekko and postgresql database. During importing with suggestes command
Code:
node gekko --config sample-eth.js --import --set debug=true

I receive an error after some time: 
Code:
.
.
.
Processing 998 new trades. From 2018-06-29 08:57:39 UTC to 2018-06-29 11:44:59 UTC. (3 hours). Last price: 351.68
2019-01-31T08:30:41.521Z 'Unexpected end of JSON input'
2019-01-31 09:30:41 (ERROR): There was an error importing from Kraken SyntaxError: Unexpected end of JSON input
2019-01-31 09:30:41 (DEBUG): Trade fetch came back empty.
2019-01-31 09:30:41 (INFO): Done importing!


Note: I stick to your sample.eth.js and did not make any changes. 
Could you please help me with this?
  Reply
#16
(01-12-2019, 10:41 PM)mark.sch Wrote: I am glad it works for you. Did some tests in the past with volume based indicators also, but they did not outperform a traditional indicator like RSI during my tests.

E.g. taking T5mainasync strat, on whole year 2018 it makes a profit of +164%, ETHEUR: https://cloud.think5.de/gekko/backtests/...81231.html

With a direct RSI to MFI indicator replacement, the profits get lower using this strategy. Maybe you can get better results with MFI and new, adjusted tresholds.

RSI is kinda manupliated . thats why i dont depend on it as major indicator but sometimes i use it as a confirmation with others . i found that mfi with other indicators give stable steady results and yes it could be lower profits  than RSI in some cases but it give low losing trades
  Reply
#17
(01-10-2019, 11:35 AM)mark.sch Wrote: Yes it is possible, but you will need to add some gekko core modifications. The problem is, that talib und tulip work async with their indicator calculations. So these calculations will either need proper callbacks or async/await patterns to work with the core without running into candle timing and race conditions.

I made some pull requests to target exactly this issue. You may have a look and pick what you need. You may also play with the Green Gekko fork, which has implemented this feature ready to go. In my own strategies I run 5 different candle sizes within one strategy on many different talib indicators for example.

Hi Mark,

I was just experimenting with Green Gekko recently and I noticed that when using the async features you have implemented, the batch size has to always be 1 to get accurate backtesting results.. I added a bunch of debug messages to see what's going on, and I guess as expected, when batch size is more than 1, you get a big batch of candles first, then a big batch of indicators results, etc.. which results in inaccurate tests..

However, with a batch size of 1, backtesting becomes really really slow, and attempting to use tools like brute force or gekko batcher will take forever to run..

Is there any way to avoid this slow down or a work around you can suggest?
  Reply
#18
I really liked the modifications of Green Gekko.

I'm doing some initial testing, but I found it a little slow.

This is normal?

Any tips?

Thank you
  Reply
#19
(05-09-2019, 01:38 AM)Thank stelnemri Wrote: Got a solution?

(01-10-2019, 11:35 AM)mark.sch Wrote: Yes it is possible, but you will need to add some gekko core modifications. The problem is, that talib und tulip work async with their indicator calculations. So these calculations will either need proper callbacks or async/await patterns to work with the core without running into candle timing and race conditions.

I made some pull requests to target exactly this issue. You may have a look and pick what you need. You may also play with the Green Gekko fork, which has implemented this feature ready to go. In my own strategies I run 5 different candle sizes within one strategy on many different talib indicators for example.

Hi Mark,

I was just experimenting with Green Gekko recently and I noticed that when using the async features you have implemented, the batch size has to always be 1 to get accurate backtesting results.. I added a bunch of debug messages to see what's going on, and I guess as expected, when batch size is more than 1, you get a big batch of candles first, then a big batch of indicators results, etc.. which results in inaccurate tests..

However, with a batch size of 1, backtesting becomes really really slow, and attempting to use tools like brute force or gekko batcher will take forever to run..

Is there any way to avoid this slow down or a work around you can suggest?
  Reply
#20
There might be a more easy way of handling multiple time scales.
In one of my current strategies, i wrote below code :

SumCandles : function(candles,start,length) // from a candles array start at start, and take a length of candles to sum
{
var sum=
{start : 0,
stop : 0,
high : 0,
low : 0,
volume : 0,
trades : 0
};
sum.high= candles[start].high;
sum.low = candles[start].low;
sum.start=candles[start].open;
sum.stop = candles[start+length].close;

for(i=start;i<length;i++)
{
if(candles[i].high>sum.high)sum.high=candles[i].high;
if(candles[i].low<sum.low)sum.low=candles[i].low;
sum.volume = sum.volume+candles[i].volume;
sum.trades = sum.trades+candles[i].trades;
}
return sum;
},


for above to work you need an array of candles, so in the strategy update function one could write :

candles.push(candle);

if (candles.length > 10) { //keeps 10 candles in memorry
candles.shift();
}


I'm doing candle stick patterns at the moment, but if i remind correctly though that array should be be able to be pushed trough indicators as well.
with a little bit more coding one could create several arrays (say 5, 15, and 60 minute arrays).
  Reply


Forum Jump:


Users browsing this thread: