04-30-2018, 03:33 AM
(This post was last modified: 04-30-2018, 03:42 AM by susitronix.)
In this tutorial you can learn how to setup indicators.
>>>i have randoomly choosen Tulip indicators but it could be eny avilable indicators for gekko.
>>>>>the test results are all in the same uptrend/period and should only show the trigger points.
>>>>>>>WARNING THESE STRATEGIES ARE NOT PROFITABLE ENOUGH OVER TIME.
(((((it needs more than one indicator-if-statement to become a profitable trader)))))
Some indicators have two or three options (user input averaging length) and more than one output.
In this case, Arrays are used to set the inputs or read the output values.
First a simple RSI (realtime strength index) with one input/output
////////Test results: BASSic RSI
use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)
>select all and delete the content
>>copy/paste my example code strat above
>>>Save as: rename to:
>>>>tulip_RSI.js //and save
WARNIG: MY CODE INDENTS HAVE BEEN BIT MESSED UP HERE
JUST: in your editor right-click choose [format document] before save...
use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)
>select all and delete the content
>>copy/paste my example code user settings above
>>>Save as: rename to:
>>>>tulip_RSI.toml
>>>>>Save as type //<<<SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!)
The MA (Moving avereage) with two MAs looking for the crossing point.
//////////test results: BASSic MA
>>>>save as tulip_MA.js
>>>>save as tulip_MA.toml
It is the same setup as for the RSI, only dual.
the MACD has more options and outputs, but which ones??
In the gekko folder:
looking for tulind.js
>>>thats all we need for the configuration.
more information:
tulip bindings for node.js
tulip indicators
//////////test results: BASSic MACD
>>>>save as tulip_MACD.js
>>>>save as tulip_MACD.toml
lets have a look at the tulind.js file (library).
Its long. Use the Find function in your editor:
>>>Ctrl+F
>>>>>type macd and hit enter
Its a bit hard to understand but we only need the options.
Above it says "requires".
As you learnd in my TUT #2
>>>>>the squared bracket designate ARRAYs (number-chains).
and the outputs:
In the options array, are objects that have a name and a value associated to it.
If we map the user.settings we can use the array name. thats the quick n dirty way:
now we move the whole array into the indicator:
the order would be the same as we set it up in the setttings.
For the results we would use the right object:
>>>Remember if you want to use it globally, you must first make a global object out of it. TUT #1
The Stoch oscillator has also multiple options/outputs.
//////////test results: BASSic STOCH
>>>>save as tulip_STOCH.js
[url=https://forum.gekko.wizb.it/thread-57009.html][/url]
>>>>save as tulip_STOCH.toml
The options and outputs are a bit different.
I have tryed other indicators but the test results were aweful
>>> THUS THIS BASSic TULIP STRATs, AS THEY ARE, WOULD BE USED FOR SHORTTERM TRADING
>>>>>OTHER INDICATORS COULD BE USEFULL FOR LONGTERM TREND INDICATION. let me know...
___________________________________________________________________________
In the previous TUTs, we have created utilities for a preset strat.
here we learnd how to setup indicators.
In the next TUTs we will beginn to build our strat.
>>>i have randoomly choosen Tulip indicators but it could be eny avilable indicators for gekko.
>>>>>the test results are all in the same uptrend/period and should only show the trigger points.
>>>>>>>WARNING THESE STRATEGIES ARE NOT PROFITABLE ENOUGH OVER TIME.
(((((it needs more than one indicator-if-statement to become a profitable trader)))))
Some indicators have two or three options (user input averaging length) and more than one output.
In this case, Arrays are used to set the inputs or read the output values.
First a simple RSI (realtime strength index) with one input/output
////////Test results: BASSic RSI
Code:
/*
BASSic tulip_RSI
*/
var _ = require('lodash');
var log = require('../core/log.js');
var config = require('../core/util.js').getConfig();
var strat = {};
strat.init = function () {
//add candle.close
price =
{
close: 0//this.candle
};
this.price = price;
logic =
{
longpos: false
};
this.logic = logic;
//first fetch settings from .toml
var customRSIsettings = this.settings.RSI;
// define the indicators we need //move the settings into >>>rsi input length
this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);
}
strat.update = function (candle) {
}
strat.log = function () {
}
strat.check = function (candle) {
//update price.close
this.price.close = this.candle.close;
//update the indicator before using it
var resultRSI = this.tulipIndicators.myrsi.result.result;
//lets trade...
if (resultRSI > this.settings.trsRSI.high && this.logic.longpos !== false) {
this.logic.longpos = false;
this.advice('short');
log.debug('goShort price ' + this.price.close + ' rsi ' + resultRSI.toFixed(2));
}
else if (resultRSI < this.settings.trsRSI.low && this.logic.longpos !== true) {
this.logic.longpos = true;
this.advice('long');
log.debug('goLong price ' + this.price.close + ' rsi ' + resultRSI.toFixed(2));
}
}
module.exports = strat;
>select all and delete the content
>>copy/paste my example code strat above
>>>Save as: rename to:
>>>>tulip_RSI.js //and save
WARNIG: MY CODE INDENTS HAVE BEEN BIT MESSED UP HERE
JUST: in your editor right-click choose [format document] before save...
Code:
[RSI]
optInTimePeriod = 15
[trsRSI]
high = 71
low = 28
#_try_1min_candles_#
#_binance_BTC_USDT_#
>select all and delete the content
>>copy/paste my example code user settings above
>>>Save as: rename to:
>>>>tulip_RSI.toml
>>>>>Save as type //<<<SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!)
The MA (Moving avereage) with two MAs looking for the crossing point.
//////////test results: BASSic MA
Code:
/*
BASSic tulip_MA
*/
var _ = require('lodash');
var log = require('../core/log.js');
var config = require('../core/util.js').getConfig();
var strat = {};
strat.init = function () {
//add candle.close
price =
{
close: 0//this.candle
};
this.price = price;
logic =
{
longpos: false
};
this.logic = logic;
//first fetch settings from .toml
var customMAfastsettings = this.settings.MA_Fast;
var customMAslowsettings = this.settings.MA_Slow;
// define the indicators we need //move the settings into >>>rsi input length
this.addTulipIndicator('mafast', 'sma', customMAfastsettings);
this.addTulipIndicator('maslow', 'sma', customMAslowsettings);
}
strat.update = function (candle) {
}
strat.log = function () {
}
strat.check = function (candle) {
//update price.close
this.price.close = this.candle.close;
//update the indicator before using it
var resultMAfast = this.tulipIndicators.mafast.result.result;
var resultMAslow = this.tulipIndicators.maslow.result.result;
//lets trade...
if (resultMAslow > resultMAfast && this.logic.longpos !== false) {
this.logic.longpos = false;
this.advice('short');
log.debug('goShort price ' + this.price.close + ' maS ' + resultMAslow.toFixed(2) + ' maF ' + resultMAfast.toFixed(2));
}
else if (resultMAslow < resultMAfast && this.logic.longpos !== true) {
this.logic.longpos = true;
this.advice('long');
log.debug('goLong price ' + this.price.close + ' maS ' + resultMAslow.toFixed(2) + ' maF ' + resultMAfast.toFixed(2));
}
}
module.exports = strat;
Code:
[MA_Fast]
optInTimePeriod = 50
[MA_Slow]
optInTimePeriod = 100
#_try_15min_candles_#
#_binance_BTC_USDT_#
It is the same setup as for the RSI, only dual.
the MACD has more options and outputs, but which ones??
In the gekko folder:
Code:
C:\Users.....\gekko\core
>>>thats all we need for the configuration.
more information:
tulip bindings for node.js
tulip indicators
//////////test results: BASSic MACD
Code:
/*
BASSic tulip_MACD
*/
var _ = require('lodash');
var log = require('../core/log.js');
var config = require('../core/util.js').getConfig();
var strat = {};
strat.init = function () {
//add candle.close
price =
{
close: 0//this.candle
};
this.price = price;
logic =
{
longpos: false
};
this.logic = logic;
//first fetch settings from .toml
var customMACDsettings = this.settings.MACD;
// define the indicators we need //move the settings into >>>macd input length
this.addTulipIndicator('mymacd', 'macd', customMACDsettings);
}
strat.update = function (candle) {
}
strat.log = function () {
}
strat.check = function (candle) {
//update price.close
this.price.close = this.candle.close;
//update the indicator before using it
var resultMACD = this.tulipIndicators.mymacd.result;
//lets trade...
if (resultMACD.macd > resultMACD.macdSignal && this.logic.longpos !== false) {
this.logic.longpos = false;
this.advice('short');
log.debug('goShort price ' + this.price.close + ' mc ' + resultMACD.macd.toFixed(2) + ' m.sig ' + resultMACD.macdSignal.toFixed(2));
}
else if (resultMACD.macd < resultMACD.macdSignal && this.logic.longpos !== true) {
this.logic.longpos = true;
this.advice('long');
log.debug('goLong price ' + this.price.close + ' mc ' + resultMACD.macd.toFixed(2) + ' m.sig ' + resultMACD.macdSignal.toFixed(2));
}
}
module.exports = strat;
Code:
[MACD]
optInFastPeriod = 25
optInSlowPeriod = 50
optInSignalPeriod = 30
#_try_15min_candles_#
#_Binance_BTC_USDT_#
lets have a look at the tulind.js file (library).
Its long. Use the Find function in your editor:
>>>Ctrl+F
>>>>>type macd and hit enter
Code:
methods.macd = {
requires: ['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod'],
create: (params) => {
verifyParams('macd', params);
return (data, callback) => execute(callback, {
indicator: tulind.indicators.macd,
inputs: [data.close],
options: [params.optInFastPeriod, params.optInSlowPeriod, params.optInSignalPeriod],
results: ['macd', 'macdSignal', 'macdHistogram'],
});
}
}
Above it says "requires".
As you learnd in my TUT #2
>>>>>the squared bracket designate ARRAYs (number-chains).
Code:
['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod']
and the outputs:
Code:
['macd', 'macdSignal', 'macdHistogram']
In the options array, are objects that have a name and a value associated to it.
If we map the user.settings we can use the array name. thats the quick n dirty way:
Code:
var customMACDsettings = this.settings.MACD;
now we move the whole array into the indicator:
Code:
this.addTulipIndicator('mymacd', 'macd', customMACDsettings);
For the results we would use the right object:
Code:
resultMACD.macd
resultMACD.macdSignal
resultMACD.macdHistogram
>>>Remember if you want to use it globally, you must first make a global object out of it. TUT #1
The Stoch oscillator has also multiple options/outputs.
//////////test results: BASSic STOCH
Code:
/*
BASSic tulip_STOCH
*/
var _ = require('lodash');
var log = require('../core/log.js');
var config = require('../core/util.js').getConfig();
var strat = {};
strat.init = function () {
//add candle.close
price =
{
close: 0//this.candle
};
this.price = price;
logic =
{
longpos: false
};
this.logic = logic;
//first fetch settings from .toml
var customSTOCHsettings = this.settings.STOCH;
// define the indicators we need //move the settings into >>>rsi input length
this.addTulipIndicator('mystoch', 'stoch', customSTOCHsettings);
}
strat.update = function (candle) {
}
strat.log = function () {
}
strat.check = function (candle) {
//update price.close
this.price.close = this.candle.close;
//update the indicator before using it
var resultSTOCH = this.tulipIndicators.mystoch.result;
//lets trade...
if (resultSTOCH.stochD > this.settings.trsSTOCH.high && this.logic.longpos !== false) {
this.logic.longpos = false;
this.advice('short');
log.debug('goShort price ' + this.price.close + ' stochD ' + resultSTOCH.stochD.toFixed(2));
}
else if (resultSTOCH.stochD < this.settings.trsSTOCH.low && this.logic.longpos !== true) {
this.logic.longpos = true;
this.advice('long');
log.debug('goLong price ' + this.price.close + ' stochD ' + resultSTOCH.stochD.toFixed(2));
}
}
module.exports = strat;
[url=https://forum.gekko.wizb.it/thread-57009.html][/url]
Code:
[STOCH]
optInFastKPeriod = 30
optInSlowKPeriod = 4
optInSlowDPeriod = 4
[trsSTOCH]
high = 80
low = 20
#_try_8min_candles_#
#_binance_BTC_USDT_#
Code:
methods.stoch = {
requires: ['optInFastKPeriod', 'optInSlowKPeriod', 'optInSlowDPeriod'],
create: (params) => {
verifyParams('stoch', params);
return (data, callback) => execute(callback, {
indicator: tulind.indicators.stoch,
inputs: [data.high, data.low, data.close],
options: [params.optInFastKPeriod, params.optInSlowKPeriod, params.optInSlowDPeriod],
results: ['stochK', 'stochD'],
});
}
}
I have tryed other indicators but the test results were aweful
>>> THUS THIS BASSic TULIP STRATs, AS THEY ARE, WOULD BE USED FOR SHORTTERM TRADING
>>>>>OTHER INDICATORS COULD BE USEFULL FOR LONGTERM TREND INDICATION. let me know...
___________________________________________________________________________
In the previous TUTs, we have created utilities for a preset strat.
here we learnd how to setup indicators.
In the next TUTs we will beginn to build our strat.