<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Gekko Forum - Guides]]></title>
		<link>https://forum.gekko.wizb.it/</link>
		<description><![CDATA[Gekko Forum - https://forum.gekko.wizb.it]]></description>
		<pubDate>Tue, 14 Apr 2026 23:56:07 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[is gekko useful for stock market as well?]]></title>
			<link>https://forum.gekko.wizb.it/thread-58080.html</link>
			<pubDate>Wed, 29 Apr 2020 15:59:39 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-58080.html</guid>
			<description><![CDATA[Hi, I am totally new to Gekko, I have two (probably stupid) questions:<br />
<br />
1) can I use Gekko for analyzing stock market data instead of cryptocurrencies? <br />
2) how can I feed Gekko with custom market/stock data?]]></description>
			<content:encoded><![CDATA[Hi, I am totally new to Gekko, I have two (probably stupid) questions:<br />
<br />
1) can I use Gekko for analyzing stock market data instead of cryptocurrencies? <br />
2) how can I feed Gekko with custom market/stock data?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Adding Events to your strategy]]></title>
			<link>https://forum.gekko.wizb.it/thread-58031.html</link>
			<pubDate>Tue, 05 Nov 2019 09:13:42 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-58031.html</guid>
			<description><![CDATA[There are a large <a href="https://gekko.wizb.it/docs/internals/events.html" target="_blank" rel="noopener" class="mycode_url">number of Events</a> with interesting data that are emitted by the Gekko plugins. Some would be quite useful in strategies but they are not available for the simple reason that strategies are not plugins and therefore cannot directly pick up the triggered events.<br />
<br />
My quest was initially to be able to read live portfolio data as I have two strategies running in parallell and I need to know if I am exposed or not. I also want the strategy to react correctly to manual changes in the portfolio. I have since added more events that have proven quite useful.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Before using this guide, please be aware that it requires changes to two core Gekko plugins, meaning that if you update Gekko your changes are lost and the strategy will not work. It may also mean you break something else if you are not careful.</span><br />
<br />
That being said, it is quite easy to do. Let's add the <a href="https://gekko.wizb.it/docs/internals/events.html#portfolioChange-event" target="_blank" rel="noopener" class="mycode_url">PortfolioChange event</a> (~ is your Gekko root folder);<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">tradingAdvisor.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Actor.prototype.processPortfolioChange = function(portfolio) {<span style="font-size: small;" class="mycode_size">  // This must be the handler name. The parameter name can be made up (portfolio). Just be consistent.</span><br />
  this.strategy.processPortfolioChange(portfolio);<span style="font-size: small;" class="mycode_size">  // This will be executed in baseTradingMethod.js</span><br />
}</span><br />
<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">baseTradingMethod.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Base.prototype.processPortfolioChange = function(portfolio) {<br />
  this.onPortfolioChange(portfolio);  <span style="font-size: small;" class="mycode_size">// onPortfolioChange will be accessible in the strategy</span><br />
}</span><br />
<br />
In your strategy, <span style="font-weight: bold;" class="mycode_b"><span style="font-family: Consolas;" class="mycode_font">onPortfolioChange</span></span> will trigger when the portfolio has changed so you can read the asset and currency variables. This is independent of your candle size so this can trigger at any moment. Add, for example;<br />
<span style="font-family: Consolas;" class="mycode_font">strat.onPortfolioChange = function (portfolio) {<br />
 log.info('Portfolio has changed; Asset=', portfolio.asset.toFixed(3), 'and Currency=', portfolio.currency.toFixed(0) );<br />
}</span><br />
<br />
<span style="font-weight: bold;" class="mycode_b">That's it! </span><br />
<br />
Follow the same logic for any other Events. This adds <a href="https://gekko.wizb.it/docs/internals/events.html#portfolioValueChange-event" target="_blank" rel="noopener" class="mycode_url">Balance updates</a>;<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">tradingAdvisor.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Actor.prototype.portfolioValueChange = function(balance) {<br />
  this.strategy.portfolioValueChange(balance);<br />
}</span><br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">baseTradingMethod.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Base.prototype.portfolioValueChange = function(balance) {<br />
  this.onBalanceChange(balance);<br />
}</span><br />
In your strategy, <span style="font-weight: bold;" class="mycode_b">add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">strat.onBalanceChange = function (balance) {<br />
  log.info('Balance has changed; it is now', balance.balance.toFixed(1) );<br />
}</span>]]></description>
			<content:encoded><![CDATA[There are a large <a href="https://gekko.wizb.it/docs/internals/events.html" target="_blank" rel="noopener" class="mycode_url">number of Events</a> with interesting data that are emitted by the Gekko plugins. Some would be quite useful in strategies but they are not available for the simple reason that strategies are not plugins and therefore cannot directly pick up the triggered events.<br />
<br />
My quest was initially to be able to read live portfolio data as I have two strategies running in parallell and I need to know if I am exposed or not. I also want the strategy to react correctly to manual changes in the portfolio. I have since added more events that have proven quite useful.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Before using this guide, please be aware that it requires changes to two core Gekko plugins, meaning that if you update Gekko your changes are lost and the strategy will not work. It may also mean you break something else if you are not careful.</span><br />
<br />
That being said, it is quite easy to do. Let's add the <a href="https://gekko.wizb.it/docs/internals/events.html#portfolioChange-event" target="_blank" rel="noopener" class="mycode_url">PortfolioChange event</a> (~ is your Gekko root folder);<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">tradingAdvisor.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Actor.prototype.processPortfolioChange = function(portfolio) {<span style="font-size: small;" class="mycode_size">  // This must be the handler name. The parameter name can be made up (portfolio). Just be consistent.</span><br />
  this.strategy.processPortfolioChange(portfolio);<span style="font-size: small;" class="mycode_size">  // This will be executed in baseTradingMethod.js</span><br />
}</span><br />
<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">baseTradingMethod.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Base.prototype.processPortfolioChange = function(portfolio) {<br />
  this.onPortfolioChange(portfolio);  <span style="font-size: small;" class="mycode_size">// onPortfolioChange will be accessible in the strategy</span><br />
}</span><br />
<br />
In your strategy, <span style="font-weight: bold;" class="mycode_b"><span style="font-family: Consolas;" class="mycode_font">onPortfolioChange</span></span> will trigger when the portfolio has changed so you can read the asset and currency variables. This is independent of your candle size so this can trigger at any moment. Add, for example;<br />
<span style="font-family: Consolas;" class="mycode_font">strat.onPortfolioChange = function (portfolio) {<br />
 log.info('Portfolio has changed; Asset=', portfolio.asset.toFixed(3), 'and Currency=', portfolio.currency.toFixed(0) );<br />
}</span><br />
<br />
<span style="font-weight: bold;" class="mycode_b">That's it! </span><br />
<br />
Follow the same logic for any other Events. This adds <a href="https://gekko.wizb.it/docs/internals/events.html#portfolioValueChange-event" target="_blank" rel="noopener" class="mycode_url">Balance updates</a>;<br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">tradingAdvisor.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Actor.prototype.portfolioValueChange = function(balance) {<br />
  this.strategy.portfolioValueChange(balance);<br />
}</span><br />
<span style="font-weight: bold;" class="mycode_b">Edit </span><span style="font-family: Consolas;" class="mycode_font">~/plugins/tradingAdvisor/<span style="font-weight: bold;" class="mycode_b">baseTradingMethod.js </span></span><span style="font-weight: bold;" class="mycode_b">and add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">Base.prototype.portfolioValueChange = function(balance) {<br />
  this.onBalanceChange(balance);<br />
}</span><br />
In your strategy, <span style="font-weight: bold;" class="mycode_b">add:</span><br />
<span style="font-family: Consolas;" class="mycode_font">strat.onBalanceChange = function (balance) {<br />
  log.info('Balance has changed; it is now', balance.balance.toFixed(1) );<br />
}</span>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[trade with 50%]]></title>
			<link>https://forum.gekko.wizb.it/thread-58013.html</link>
			<pubDate>Fri, 20 Sep 2019 06:08:08 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-58013.html</guid>
			<description><![CDATA[Hi,<br />
<br />
i am new with gekko, but it works now :-)<br />
i want to run 2 gekkos with one trading account. So i have to limit each gekko to a trading amount of 50% ?<br />
<br />
can anybody tell me in simple words (i am not a programmer, i read some articles about this but didn't understand it ) where i can tell gekko to trade only with 50% of my amount ?<br />
<br />
thank you so much<br />
<br />
Mike]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
i am new with gekko, but it works now :-)<br />
i want to run 2 gekkos with one trading account. So i have to limit each gekko to a trading amount of 50% ?<br />
<br />
can anybody tell me in simple words (i am not a programmer, i read some articles about this but didn't understand it ) where i can tell gekko to trade only with 50% of my amount ?<br />
<br />
thank you so much<br />
<br />
Mike]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Quick example of how to implement NATR in a strategy.]]></title>
			<link>https://forum.gekko.wizb.it/thread-57984.html</link>
			<pubDate>Mon, 05 Aug 2019 00:59:49 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57984.html</guid>
			<description><![CDATA[Can anybody post a quick code example of how this indicators is coded in a strategy?]]></description>
			<content:encoded><![CDATA[Can anybody post a quick code example of how this indicators is coded in a strategy?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Playlist of all my Gekko Trading Bot videos]]></title>
			<link>https://forum.gekko.wizb.it/thread-57779.html</link>
			<pubDate>Tue, 27 Nov 2018 23:37:08 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57779.html</guid>
			<description><![CDATA[I have been creating videos on the Gekko Trading Bot since the beginning of this year. I covered everything from installing it on Windows, Mac, Linux, Docker, and backtesting, running various plugins like Telegram and Twitter. I'm sure some of you have watched some of my videos. I figured I probably should have a playlist of all the videos here so you can reference them at your leisure. <br />
<br />
<a href="https://www.youtube.com/playlist?list=PL1t7sxpCVDDKCZStBot_RjPlPyy9Qa3aY" target="_blank" rel="noopener" class="mycode_url">https://www.youtube.com/playlist?list=PL...lPyy9Qa3aY</a><br />
<br />
In addition, I get asked what Gekko topics I should cover next. I don't always respond to PMs (sorry, my inbox is inundated) so it might be better to leave a comment here and I will let you know if that is something that I will cover in a future video.]]></description>
			<content:encoded><![CDATA[I have been creating videos on the Gekko Trading Bot since the beginning of this year. I covered everything from installing it on Windows, Mac, Linux, Docker, and backtesting, running various plugins like Telegram and Twitter. I'm sure some of you have watched some of my videos. I figured I probably should have a playlist of all the videos here so you can reference them at your leisure. <br />
<br />
<a href="https://www.youtube.com/playlist?list=PL1t7sxpCVDDKCZStBot_RjPlPyy9Qa3aY" target="_blank" rel="noopener" class="mycode_url">https://www.youtube.com/playlist?list=PL...lPyy9Qa3aY</a><br />
<br />
In addition, I get asked what Gekko topics I should cover next. I don't always respond to PMs (sorry, my inbox is inundated) so it might be better to leave a comment here and I will let you know if that is something that I will cover in a future video.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TECH TUT] Updating a old exchange integration to Gekko 0.6+]]></title>
			<link>https://forum.gekko.wizb.it/thread-57777.html</link>
			<pubDate>Mon, 26 Nov 2018 11:34:20 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57777.html</guid>
			<description><![CDATA[This is a technical guide that explains how to migrate legacy exchange wrapper files to new Gekko Broker wrapper files used by Gekko +0.6. This is meant for technical contributors to Gekko who want to update an old exchange integration into Gekko. This isn't an exact guide but it roughly covers the things you need to fix.<br />
<br />
All exchange wrappers can be found here: <a href="https://github.com/askmike/gekko/tree/develop/exchange/wrappers" target="_blank" rel="noopener" class="mycode_url">https://github.com/askmike/gekko/tree/de...e/wrappers</a><br />
<br />
- All files ending with .js.old are old wrappers not updated yet.<br />
- All files ending with .js are new wrappers not are working with Gekko 0.6 or higher.<br />
<br />
If you want to update an outdated wrapper you need to do a few things:<br />
<br />
- Remove all requires to any files outside the `gekko/exchange` directory, such as log and util (the wrappers are now part of a standalone library called Gekko Broker).<br />
- Some function signatures have changed, such as:<br />
  - checkOrder: the callback needs to be passed on object describing partial fills &amp; order rejection<br />
  - cancelOrder: the callback needs to be passed err as well as a "filled" boolean and optionally more data regarding partial fills.<br />
- Error handling works different now, you need to create a function that will handle correct (non error result) and you will need to create a global function that will process the exchange SDK output and normalize error types for the new retry system.<br />
<br />
You can look at existing updated implementations for example, and be sure to check out the wrapper reference here: <a href="https://gekko.wizb.it/docs/extending/add_an_exchange.html" target="_blank" rel="noopener" class="mycode_url">https://gekko.wizb.it/docs/extending/add...hange.html</a>]]></description>
			<content:encoded><![CDATA[This is a technical guide that explains how to migrate legacy exchange wrapper files to new Gekko Broker wrapper files used by Gekko +0.6. This is meant for technical contributors to Gekko who want to update an old exchange integration into Gekko. This isn't an exact guide but it roughly covers the things you need to fix.<br />
<br />
All exchange wrappers can be found here: <a href="https://github.com/askmike/gekko/tree/develop/exchange/wrappers" target="_blank" rel="noopener" class="mycode_url">https://github.com/askmike/gekko/tree/de...e/wrappers</a><br />
<br />
- All files ending with .js.old are old wrappers not updated yet.<br />
- All files ending with .js are new wrappers not are working with Gekko 0.6 or higher.<br />
<br />
If you want to update an outdated wrapper you need to do a few things:<br />
<br />
- Remove all requires to any files outside the `gekko/exchange` directory, such as log and util (the wrappers are now part of a standalone library called Gekko Broker).<br />
- Some function signatures have changed, such as:<br />
  - checkOrder: the callback needs to be passed on object describing partial fills &amp; order rejection<br />
  - cancelOrder: the callback needs to be passed err as well as a "filled" boolean and optionally more data regarding partial fills.<br />
- Error handling works different now, you need to create a function that will handle correct (non error result) and you will need to create a global function that will process the exchange SDK output and normalize error types for the new retry system.<br />
<br />
You can look at existing updated implementations for example, and be sure to check out the wrapper reference here: <a href="https://gekko.wizb.it/docs/extending/add_an_exchange.html" target="_blank" rel="noopener" class="mycode_url">https://gekko.wizb.it/docs/extending/add...hange.html</a>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] Importing market data from the CLI]]></title>
			<link>https://forum.gekko.wizb.it/thread-57656.html</link>
			<pubDate>Tue, 18 Sep 2018 02:54:00 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57656.html</guid>
			<description><![CDATA[[I might move this guide into the docs one day]<br />
 <br />
If you are experiencing issues importing data via the interface, you can do so via the commandline to get more debug information needed to troubleshoot your problem.<br />
<br />
Step 1: create a config file<br />
<br />
Copy gekko/sample-config.js into gekko/config.js<br />
<br />
Step 2: configure your config<br />
<br />
Open up the gekko/config.js file with a text editor (<a href="https://www.sublimetext.com/" target="_blank" rel="noopener" class="mycode_url">sublime</a> is excellent, free and runs on all major OSes).<br />
<br />
- Search for "config.watch" and replace exchange, currency and asset with the market you want to import from.<br />
- [OPTIONAL] Search for "config.importer" and replace the from date with a more recent date (for example a month ago).<br />
<br />
Step 3: run the import<br />
<br />
- Open a terminal and navigate to the Gekko directory.<br />
- Run the import by typing: node gekko -c config.js -i]]></description>
			<content:encoded><![CDATA[[I might move this guide into the docs one day]<br />
 <br />
If you are experiencing issues importing data via the interface, you can do so via the commandline to get more debug information needed to troubleshoot your problem.<br />
<br />
Step 1: create a config file<br />
<br />
Copy gekko/sample-config.js into gekko/config.js<br />
<br />
Step 2: configure your config<br />
<br />
Open up the gekko/config.js file with a text editor (<a href="https://www.sublimetext.com/" target="_blank" rel="noopener" class="mycode_url">sublime</a> is excellent, free and runs on all major OSes).<br />
<br />
- Search for "config.watch" and replace exchange, currency and asset with the market you want to import from.<br />
- [OPTIONAL] Search for "config.importer" and replace the from date with a more recent date (for example a month ago).<br />
<br />
Step 3: run the import<br />
<br />
- Open a terminal and navigate to the Gekko directory.<br />
- Run the import by typing: node gekko -c config.js -i]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[How to change database in the new version]]></title>
			<link>https://forum.gekko.wizb.it/thread-57647.html</link>
			<pubDate>Fri, 14 Sep 2018 21:10:27 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57647.html</guid>
			<description><![CDATA[I did change from sqlite to postgres, but it doens't work on version 6. I did all I can do, but I still not able to use postgresql.<br />
Anyone know what should I change in this new version?]]></description>
			<content:encoded><![CDATA[I did change from sqlite to postgres, but it doens't work on version 6. I did all I can do, but I still not able to use postgresql.<br />
Anyone know what should I change in this new version?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[Tutorial] Windows64 native with talib tulind and xFFFFF repo]]></title>
			<link>https://forum.gekko.wizb.it/thread-57602.html</link>
			<pubDate>Mon, 03 Sep 2018 03:25:15 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57602.html</guid>
			<description><![CDATA[<span style="color: #666666;" class="mycode_color">Hi, i can't post this as thread because i have links to resources (github, nodejs) and forum treats it as spam.<br />
<br />
Anyway the tutorial is about my struggle installing gekko on native Windows 10 64 bit as bash for windows seems slow for me(probably just me though).<br />
<br />
What this tutorial includes:<br />
<br />
1. gekko typical install<br />
2. installation of windows-build-tools<br />
3. installing/Compiling of native talib and tulind<br />
4. installation of Gekko-Strategies by xFFFFF<br />
5. installation of modules to make neuralnet-based strats work (some of them)<br />
<br />
Here is the pdf though. If you guys tested it and it works kindly ask admin to post and revise if it's helpful for newbies like me. Thank you.<br />
<br />
*public domain, use at your own risk... blah blah blah, credits to original authors.</span><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://forum.gekko.wizb.it/images/attachtypes/pdf.png" title="Adobe Acrobat PDF" border="0" alt=".pdf" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=269" target="_blank" title="">GekkoOnWindows64Native.pdf</a> (Size: 221.52 KB / Downloads: 216)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[<span style="color: #666666;" class="mycode_color">Hi, i can't post this as thread because i have links to resources (github, nodejs) and forum treats it as spam.<br />
<br />
Anyway the tutorial is about my struggle installing gekko on native Windows 10 64 bit as bash for windows seems slow for me(probably just me though).<br />
<br />
What this tutorial includes:<br />
<br />
1. gekko typical install<br />
2. installation of windows-build-tools<br />
3. installing/Compiling of native talib and tulind<br />
4. installation of Gekko-Strategies by xFFFFF<br />
5. installation of modules to make neuralnet-based strats work (some of them)<br />
<br />
Here is the pdf though. If you guys tested it and it works kindly ask admin to post and revise if it's helpful for newbies like me. Thank you.<br />
<br />
*public domain, use at your own risk... blah blah blah, credits to original authors.</span><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://forum.gekko.wizb.it/images/attachtypes/pdf.png" title="Adobe Acrobat PDF" border="0" alt=".pdf" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=269" target="_blank" title="">GekkoOnWindows64Native.pdf</a> (Size: 221.52 KB / Downloads: 216)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] Running a backtest through the CLI]]></title>
			<link>https://forum.gekko.wizb.it/thread-57581.html</link>
			<pubDate>Fri, 17 Aug 2018 07:10:24 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57581.html</guid>
			<description><![CDATA[[I might move this guide into the docs one day]<br />
<br />
If you are developing your own strategy or want to gain more insights in what is happening you can easily use the commandline interface (CLI) to run a backtest quickly. By default these backtests include a lot of debugging information which you can use to understand what is going on inside the strategy you are running.<br />
<br />
This guide assumes you have historical data available (imported previously or obtained from a live gekko).<br />
<br />
Step 1: create a config file<br />
<br />
Copy gekko/sample-config.js into gekko/config.js<br />
<br />
Step 2: configure your config<br />
<br />
Open up the gekko/config.js file with a text editor (<a href="https://www.sublimetext.com/" target="_blank" rel="noopener" class="mycode_url">sublime</a> is excellent, free and runs on all major OSes).<br />
<br />
- Search for "config.watch" and replace exchange, currency and asset with the market you want to backtest over.<br />
- Search for "config.tradingAdvisor" and set method to your strategy, candleSize to the type of candles you want (in minutes, hourly candles means filling in 60).<br />
- [optoinally] Search for "paperTrader" and configure the slippage and spread according to the market. If you are trading on a big market (BTC/USD for example) the defaults are fine.<br />
<br />
Step 3: run the backtest<br />
<br />
- Open a terminal and navigate to the Gekko directory.<br />
- Run the backtest by typing: node gekko -c config.js -b]]></description>
			<content:encoded><![CDATA[[I might move this guide into the docs one day]<br />
<br />
If you are developing your own strategy or want to gain more insights in what is happening you can easily use the commandline interface (CLI) to run a backtest quickly. By default these backtests include a lot of debugging information which you can use to understand what is going on inside the strategy you are running.<br />
<br />
This guide assumes you have historical data available (imported previously or obtained from a live gekko).<br />
<br />
Step 1: create a config file<br />
<br />
Copy gekko/sample-config.js into gekko/config.js<br />
<br />
Step 2: configure your config<br />
<br />
Open up the gekko/config.js file with a text editor (<a href="https://www.sublimetext.com/" target="_blank" rel="noopener" class="mycode_url">sublime</a> is excellent, free and runs on all major OSes).<br />
<br />
- Search for "config.watch" and replace exchange, currency and asset with the market you want to backtest over.<br />
- Search for "config.tradingAdvisor" and set method to your strategy, candleSize to the type of candles you want (in minutes, hourly candles means filling in 60).<br />
- [optoinally] Search for "paperTrader" and configure the slippage and spread according to the market. If you are trading on a big market (BTC/USD for example) the defaults are fine.<br />
<br />
Step 3: run the backtest<br />
<br />
- Open a terminal and navigate to the Gekko directory.<br />
- Run the backtest by typing: node gekko -c config.js -b]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[HELP INSTALLING INDICATOR PLEASE HELP]]></title>
			<link>https://forum.gekko.wizb.it/thread-57534.html</link>
			<pubDate>Fri, 10 Aug 2018 21:47:20 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57534.html</guid>
			<description><![CDATA[herkese gekko'yu selamlıyorum ben de tulibı bir kenara kurdum ama hiçbir gösterge takmadım ve çalışamıyorum yeniim lütfen yardım ederim teşekkürler]]></description>
			<content:encoded><![CDATA[herkese gekko'yu selamlıyorum ben de tulibı bir kenara kurdum ama hiçbir gösterge takmadım ve çalışamıyorum yeniim lütfen yardım ederim teşekkürler]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] CONFIG-FILE CONVERTOR FOR CLI GEKKO]]></title>
			<link>https://forum.gekko.wizb.it/thread-57274.html</link>
			<pubDate>Thu, 21 Jun 2018 16:25:32 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57274.html</guid>
			<description><![CDATA[for the CLI-gekko (terminal gekko) we must set up the sample-config.js.<br />
<br />
our strategie has its "my_strategie.toml" file, but in the config IT MUST BE AS JSON-style CODE.<br />
<br />
if you do not use the backtest Machine from xFFFFF,<br />
you can simply use an online tool that makes the conversation for you.<br />
this is very easy and never makes an error.!!!<br />
<br />
go to this page:<br />
<a href="https://toml-to-json.matiaskorhonen.fi/" target="_blank" rel="noopener" class="mycode_url">toml-json convertor</a><br />
<br />
here simply copie paste your .toml code<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 30<br />
<br />
[trsRSI]<br />
high = 68<br />
low = 30<br />
<br />
[___stop_abs____]<br />
stop_abs = -1.7<br />
abs_exp = -250</code></div></div><br />
now copie/paste the created .json code into your sample-config.js, as you can learn from my other Tutorial:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>{<br />
  "___trendatron___": {<br />
    "__longPos": false<br />
  },<br />
  "_backtest_start_": {<br />
    "__________day": 1,<br />
    "______month": 4,<br />
    "_____hour": 18,<br />
    "_minute": 38,<br />
    "candle_size": 1<br />
  },<br />
  "RSI": {<br />
    "optInTimePeriod": 30<br />
  },<br />
  "trsRSI": {<br />
    "high": 68,<br />
    "low": 30<br />
  },<br />
  "___stop_abs____": {<br />
    "stop_abs": -1.7,<br />
    "abs_exp": -250<br />
  }<br />
}</code></div></div><br />
<br />
<a href="https://forum.gekko.wizb.it/thread-57089.html" target="_blank" rel="noopener" class="mycode_url">TUT#5</a><br />
just scroll down and find the thread :-)<br />
<br />
thanks to xFFFFF, Matias Korhonen, and Ankasem<br />
hope this helps]]></description>
			<content:encoded><![CDATA[for the CLI-gekko (terminal gekko) we must set up the sample-config.js.<br />
<br />
our strategie has its "my_strategie.toml" file, but in the config IT MUST BE AS JSON-style CODE.<br />
<br />
if you do not use the backtest Machine from xFFFFF,<br />
you can simply use an online tool that makes the conversation for you.<br />
this is very easy and never makes an error.!!!<br />
<br />
go to this page:<br />
<a href="https://toml-to-json.matiaskorhonen.fi/" target="_blank" rel="noopener" class="mycode_url">toml-json convertor</a><br />
<br />
here simply copie paste your .toml code<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 30<br />
<br />
[trsRSI]<br />
high = 68<br />
low = 30<br />
<br />
[___stop_abs____]<br />
stop_abs = -1.7<br />
abs_exp = -250</code></div></div><br />
now copie/paste the created .json code into your sample-config.js, as you can learn from my other Tutorial:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>{<br />
  "___trendatron___": {<br />
    "__longPos": false<br />
  },<br />
  "_backtest_start_": {<br />
    "__________day": 1,<br />
    "______month": 4,<br />
    "_____hour": 18,<br />
    "_minute": 38,<br />
    "candle_size": 1<br />
  },<br />
  "RSI": {<br />
    "optInTimePeriod": 30<br />
  },<br />
  "trsRSI": {<br />
    "high": 68,<br />
    "low": 30<br />
  },<br />
  "___stop_abs____": {<br />
    "stop_abs": -1.7,<br />
    "abs_exp": -250<br />
  }<br />
}</code></div></div><br />
<br />
<a href="https://forum.gekko.wizb.it/thread-57089.html" target="_blank" rel="noopener" class="mycode_url">TUT#5</a><br />
just scroll down and find the thread :-)<br />
<br />
thanks to xFFFFF, Matias Korhonen, and Ankasem<br />
hope this helps]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Japonicus Results]]></title>
			<link>https://forum.gekko.wizb.it/thread-57204.html</link>
			<pubDate>Wed, 23 May 2018 05:55:12 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57204.html</guid>
			<description><![CDATA[Hi all,<br />
<br />
Anyone got a guide on how to read the results from Japonicus?<br />
<br />
Thanks]]></description>
			<content:encoded><![CDATA[Hi all,<br />
<br />
Anyone got a guide on how to read the results from Japonicus?<br />
<br />
Thanks]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Help for my strategy]]></title>
			<link>https://forum.gekko.wizb.it/thread-57139.html</link>
			<pubDate>Thu, 10 May 2018 21:37:46 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57139.html</guid>
			<description><![CDATA[Hello,<br />
<br />
how do i implement a new indicator?I installed talib and tulip but dont know how to implement the bollinger bands indicator.I also need an advice how to create a trigger where the buy signal is triggered when the candle closes under the lowest band and then sell it when it closes on/above the middle/upper band.I have no programming skills so write slowly please.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
how do i implement a new indicator?I installed talib and tulip but dont know how to implement the bollinger bands indicator.I also need an advice how to create a trigger where the buy signal is triggered when the candle closes under the lowest band and then sell it when it closes on/above the middle/upper band.I have no programming skills so write slowly please.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] STRATEGIE #5 dynamique stoploss  [SHARE]]]></title>
			<link>https://forum.gekko.wizb.it/thread-57089.html</link>
			<pubDate>Thu, 03 May 2018 19:02:50 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57089.html</guid>
			<description><![CDATA[In this Tutorial we will add a dynamic stoploss.<br />
<br />
Stoploss seems to be pretty hard to get right,<br />
because the most approaches would decrease the profit, rather than do good to it.<br />
<br />
First one would think, a price.long-absolut-stoploss would work well, but the reallity shows different:<br />
&gt;&gt;&gt;a smaller stop value does increase the errors and loose more than the stop would benefit..!<br />
<br />
it simply hurts the strategy as TommieHansen stated.<br />
<br />
On the otherside if we set the threshold more loose, then it again does not work too much.<br />
<br />
<br />
The indicators based stoploss are also interesting but theese have problems with the indication speed, <br />
because:<br />
&gt;&gt;&gt;&gt;&gt;the newest candle.data must first fight against the old averages, before it could seriously indicate a fast change.<br />
&gt;&gt;&gt;thats not always true since they would use multiplication to indicate a fast change.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;THUS also create a lot of false triggers due to multiplication (RSI-based)<br />
<br />
so what we do!<br />
<br />
i found a easy way is to create our own stop indicator.<br />
Its very simple design:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.exp = this.price.trades * this.price.dif;</code></div></div>the candle.trades value is intresting.<br />
It seem to indicate the changes pretty faster than enybody else.<br />
But it is a positive number (offcourse!).<br />
For our indicator we wanna have a bipolar output signal, otherwise it would trigger in both trends.<br />
therefore we multiply with the procentage difference between the candles.<br />
<br />
The price.dif is a simple procent calculation for the absolut price:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
this.price.last = 0;<br />
this.price.last = this.price.close; //BACKUP FOR THE NEXT CANDLE</code></div></div><br />
<br />
When goLong we store the candle.close:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.long = this.price.close;</code></div></div><br />
<br />
The stop(trend) logic dos inhibit the RSI trader while in the stop trend.<br />
then a unlock logic will delay the stop trend for not buy to early.<br />
<br />
I also adjusted the RSI trader to get better positive results.<br />
<a href="https://imgur.com/a/hKCXKwd" target="_blank" rel="noopener" class="mycode_url">4 month</a><br />
<a href="https://imgur.com/a/KOFmdI1" target="_blank" rel="noopener" class="mycode_url">1 month</a><br />
<br />
Binance<br />
BTC/Usdt<br />
candlesize 1min<br />
warmup 10min<br />
<br />
For the 4 month period with such a difficult trend, its not bad.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;its only a rsi and a stoploss...&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;<br />
the one month as expected, is a bit less then the bulltrend<br />
<br />
here is the finished  code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #5<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.name = 'trendatron_2';<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.cpuTime();<br />
<br />
    this.indInit();<br />
<br />
    this.setupLog();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
<br />
    this.priceUpdate();<br />
<br />
    this.calculus();<br />
<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
trenda.check = function (candle) {<br />
<br />
    this.stop();<br />
    //lets trade...<br />
    if (this.logic.stopabs !== true &amp;&amp; this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.logic.stopabs !== true &amp;&amp; this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.stop = function () {<br />
    if (this.logic.stopabs !== false) {<br />
        if (this.logic.lock !== false &amp;&amp; this.resultRSI &gt; this.settings.trsRSI.high) {<br />
            this.logic.lock = false;<br />
        }<br />
        if (this.logic.lock !== true &amp;&amp; this.resultRSI &lt; this.settings.trsRSI.low) {<br />
            this.logic.stopabs = false;<br />
            log.debug('-  ' + this.timearr + ' zz---unlock ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
    //SIDECHAIN STOP<br />
    if (this.logic.stopabs !== true &amp;&amp; this.logic.longpos !== false &amp;&amp; this.stopabsset &gt; this.price.abs) {<br />
        if (this.stopabsexpset &gt; this.price.exp) {<br />
            this.logic.stopabs = true;<br />
            this.logic.lock = true;<br />
            this.goShort();<br />
            this.logic.stopcount++;<br />
            log.debug('-  ' + this.timearr + ' xxxxxxxxxxx ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
    if (this.logic.stopabs !== true &amp;&amp; this.logic.longpos !== true &amp;&amp; this.stopabsset &gt; this.price.abs) {<br />
        if (this.stopabsexpset &gt; this.price.exp) {<br />
            this.logic.stopabs = true;<br />
            this.logic.lock = true;<br />
            this.logic.waitcount++;<br />
            log.debug('-  ' + this.timearr + ' yyyyyyyyyy ' + '  wait ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
}<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    this.price.long = this.price.close;<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
trenda.priceUpdate = function () {<br />
    this.price.close = this.candle.close;<br />
    this.price.low = this.candle.low;<br />
    this.price.high = this.candle.high;<br />
    this.price.volume = this.candle.volume;<br />
    this.price.vwp = this.candle.vwp;<br />
    this.price.trades = this.candle.trades;<br />
}<br />
trenda.calculus = function () {<br />
    this.price.abs = ((this.price.long - this.price.close) / this.price.long) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
<br />
    this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
    this.price.last = 0;<br />
    this.price.last = this.price.close;<br />
<br />
    this.price.exp = this.price.trades * this.price.dif;<br />
}<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
            low: 0,//this.candle<br />
            high: 0,//this.candle<br />
            volume: 0,//this.candle<br />
            vwp: 0,//this.candle<br />
            trades: 0,//this.candle<br />
            long: 0,<br />
            last: 0,<br />
            dif: 0,<br />
            exp: 0<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            stopabs: false,<br />
            lock: false,<br />
            globalcount: 0,<br />
            stopcount: 0,<br />
            waitcount: 0<br />
        };<br />
    this.logic = logic;<br />
<br />
    this.stopabsset = this.settings.___stop_abs____.stop_abs;<br />
    this.stopabsexpset = this.settings.___stop_abs____.abs_exp;<br />
}<br />
trenda.cpuTime = function () {<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
trenda.setupLog = function () {<br />
    log.info<br />
        (<br />
<br />
<br />
        '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  ...last longpos = ' + this.logic.longpos + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  .....start backtest ' + this.name + ' varactor' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                     &lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                 &gt;&lt;&lt;&gt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '             &gt;&gt;&lt;&lt;&gt;&gt;       &lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '        &lt;&gt;&gt;&lt;&lt;&gt;    system v3   &gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '    &lt;&lt;&gt;&gt;&lt;&lt;&gt;  start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + ' &gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        ' &gt;&lt;&lt;&gt;&gt;&lt;    ......beginn trading       &lt;&gt;&gt;&lt;&lt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '&gt;&lt;&lt;&gt;&gt;&lt;            ' + this.name + '         &gt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  &gt;&gt;&lt;&lt;&gt;&gt;       susitronix d-sign      &lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '     &gt;&gt;&lt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;            &lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '              &gt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                    &gt;&gt;&gt;&lt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                      &lt;&gt;' + '&#92;n'<br />
        );<br />
}<br />
trenda.end = function () {<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    this.globalcountdif = this.logic.globalcount - this.globalcountbegin;<br />
<br />
    let seconds = ((new Date() - this.startTime) / 1000),<br />
        minutes = seconds / 60,<br />
        str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes / 60) + seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
<br />
    log.info<br />
        (<br />
        '&#92;n' + '&#92;t' + '&#92;t' +<br />
        '.....backtest started with longpos = ' + this.longpos + '&#92;n' + '&#92;t' +<br />
        '.....stop count = ' + this.logic.stopcount + '&#92;n' + '&#92;t' +<br />
        '.....wait count = ' + this.logic.waitcount + '&#92;n' + '&#92;t' +<br />
        '                                                       ' + '&#92;n' + '&#92;t' +<br />
        '                             &lt;&lt;&gt;&gt;                      ' + '&#92;n' + '&#92;t' +<br />
        '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                ' + '&#92;n' + '&#92;t' +<br />
        '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          ' + '&#92;n' + '&#92;t' +<br />
        '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     ' + this.name + '     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + '     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time ' + this.candlemonth + ':' + this.candleday + ':' + this.candlehour + ':' + this.candleminute + ' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      ' + str + ' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = ' + this.cputime.toFixed(4) + ' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; ' + '&#92;n' + '&#92;t' +<br />
        '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; ' + '&#92;n' + '&#92;t' +<br />
        '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; ' + '&#92;n' + '&#92;t'<br />
        );<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
And here the settings .toml<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 30<br />
<br />
[trsRSI]<br />
high = 68<br />
low = 30<br />
<br />
[___stop_abs____]<br />
stop_abs = -1.7<br />
abs_exp = -250</code></div></div><br />
<br />
The actual code for the strat would be fearly small, the rest are just debug tools.<br />
&gt;&gt;&gt;In the following tutorial we will build the hypetrend that can be seen as a complement to the stoploss, function wise.<br />
Also we try to build a macrotrend for the longer trends in the future.<br />
<br />
If you have questions to it, feel free to ask here in this topic because i will read them. hope this helps<br />
or if you need some help with your strategie, no worries fire it up]]></description>
			<content:encoded><![CDATA[In this Tutorial we will add a dynamic stoploss.<br />
<br />
Stoploss seems to be pretty hard to get right,<br />
because the most approaches would decrease the profit, rather than do good to it.<br />
<br />
First one would think, a price.long-absolut-stoploss would work well, but the reallity shows different:<br />
&gt;&gt;&gt;a smaller stop value does increase the errors and loose more than the stop would benefit..!<br />
<br />
it simply hurts the strategy as TommieHansen stated.<br />
<br />
On the otherside if we set the threshold more loose, then it again does not work too much.<br />
<br />
<br />
The indicators based stoploss are also interesting but theese have problems with the indication speed, <br />
because:<br />
&gt;&gt;&gt;&gt;&gt;the newest candle.data must first fight against the old averages, before it could seriously indicate a fast change.<br />
&gt;&gt;&gt;thats not always true since they would use multiplication to indicate a fast change.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;THUS also create a lot of false triggers due to multiplication (RSI-based)<br />
<br />
so what we do!<br />
<br />
i found a easy way is to create our own stop indicator.<br />
Its very simple design:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.exp = this.price.trades * this.price.dif;</code></div></div>the candle.trades value is intresting.<br />
It seem to indicate the changes pretty faster than enybody else.<br />
But it is a positive number (offcourse!).<br />
For our indicator we wanna have a bipolar output signal, otherwise it would trigger in both trends.<br />
therefore we multiply with the procentage difference between the candles.<br />
<br />
The price.dif is a simple procent calculation for the absolut price:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
this.price.last = 0;<br />
this.price.last = this.price.close; //BACKUP FOR THE NEXT CANDLE</code></div></div><br />
<br />
When goLong we store the candle.close:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.price.long = this.price.close;</code></div></div><br />
<br />
The stop(trend) logic dos inhibit the RSI trader while in the stop trend.<br />
then a unlock logic will delay the stop trend for not buy to early.<br />
<br />
I also adjusted the RSI trader to get better positive results.<br />
<a href="https://imgur.com/a/hKCXKwd" target="_blank" rel="noopener" class="mycode_url">4 month</a><br />
<a href="https://imgur.com/a/KOFmdI1" target="_blank" rel="noopener" class="mycode_url">1 month</a><br />
<br />
Binance<br />
BTC/Usdt<br />
candlesize 1min<br />
warmup 10min<br />
<br />
For the 4 month period with such a difficult trend, its not bad.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;its only a rsi and a stoploss...&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;<br />
the one month as expected, is a bit less then the bulltrend<br />
<br />
here is the finished  code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #5<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.name = 'trendatron_2';<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.cpuTime();<br />
<br />
    this.indInit();<br />
<br />
    this.setupLog();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
<br />
    this.priceUpdate();<br />
<br />
    this.calculus();<br />
<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
trenda.check = function (candle) {<br />
<br />
    this.stop();<br />
    //lets trade...<br />
    if (this.logic.stopabs !== true &amp;&amp; this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.logic.stopabs !== true &amp;&amp; this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.stop = function () {<br />
    if (this.logic.stopabs !== false) {<br />
        if (this.logic.lock !== false &amp;&amp; this.resultRSI &gt; this.settings.trsRSI.high) {<br />
            this.logic.lock = false;<br />
        }<br />
        if (this.logic.lock !== true &amp;&amp; this.resultRSI &lt; this.settings.trsRSI.low) {<br />
            this.logic.stopabs = false;<br />
            log.debug('-  ' + this.timearr + ' zz---unlock ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
    //SIDECHAIN STOP<br />
    if (this.logic.stopabs !== true &amp;&amp; this.logic.longpos !== false &amp;&amp; this.stopabsset &gt; this.price.abs) {<br />
        if (this.stopabsexpset &gt; this.price.exp) {<br />
            this.logic.stopabs = true;<br />
            this.logic.lock = true;<br />
            this.goShort();<br />
            this.logic.stopcount++;<br />
            log.debug('-  ' + this.timearr + ' xxxxxxxxxxx ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
    if (this.logic.stopabs !== true &amp;&amp; this.logic.longpos !== true &amp;&amp; this.stopabsset &gt; this.price.abs) {<br />
        if (this.stopabsexpset &gt; this.price.exp) {<br />
            this.logic.stopabs = true;<br />
            this.logic.lock = true;<br />
            this.logic.waitcount++;<br />
            log.debug('-  ' + this.timearr + ' yyyyyyyyyy ' + '  wait ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));<br />
        }<br />
    }<br />
}<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    this.price.long = this.price.close;<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
trenda.priceUpdate = function () {<br />
    this.price.close = this.candle.close;<br />
    this.price.low = this.candle.low;<br />
    this.price.high = this.candle.high;<br />
    this.price.volume = this.candle.volume;<br />
    this.price.vwp = this.candle.vwp;<br />
    this.price.trades = this.candle.trades;<br />
}<br />
trenda.calculus = function () {<br />
    this.price.abs = ((this.price.long - this.price.close) / this.price.long) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
<br />
    this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;&nbsp;&nbsp;&nbsp;&nbsp;//LAST LONG<br />
    this.price.last = 0;<br />
    this.price.last = this.price.close;<br />
<br />
    this.price.exp = this.price.trades * this.price.dif;<br />
}<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
            low: 0,//this.candle<br />
            high: 0,//this.candle<br />
            volume: 0,//this.candle<br />
            vwp: 0,//this.candle<br />
            trades: 0,//this.candle<br />
            long: 0,<br />
            last: 0,<br />
            dif: 0,<br />
            exp: 0<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            stopabs: false,<br />
            lock: false,<br />
            globalcount: 0,<br />
            stopcount: 0,<br />
            waitcount: 0<br />
        };<br />
    this.logic = logic;<br />
<br />
    this.stopabsset = this.settings.___stop_abs____.stop_abs;<br />
    this.stopabsexpset = this.settings.___stop_abs____.abs_exp;<br />
}<br />
trenda.cpuTime = function () {<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
trenda.setupLog = function () {<br />
    log.info<br />
        (<br />
<br />
<br />
        '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  ...last longpos = ' + this.logic.longpos + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  .....start backtest ' + this.name + ' varactor' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                     &lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                 &gt;&lt;&lt;&gt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '             &gt;&gt;&lt;&lt;&gt;&gt;       &lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '        &lt;&gt;&gt;&lt;&lt;&gt;    system v3   &gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '    &lt;&lt;&gt;&gt;&lt;&lt;&gt;  start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + ' &gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        ' &gt;&lt;&lt;&gt;&gt;&lt;    ......beginn trading       &lt;&gt;&gt;&lt;&lt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '&gt;&lt;&lt;&gt;&gt;&lt;            ' + this.name + '         &gt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '  &gt;&gt;&lt;&lt;&gt;&gt;       susitronix d-sign      &lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '     &gt;&gt;&lt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;            &lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '              &gt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                    &gt;&gt;&gt;&lt;&lt;&lt;' + '&#92;n' + '&#92;t' + '&#92;t' + '&#92;t' +<br />
        '                      &lt;&gt;' + '&#92;n'<br />
        );<br />
}<br />
trenda.end = function () {<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    this.globalcountdif = this.logic.globalcount - this.globalcountbegin;<br />
<br />
    let seconds = ((new Date() - this.startTime) / 1000),<br />
        minutes = seconds / 60,<br />
        str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes / 60) + seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
<br />
    log.info<br />
        (<br />
        '&#92;n' + '&#92;t' + '&#92;t' +<br />
        '.....backtest started with longpos = ' + this.longpos + '&#92;n' + '&#92;t' +<br />
        '.....stop count = ' + this.logic.stopcount + '&#92;n' + '&#92;t' +<br />
        '.....wait count = ' + this.logic.waitcount + '&#92;n' + '&#92;t' +<br />
        '                                                       ' + '&#92;n' + '&#92;t' +<br />
        '                             &lt;&lt;&gt;&gt;                      ' + '&#92;n' + '&#92;t' +<br />
        '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                ' + '&#92;n' + '&#92;t' +<br />
        '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          ' + '&#92;n' + '&#92;t' +<br />
        '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     ' + this.name + '     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + '     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time ' + this.candlemonth + ':' + this.candleday + ':' + this.candlehour + ':' + this.candleminute + ' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      ' + str + ' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = ' + this.cputime.toFixed(4) + ' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' + '&#92;n' + '&#92;t' +<br />
        '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; ' + '&#92;n' + '&#92;t' +<br />
        '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; ' + '&#92;n' + '&#92;t' +<br />
        '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; ' + '&#92;n' + '&#92;t'<br />
        );<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
And here the settings .toml<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 30<br />
<br />
[trsRSI]<br />
high = 68<br />
low = 30<br />
<br />
[___stop_abs____]<br />
stop_abs = -1.7<br />
abs_exp = -250</code></div></div><br />
<br />
The actual code for the strat would be fearly small, the rest are just debug tools.<br />
&gt;&gt;&gt;In the following tutorial we will build the hypetrend that can be seen as a complement to the stoploss, function wise.<br />
Also we try to build a macrotrend for the longer trends in the future.<br />
<br />
If you have questions to it, feel free to ask here in this topic because i will read them. hope this helps<br />
or if you need some help with your strategie, no worries fire it up]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Migration to postgreSQL or mongoDB]]></title>
			<link>https://forum.gekko.wizb.it/thread-57088.html</link>
			<pubDate>Thu, 03 May 2018 18:06:48 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57088.html</guid>
			<description><![CDATA[In my opinion, this is not normal, probably everyone who did it for the first time was just as surprised as me "why the f* does not work?"<br />
<br />
Changes should be made in the following files:<br />
<br />
gekko/config/adapters/postgresql.toml:1:postgres://<br />
gekko/config/adapters/mongodb.toml:1:mongodb://<br />
gekko/config/general.toml:4:'sqlite'<br />
gekko/web/vue/UIconfig.js:19:'sqlite'<br />
gekko/web/routes/baseConfig.js:53:postgres://<br />
gekko/web/routes/baseConfig.js:66:mongodb://<br />
gekko/test/test-config.json:112:postgres://<br />
<br />
God bless the grep!]]></description>
			<content:encoded><![CDATA[In my opinion, this is not normal, probably everyone who did it for the first time was just as surprised as me "why the f* does not work?"<br />
<br />
Changes should be made in the following files:<br />
<br />
gekko/config/adapters/postgresql.toml:1:postgres://<br />
gekko/config/adapters/mongodb.toml:1:mongodb://<br />
gekko/config/general.toml:4:'sqlite'<br />
gekko/web/vue/UIconfig.js:19:'sqlite'<br />
gekko/web/routes/baseConfig.js:53:postgres://<br />
gekko/web/routes/baseConfig.js:66:mongodb://<br />
gekko/test/test-config.json:112:postgres://<br />
<br />
God bless the grep!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] STRATEGIE #4 TULIP: MA, MACD, STOCH, RSI [SHARE]]]></title>
			<link>https://forum.gekko.wizb.it/thread-57011.html</link>
			<pubDate>Mon, 30 Apr 2018 03:33:43 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57011.html</guid>
			<description><![CDATA[In this tutorial you can learn how to setup indicators.<br />
<br />
&gt;&gt;&gt;i have randoomly choosen Tulip indicators but it could be eny avilable indicators for gekko.<br />
&gt;&gt;&gt;&gt;&gt;the test results are all in the same uptrend/period and should only show the trigger points.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;WARNING THESE STRATEGIES ARE NOT PROFITABLE ENOUGH OVER TIME.<br />
(((((it needs more than one indicator-if-statement to become a profitable trader)))))<br />
<br />
Some indicators have two or three options (user input averaging length) and more than one output.<br />
In this case, Arrays are used to set the inputs or read the output values.<br />
<br />
First a simple RSI (realtime strength index) with one input/output<br />
////////Test results: <a href="https://imgur.com/a/bRu6hx8" target="_blank" rel="noopener" class="mycode_url">BASSic RSI</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_RSI<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  rsi ' + resultRSI.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  rsi ' + resultRSI.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;tulip_RSI.js //and save<br />
<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28<br />
<br />
#_try_1min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;tulip_RSI.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
The MA (Moving avereage) with two MAs looking for the crossing point.<br />
//////////test results: <a href="https://imgur.com/a/1SIoAZv" target="_blank" rel="noopener" class="mycode_url">BASSic MA</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_MA<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMAfastsettings = this.settings.MA_Fast;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMAslowsettings = this.settings.MA_Slow;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mafast', 'sma', customMAfastsettings);<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('maslow', 'sma', customMAslowsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMAfast = this.tulipIndicators.mafast.result.result;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMAslow = this.tulipIndicators.maslow.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultMAslow &gt; resultMAfast &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  maS ' + resultMAslow.toFixed(2) + '  maF ' + resultMAfast.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultMAslow &lt; resultMAfast &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  maS ' + resultMAslow.toFixed(2) + '  maF ' + resultMAfast.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MA.js<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[MA_Fast]<br />
optInTimePeriod = 50<br />
<br />
[MA_Slow]<br />
optInTimePeriod = 100<br />
<br />
#_try_15min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MA.toml<br />
<br />
It is the same setup as for the RSI, only dual.<br />
<br />
the MACD has more options and outputs, but which ones??<br />
In the gekko folder:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>C:&#92;Users.....&#92;gekko&#92;core</code></div></div>looking for tulind.js<br />
&gt;&gt;&gt;thats all we need for the configuration.<br />
<br />
more information:<br />
<br />
<a href="https://github.com/TulipCharts/tulipnode" target="_blank" rel="noopener" class="mycode_url">tulip bindings for node.js</a><br />
<a href="https://tulipindicators.org/" target="_blank" rel="noopener" class="mycode_url">tulip indicators</a><br />
<br />
//////////test results: <a href="https://imgur.com/a/qiaEaRS" target="_blank" rel="noopener" class="mycode_url">BASSic MACD</a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_MACD<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMACDsettings = this.settings.MACD;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;macd input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mymacd', 'macd', customMACDsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMACD = this.tulipIndicators.mymacd.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultMACD.macd &gt; resultMACD.macdSignal &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  mc ' + resultMACD.macd.toFixed(2) + '  m.sig ' + resultMACD.macdSignal.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultMACD.macd &lt; resultMACD.macdSignal &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  mc ' + resultMACD.macd.toFixed(2) + '  m.sig ' + resultMACD.macdSignal.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MACD.js<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[MACD]<br />
optInFastPeriod = 25<br />
optInSlowPeriod = 50<br />
optInSignalPeriod = 30<br />
<br />
#_try_15min_candles_#<br />
#_Binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MACD.toml<br />
<br />
lets have a look at the tulind.js file (library).<br />
Its long. Use the Find function in your editor:<br />
&gt;&gt;&gt;Ctrl+F<br />
&gt;&gt;&gt;&gt;&gt;type macd and hit enter<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>methods.macd = {<br />
    requires: ['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod'],<br />
    create: (params) =&gt; {<br />
        verifyParams('macd', params);<br />
<br />
        return (data, callback) =&gt; execute(callback, {<br />
            indicator: tulind.indicators.macd,<br />
            inputs: [data.close],<br />
            options: [params.optInFastPeriod, params.optInSlowPeriod, params.optInSignalPeriod],<br />
            results: ['macd', 'macdSignal', 'macdHistogram'],<br />
        });<br />
    }<br />
}</code></div></div>Its a bit hard to understand  but we only need the options.<br />
Above it says "requires".<br />
<br />
As you learnd in my <a href="https://forum.gekko.wizb.it/thread-57009.html" target="_blank" rel="noopener" class="mycode_url">TUT #2</a><br />
&gt;&gt;&gt;&gt;&gt;the squared bracket designate  ARRAYs (number-chains).<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod']</code></div></div><br />
and the outputs:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>['macd', 'macdSignal', 'macdHistogram']</code></div></div><br />
In the options array, are objects that have a name and a value associated to it.<br />
If we map the user.settings we can use the array name. thats the quick n dirty way:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var customMACDsettings = this.settings.MACD;</code></div></div> <br />
now we move the whole array into the indicator:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.addTulipIndicator('mymacd', 'macd', customMACDsettings);</code></div></div>the order would be the same as we set it up in the setttings.<br />
<br />
For the results we would use the right object:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>resultMACD.macd<br />
resultMACD.macdSignal<br />
resultMACD.macdHistogram</code></div></div><br />
&gt;&gt;&gt;Remember if you want to use it globally, you must first make a global object out of it. <a href="https://forum.gekko.wizb.it/thread-56936.html" target="_blank" rel="noopener" class="mycode_url">TUT #1</a><br />
<br />
<br />
The Stoch oscillator has also multiple options/outputs.<br />
//////////test results: <a href="https://imgur.com/a/sAQuIdO" target="_blank" rel="noopener" class="mycode_url">BASSic STOCH</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_STOCH<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customSTOCHsettings = this.settings.STOCH;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mystoch', 'stoch', customSTOCHsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultSTOCH = this.tulipIndicators.mystoch.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultSTOCH.stochD &gt; this.settings.trsSTOCH.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  stochD ' + resultSTOCH.stochD.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultSTOCH.stochD &lt; this.settings.trsSTOCH.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  stochD ' + resultSTOCH.stochD.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_STOCH.js<br />
<br />
[url=https://forum.gekko.wizb.it/thread-57009.html][/url]<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[STOCH]<br />
optInFastKPeriod = 30<br />
optInSlowKPeriod = 4<br />
optInSlowDPeriod = 4<br />
<br />
[trsSTOCH]<br />
high = 80<br />
low = 20<br />
<br />
#_try_8min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_STOCH.toml<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>methods.stoch = {<br />
    requires: ['optInFastKPeriod', 'optInSlowKPeriod', 'optInSlowDPeriod'],<br />
    create: (params) =&gt; {<br />
        verifyParams('stoch', params);<br />
<br />
        return (data, callback) =&gt; execute(callback, {<br />
            indicator: tulind.indicators.stoch,<br />
            inputs: [data.high, data.low, data.close],<br />
            options: [params.optInFastKPeriod, params.optInSlowKPeriod, params.optInSlowDPeriod],<br />
            results: ['stochK', 'stochD'],<br />
        });<br />
    }<br />
}</code></div></div>The options and outputs are a bit different.<br />
I have tryed other indicators but the test results were aweful<br />
&gt;&gt;&gt; THUS THIS BASSic TULIP STRATs, AS THEY ARE, WOULD BE USED FOR SHORTTERM TRADING<br />
&gt;&gt;&gt;&gt;&gt;OTHER INDICATORS COULD BE USEFULL FOR LONGTERM TREND INDICATION. let me know...<br />
___________________________________________________________________________<br />
<br />
In the previous TUTs, we have created utilities for a preset strat.<br />
here we learnd how to setup indicators.<br />
<br />
In the next TUTs we will beginn to build our strat.]]></description>
			<content:encoded><![CDATA[In this tutorial you can learn how to setup indicators.<br />
<br />
&gt;&gt;&gt;i have randoomly choosen Tulip indicators but it could be eny avilable indicators for gekko.<br />
&gt;&gt;&gt;&gt;&gt;the test results are all in the same uptrend/period and should only show the trigger points.<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;WARNING THESE STRATEGIES ARE NOT PROFITABLE ENOUGH OVER TIME.<br />
(((((it needs more than one indicator-if-statement to become a profitable trader)))))<br />
<br />
Some indicators have two or three options (user input averaging length) and more than one output.<br />
In this case, Arrays are used to set the inputs or read the output values.<br />
<br />
First a simple RSI (realtime strength index) with one input/output<br />
////////Test results: <a href="https://imgur.com/a/bRu6hx8" target="_blank" rel="noopener" class="mycode_url">BASSic RSI</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_RSI<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  rsi ' + resultRSI.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  rsi ' + resultRSI.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;tulip_RSI.js //and save<br />
<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28<br />
<br />
#_try_1min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;tulip_RSI.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
The MA (Moving avereage) with two MAs looking for the crossing point.<br />
//////////test results: <a href="https://imgur.com/a/1SIoAZv" target="_blank" rel="noopener" class="mycode_url">BASSic MA</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_MA<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMAfastsettings = this.settings.MA_Fast;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMAslowsettings = this.settings.MA_Slow;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mafast', 'sma', customMAfastsettings);<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('maslow', 'sma', customMAslowsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMAfast = this.tulipIndicators.mafast.result.result;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMAslow = this.tulipIndicators.maslow.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultMAslow &gt; resultMAfast &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  maS ' + resultMAslow.toFixed(2) + '  maF ' + resultMAfast.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultMAslow &lt; resultMAfast &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  maS ' + resultMAslow.toFixed(2) + '  maF ' + resultMAfast.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MA.js<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[MA_Fast]<br />
optInTimePeriod = 50<br />
<br />
[MA_Slow]<br />
optInTimePeriod = 100<br />
<br />
#_try_15min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MA.toml<br />
<br />
It is the same setup as for the RSI, only dual.<br />
<br />
the MACD has more options and outputs, but which ones??<br />
In the gekko folder:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>C:&#92;Users.....&#92;gekko&#92;core</code></div></div>looking for tulind.js<br />
&gt;&gt;&gt;thats all we need for the configuration.<br />
<br />
more information:<br />
<br />
<a href="https://github.com/TulipCharts/tulipnode" target="_blank" rel="noopener" class="mycode_url">tulip bindings for node.js</a><br />
<a href="https://tulipindicators.org/" target="_blank" rel="noopener" class="mycode_url">tulip indicators</a><br />
<br />
//////////test results: <a href="https://imgur.com/a/qiaEaRS" target="_blank" rel="noopener" class="mycode_url">BASSic MACD</a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_MACD<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customMACDsettings = this.settings.MACD;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;macd input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mymacd', 'macd', customMACDsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultMACD = this.tulipIndicators.mymacd.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultMACD.macd &gt; resultMACD.macdSignal &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  mc ' + resultMACD.macd.toFixed(2) + '  m.sig ' + resultMACD.macdSignal.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultMACD.macd &lt; resultMACD.macdSignal &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  mc ' + resultMACD.macd.toFixed(2) + '  m.sig ' + resultMACD.macdSignal.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MACD.js<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[MACD]<br />
optInFastPeriod = 25<br />
optInSlowPeriod = 50<br />
optInSignalPeriod = 30<br />
<br />
#_try_15min_candles_#<br />
#_Binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_MACD.toml<br />
<br />
lets have a look at the tulind.js file (library).<br />
Its long. Use the Find function in your editor:<br />
&gt;&gt;&gt;Ctrl+F<br />
&gt;&gt;&gt;&gt;&gt;type macd and hit enter<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>methods.macd = {<br />
    requires: ['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod'],<br />
    create: (params) =&gt; {<br />
        verifyParams('macd', params);<br />
<br />
        return (data, callback) =&gt; execute(callback, {<br />
            indicator: tulind.indicators.macd,<br />
            inputs: [data.close],<br />
            options: [params.optInFastPeriod, params.optInSlowPeriod, params.optInSignalPeriod],<br />
            results: ['macd', 'macdSignal', 'macdHistogram'],<br />
        });<br />
    }<br />
}</code></div></div>Its a bit hard to understand  but we only need the options.<br />
Above it says "requires".<br />
<br />
As you learnd in my <a href="https://forum.gekko.wizb.it/thread-57009.html" target="_blank" rel="noopener" class="mycode_url">TUT #2</a><br />
&gt;&gt;&gt;&gt;&gt;the squared bracket designate  ARRAYs (number-chains).<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>['optInFastPeriod', 'optInSlowPeriod', 'optInSignalPeriod']</code></div></div><br />
and the outputs:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>['macd', 'macdSignal', 'macdHistogram']</code></div></div><br />
In the options array, are objects that have a name and a value associated to it.<br />
If we map the user.settings we can use the array name. thats the quick n dirty way:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var customMACDsettings = this.settings.MACD;</code></div></div> <br />
now we move the whole array into the indicator:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.addTulipIndicator('mymacd', 'macd', customMACDsettings);</code></div></div>the order would be the same as we set it up in the setttings.<br />
<br />
For the results we would use the right object:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>resultMACD.macd<br />
resultMACD.macdSignal<br />
resultMACD.macdHistogram</code></div></div><br />
&gt;&gt;&gt;Remember if you want to use it globally, you must first make a global object out of it. <a href="https://forum.gekko.wizb.it/thread-56936.html" target="_blank" rel="noopener" class="mycode_url">TUT #1</a><br />
<br />
<br />
The Stoch oscillator has also multiple options/outputs.<br />
//////////test results: <a href="https://imgur.com/a/sAQuIdO" target="_blank" rel="noopener" class="mycode_url">BASSic STOCH</a><br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
BASSic tulip_STOCH<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var strat = {};<br />
<br />
strat.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longpos: false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customSTOCHsettings = this.settings.STOCH;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('mystoch', 'stoch', customSTOCHsettings);<br />
}<br />
<br />
strat.update = function (candle) {<br />
<br />
}<br />
<br />
strat.log = function () {<br />
<br />
}<br />
<br />
strat.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultSTOCH = this.tulipIndicators.mystoch.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultSTOCH.stochD &gt; this.settings.trsSTOCH.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price ' + this.price.close + '  stochD ' + resultSTOCH.stochD.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultSTOCH.stochD &lt; this.settings.trsSTOCH.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price ' + this.price.close + '  stochD ' + resultSTOCH.stochD.toFixed(2));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = strat;</code></div></div>&gt;&gt;&gt;&gt;save as tulip_STOCH.js<br />
<br />
[url=https://forum.gekko.wizb.it/thread-57009.html][/url]<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[STOCH]<br />
optInFastKPeriod = 30<br />
optInSlowKPeriod = 4<br />
optInSlowDPeriod = 4<br />
<br />
[trsSTOCH]<br />
high = 80<br />
low = 20<br />
<br />
#_try_8min_candles_#<br />
#_binance_BTC_USDT_#</code></div></div>&gt;&gt;&gt;&gt;save as tulip_STOCH.toml<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>methods.stoch = {<br />
    requires: ['optInFastKPeriod', 'optInSlowKPeriod', 'optInSlowDPeriod'],<br />
    create: (params) =&gt; {<br />
        verifyParams('stoch', params);<br />
<br />
        return (data, callback) =&gt; execute(callback, {<br />
            indicator: tulind.indicators.stoch,<br />
            inputs: [data.high, data.low, data.close],<br />
            options: [params.optInFastKPeriod, params.optInSlowKPeriod, params.optInSlowDPeriod],<br />
            results: ['stochK', 'stochD'],<br />
        });<br />
    }<br />
}</code></div></div>The options and outputs are a bit different.<br />
I have tryed other indicators but the test results were aweful<br />
&gt;&gt;&gt; THUS THIS BASSic TULIP STRATs, AS THEY ARE, WOULD BE USED FOR SHORTTERM TRADING<br />
&gt;&gt;&gt;&gt;&gt;OTHER INDICATORS COULD BE USEFULL FOR LONGTERM TREND INDICATION. let me know...<br />
___________________________________________________________________________<br />
<br />
In the previous TUTs, we have created utilities for a preset strat.<br />
here we learnd how to setup indicators.<br />
<br />
In the next TUTs we will beginn to build our strat.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] STRATEGIE #3 CPU TIME MESSUREMENT  [SHARE]]]></title>
			<link>https://forum.gekko.wizb.it/thread-57010.html</link>
			<pubDate>Mon, 30 Apr 2018 00:50:24 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57010.html</guid>
			<description><![CDATA[When developing a strategie it may be useful to look at the cpu-time needed for calculating one candle.<br />
This would indicate a abnormal increase in processing time, if the newer code would be faulty. (looopsy-dooo)<br />
<br />
thanks to THOMMIE HANSEN<br />
<br />
We can use the built in date function to messure the total backtest time.<br />
cpu time = backtest time total / ammount of candles<br />
<br />
in the init we capture the start time<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.cpuTime = function()<br />
{<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
}</code></div></div><br />
then we can use the [end] function to calculate and display the value after the backtest period is finished.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.end = function()<br />
{<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    let seconds = ((new Date()- this.startTime)/1000),<br />
    minutes = seconds/60,<br />
    str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes/60)+seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
    <br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '.....backtest started with longpos = '+ this.longpos                                   +'&#92;n'+'&#92;t'+<br />
    '                                                       '                               +'&#92;n'+'&#92;t'+<br />
    '                             &lt;&lt;&gt;&gt;                      '                               +'&#92;n'+'&#92;t'+<br />
    '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                '                               +'&#92;n'+'&#92;t'+<br />
    '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          '                               +'&#92;n'+'&#92;t'+<br />
    '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     '+ this.name +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                               +'&#92;n'+'&#92;t'+<br />
    '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time '+ this.candlemonth +':'+this.candleday +':'+ this.candlehour +':'+ this.candleminute +' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      '+ str +' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = '+ this.cputime.toFixed(4) +' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; '                             +'&#92;n'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; '                           +'&#92;n'+'&#92;t'+<br />
    '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; '                       +'&#92;n'+'&#92;t'<br />
    );<br />
}</code></div></div><br />
whats all this...<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>+'&#92;n'+'&#92;t'+</code></div></div>...stuff is all about..?<br />
<br />
for debug lines we can use the newline or insert-tab comand.<br />
The cli window has a restricted width to display.<br />
In this way i get rid of the date header for having enough space for debug statistics.<br />
Here i choose the seperat days/minutes/hours debug line for having a colon inbetween instead of coma.<br />
<br />
Since this looks somewhat familiar why not drop the intro header and put it all together:<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.name = 'trendatron_2'; //enter the strat name here<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.cpuTime();<br />
<br />
    this.indInit();<br />
<br />
    this.setupLog();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
    this.price.close = this.candle.close;<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
<br />
    //lets trade...<br />
    if (this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.cpuTime = function()<br />
{<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
<br />
    <br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
trenda.setupLog = function()<br />
{<br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  ...last longpos = '+ this.logic.longpos          +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  .....start backtest '+ this.name +' varactor'    +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                     &lt;&lt;&gt;&gt;'                         +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                 &gt;&lt;&lt;&gt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                      +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '             &gt;&gt;&lt;&lt;&gt;&gt;       &lt;&lt;&gt;&gt;&lt;&lt;'                  +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '        &lt;&gt;&gt;&lt;&lt;&gt;    system v3   &gt;&gt;&lt;&lt;&gt;&gt;'              +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&lt;&gt;  start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +' &gt;&gt;&lt;&lt;&gt;&gt;'   +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    ' &gt;&lt;&lt;&gt;&gt;&lt;    ......beginn trading       &lt;&gt;&gt;&lt;&lt;&gt;'      +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '&gt;&lt;&lt;&gt;&gt;&lt;            '+ this.name +'         &gt;&lt;&gt;&gt;&lt;&lt;'+'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  &gt;&gt;&lt;&lt;&gt;&gt;       susitronix d-sign      &lt;&lt;&gt;&gt;&lt;&lt;'       +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '     &gt;&gt;&lt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;            &lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;'          +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '              &gt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;'                  +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                    &gt;&gt;&gt;&lt;&lt;&lt;'                        +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                      &lt;&gt;'                          +'&#92;n'<br />
    );<br />
}<br />
trenda.end = function()<br />
{<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    this.globalcountdif = this.logic.globalcount - this.globalcountbegin;<br />
<br />
    let seconds = ((new Date()- this.startTime)/1000),<br />
    minutes = seconds/60,<br />
    str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes/60)+seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
    <br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+<br />
    '.....backtest started with longpos = '+ this.longpos                                   +'&#92;n'+'&#92;t'+<br />
    '                                                       '                               +'&#92;n'+'&#92;t'+<br />
    '                             &lt;&lt;&gt;&gt;                      '                               +'&#92;n'+'&#92;t'+<br />
    '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                '                               +'&#92;n'+'&#92;t'+<br />
    '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          '                               +'&#92;n'+'&#92;t'+<br />
    '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     '+ this.name +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                               +'&#92;n'+'&#92;t'+<br />
    '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time '+ this.candlemonth +':'+this.candleday +':'+ this.candlehour +':'+ this.candleminute +' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      '+ str +' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = '+ this.cputime.toFixed(4) +' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; '                             +'&#92;n'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; '                           +'&#92;n'+'&#92;t'+<br />
    '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; '                       +'&#92;n'+'&#92;t'<br />
    );<br />
}<br />
<br />
module.exports = trenda;</code></div></div>This is the final strat. copy/paste and run with gekko backtest.<br />
<br />
now i have my own preset waiting for...<br />
i know this was boring sorry.<br />
therefore:<br />
in the next tutorial we will design some more intresting stuff:<br />
&gt;&gt;&gt;basic tulip indicators as modular blocks<br />
-MA<br />
-MACD<br />
-Stoch osc<br />
...(RSI)]]></description>
			<content:encoded><![CDATA[When developing a strategie it may be useful to look at the cpu-time needed for calculating one candle.<br />
This would indicate a abnormal increase in processing time, if the newer code would be faulty. (looopsy-dooo)<br />
<br />
thanks to THOMMIE HANSEN<br />
<br />
We can use the built in date function to messure the total backtest time.<br />
cpu time = backtest time total / ammount of candles<br />
<br />
in the init we capture the start time<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.cpuTime = function()<br />
{<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
}</code></div></div><br />
then we can use the [end] function to calculate and display the value after the backtest period is finished.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.end = function()<br />
{<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    let seconds = ((new Date()- this.startTime)/1000),<br />
    minutes = seconds/60,<br />
    str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes/60)+seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
    <br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '.....backtest started with longpos = '+ this.longpos                                   +'&#92;n'+'&#92;t'+<br />
    '                                                       '                               +'&#92;n'+'&#92;t'+<br />
    '                             &lt;&lt;&gt;&gt;                      '                               +'&#92;n'+'&#92;t'+<br />
    '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                '                               +'&#92;n'+'&#92;t'+<br />
    '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          '                               +'&#92;n'+'&#92;t'+<br />
    '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     '+ this.name +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                               +'&#92;n'+'&#92;t'+<br />
    '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time '+ this.candlemonth +':'+this.candleday +':'+ this.candlehour +':'+ this.candleminute +' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      '+ str +' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = '+ this.cputime.toFixed(4) +' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; '                             +'&#92;n'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; '                           +'&#92;n'+'&#92;t'+<br />
    '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; '                       +'&#92;n'+'&#92;t'<br />
    );<br />
}</code></div></div><br />
whats all this...<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>+'&#92;n'+'&#92;t'+</code></div></div>...stuff is all about..?<br />
<br />
for debug lines we can use the newline or insert-tab comand.<br />
The cli window has a restricted width to display.<br />
In this way i get rid of the date header for having enough space for debug statistics.<br />
Here i choose the seperat days/minutes/hours debug line for having a colon inbetween instead of coma.<br />
<br />
Since this looks somewhat familiar why not drop the intro header and put it all together:<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.name = 'trendatron_2'; //enter the strat name here<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.cpuTime();<br />
<br />
    this.indInit();<br />
<br />
    this.setupLog();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
    this.price.close = this.candle.close;<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
<br />
    //lets trade...<br />
    if (this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.cpuTime = function()<br />
{<br />
    //CPU TIME SET<br />
    this.startTime = new Date();<br />
<br />
    <br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
trenda.setupLog = function()<br />
{<br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  ...last longpos = '+ this.logic.longpos          +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  .....start backtest '+ this.name +' varactor'    +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                     &lt;&lt;&gt;&gt;'                         +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                 &gt;&lt;&lt;&gt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                      +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '             &gt;&gt;&lt;&lt;&gt;&gt;       &lt;&lt;&gt;&gt;&lt;&lt;'                  +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '        &lt;&gt;&gt;&lt;&lt;&gt;    system v3   &gt;&gt;&lt;&lt;&gt;&gt;'              +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&lt;&gt;  start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +' &gt;&gt;&lt;&lt;&gt;&gt;'   +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    ' &gt;&lt;&lt;&gt;&gt;&lt;    ......beginn trading       &lt;&gt;&gt;&lt;&lt;&gt;'      +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '&gt;&lt;&lt;&gt;&gt;&lt;            '+ this.name +'         &gt;&lt;&gt;&gt;&lt;&lt;'+'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '  &gt;&gt;&lt;&lt;&gt;&gt;       susitronix d-sign      &lt;&lt;&gt;&gt;&lt;&lt;'       +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '     &gt;&gt;&lt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;            &lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;'          +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '              &gt;&lt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&gt;&gt;'                  +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                    &gt;&gt;&gt;&lt;&lt;&lt;'                        +'&#92;n'+'&#92;t'+'&#92;t'+'&#92;t'+<br />
    '                      &lt;&gt;'                          +'&#92;n'<br />
    );<br />
}<br />
trenda.end = function()<br />
{<br />
    this.logic.globalcount;<br />
    this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;<br />
    this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;<br />
    this.hoursdif = (this.logic.globalcount / 60) % 24;<br />
    this.minutesdif = this.logic.globalcount % 60;<br />
<br />
    this.globalcountdif = this.logic.globalcount - this.globalcountbegin;<br />
<br />
    let seconds = ((new Date()- this.startTime)/1000),<br />
    minutes = seconds/60,<br />
    str;<br />
    //CPU TIME CALCULUS IN MILLISECONDS<br />
    this.totaltime = ((minutes/60)+seconds);<br />
    this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);<br />
<br />
    minutes &lt; 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';<br />
    <br />
    log.info<br />
    (<br />
    '&#92;n'+'&#92;t'+'&#92;t'+<br />
    '.....backtest started with longpos = '+ this.longpos                                   +'&#92;n'+'&#92;t'+<br />
    '                                                       '                               +'&#92;n'+'&#92;t'+<br />
    '                             &lt;&lt;&gt;&gt;                      '                               +'&#92;n'+'&#92;t'+<br />
    '                       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                '                               +'&#92;n'+'&#92;t'+<br />
    '                 &gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;          '                               +'&#92;n'+'&#92;t'+<br />
    '            &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;     '+ this.name +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'                               +'&#92;n'+'&#92;t'+<br />
    '        &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    start date '+ this.month +':'+ this.day +':'+ this.hour+':'+ this.minute +'     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         end time '+ this.candlemonth +':'+this.candleday +':'+ this.candlehour +':'+ this.candleminute +' finish     &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;' +'&#92;n'+'&#92;t'+<br />
    ' &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;      '+ str +' / candles = ' + this.logic.globalcount + '       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '   &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;    candle cpu time = '+ this.cputime.toFixed(4) +' mSec       &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;'    +'&#92;n'+'&#92;t'+<br />
    '      &gt;&gt;&lt;&lt; &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt; &lt;&lt;&gt;&gt; '                             +'&#92;n'+'&#92;t'+<br />
    '    &lt;&lt;&gt;&gt;&lt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;         &lt;&lt;&gt;&gt;&lt;&lt; '                           +'&#92;n'+'&#92;t'+<br />
    '&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;                &lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;                &gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&gt;&lt; '                       +'&#92;n'+'&#92;t'<br />
    );<br />
}<br />
<br />
module.exports = trenda;</code></div></div>This is the final strat. copy/paste and run with gekko backtest.<br />
<br />
now i have my own preset waiting for...<br />
i know this was boring sorry.<br />
therefore:<br />
in the next tutorial we will design some more intresting stuff:<br />
&gt;&gt;&gt;basic tulip indicators as modular blocks<br />
-MA<br />
-MACD<br />
-Stoch osc<br />
...(RSI)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] STRATEGIE #2 TIME CURSOR  [SHARE]]]></title>
			<link>https://forum.gekko.wizb.it/thread-57009.html</link>
			<pubDate>Sun, 29 Apr 2018 23:05:42 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-57009.html</guid>
			<description><![CDATA[In the following tutorial you can learn how to:<br />
<br />
-build a useful timecursor for our debug purposes<br />
&gt;&gt;&gt; use a Array<br />
&gt;&gt;&gt;&gt;&gt; use a for loop<br />
<br />
&gt;&gt;&gt;ONLY START THE SIMULATION WHEN I ASK YOU TO (incomplete snippets wont work)<br />
<br />
IF YOU ARE NEW TO GEKKO AND JAVA SCRIPT, PLEASE LOOKING FOR [TUT] #1<br />
<a href="https://forum.gekko.wizb.it/thread-56936.html" target="_blank" rel="noopener" class="mycode_url">BASSic TULIP RSI</a><br />
<br />
The timecursor, can be added to eny debug line.<br />
First in the settings we set the Start date, of the Backtest period.<br />
Then the time cursor will calculate the same date/time as we looking at in the gekko --ui Test result waveform window.<br />
...the time reference to eny event...<br />
<br />
For solving the month/day problem we use our first Array where we simply preset the monthdays, for each month, into it.<br />
<br />
The simple way for the time reference would be, the build-in date function, but i found that it will have lots of decimal places.<br />
To go around we could use the function:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>myValue.toFixed(0)</code></div></div><br />
<br />
this will loose all the decimal places BUT!!! it crates a rounding with error included and becomes useless.<br />
<br />
i designed my own whole number counter that works pretty spot-on.<br />
<br />
Version3 uses the settings:<br />
candle_size //(minutes!) this sets a [for loop], to update the right minutes-ammount if the candle_size is bigger than 1 minute.<br />
&gt;&gt;&gt; therefore we design our first [for loop].<br />
<br />
Here is the code from the last TUT with a little tuning of the RSI:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #0<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //add debug line and display the rsi value<br />
    //log.debug('RSI result = ' + resultRSI);<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.logic.longpos = false;<br />
        this.advice('short');<br />
        log.debug('goShort price.close = ' + this.price.close);<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.logic.longpos = true;<br />
        this.advice('long');<br />
        log.debug('goLong price.close = ' + this.price.close);<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div>use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
 &gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_1.js //and save<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
The settings.toml code:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28</code></div></div>use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
 &gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_1.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
Now we implement the timecurser step by step as i would write the code.<br />
First write settings.toml<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28</code></div></div>we also use the logic.longpos to tell gekko if we start trading with currency or asset.<br />
that way we dont need to edit the code for using basic functions like this.<br />
<br />
Now i have nice names in the settings but for writing code i use different names.<br />
instead of just initializing the settings in the [INIT] we create a mapping:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.init = function () {<br />
    <br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: this.longpos<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}</code></div></div>we have also initialized two arrays:<br />
this.montharr //here we set the values for each month directly. This will also set the length to 12<br />
this.timearr //here we only init a empty array since we dont know/have the content yet.<br />
<br />
&gt;&gt;&gt;WE CAN CHECK A ARRAY LENGTH IN THE DEBUG LINE:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>log.debug('Array length ' + this.myArray.length);</code></div></div><br />
add the main code to the update function, that will execute before we can use it:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.update = function (candle) {<br />
    <br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}</code></div></div><br />
Now we setup the main counter in the [INIT] that will count the candles for the backtest period.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0 //candle counter<br />
        };<br />
    this.logic = logic;</code></div></div><br />
<br />
<br />
The final code with the debug lines using the time array:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #0<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.logic.longpos = false;<br />
        this.advice('short');<br />
        log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.logic.longpos = true;<br />
        this.advice('long');<br />
        log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;save this code as: trendatron_1.js<br />
&gt;&gt;&gt;&gt;&gt;save also the latest settings.toml from above, as trendatron_1.toml (File type "all files")<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;run the code<br />
<br />
<br />
The code works but looks alllready stuffed with nothing in there yet.<br />
&gt;&gt;&gt;&gt;&gt;We create subroutines/functions that can be called from every where:<br />
(this makes sense for functions that are called more than once, or that are only to be initialized, like the timecursor (set and forget)).<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.indInit();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //add debug line and display the rsi value<br />
    //log.debug('RSI result = ' + resultRSI);<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
<br />
<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
looks better but lets use the [update] as its ment to, and the [check] for the final strategic statements:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.indInit();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
    this.price.close = this.candle.close;<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
<br />
    //lets trade...<br />
    if (this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
much better ;-)<br />
its now modular to comment/uncomment functions, besides it has become somewhat structurized.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>//this.timeCursor();</code></div></div>now the whole function is switched off<br />
<br />
<br />
thats it for the timecursor and subcircuits.<br />
in the next short tutorial a simple cpu-prozessing-time messurement tool and debug functions are the topic.]]></description>
			<content:encoded><![CDATA[In the following tutorial you can learn how to:<br />
<br />
-build a useful timecursor for our debug purposes<br />
&gt;&gt;&gt; use a Array<br />
&gt;&gt;&gt;&gt;&gt; use a for loop<br />
<br />
&gt;&gt;&gt;ONLY START THE SIMULATION WHEN I ASK YOU TO (incomplete snippets wont work)<br />
<br />
IF YOU ARE NEW TO GEKKO AND JAVA SCRIPT, PLEASE LOOKING FOR [TUT] #1<br />
<a href="https://forum.gekko.wizb.it/thread-56936.html" target="_blank" rel="noopener" class="mycode_url">BASSic TULIP RSI</a><br />
<br />
The timecursor, can be added to eny debug line.<br />
First in the settings we set the Start date, of the Backtest period.<br />
Then the time cursor will calculate the same date/time as we looking at in the gekko --ui Test result waveform window.<br />
...the time reference to eny event...<br />
<br />
For solving the month/day problem we use our first Array where we simply preset the monthdays, for each month, into it.<br />
<br />
The simple way for the time reference would be, the build-in date function, but i found that it will have lots of decimal places.<br />
To go around we could use the function:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>myValue.toFixed(0)</code></div></div><br />
<br />
this will loose all the decimal places BUT!!! it crates a rounding with error included and becomes useless.<br />
<br />
i designed my own whole number counter that works pretty spot-on.<br />
<br />
Version3 uses the settings:<br />
candle_size //(minutes!) this sets a [for loop], to update the right minutes-ammount if the candle_size is bigger than 1 minute.<br />
&gt;&gt;&gt; therefore we design our first [for loop].<br />
<br />
Here is the code from the last TUT with a little tuning of the RSI:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #0<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //add debug line and display the rsi value<br />
    //log.debug('RSI result = ' + resultRSI);<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.logic.longpos = false;<br />
        this.advice('short');<br />
        log.debug('goShort price.close = ' + this.price.close);<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.logic.longpos = true;<br />
        this.advice('long');<br />
        log.debug('goLong price.close = ' + this.price.close);<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div>use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
 &gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_1.js //and save<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
The settings.toml code:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28</code></div></div>use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
 &gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_1.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
Now we implement the timecurser step by step as i would write the code.<br />
First write settings.toml<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[___trendatron___]<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;#<br />
__longPos = false<br />
<br />
#&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;#<br />
[_backtest_start_]<br />
__________day = 1<br />
______month = 4<br />
_____hour = 18<br />
_minute = 38<br />
candle_size = 1<br />
#&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;#<br />
<br />
[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 71<br />
low = 28</code></div></div>we also use the logic.longpos to tell gekko if we start trading with currency or asset.<br />
that way we dont need to edit the code for using basic functions like this.<br />
<br />
Now i have nice names in the settings but for writing code i use different names.<br />
instead of just initializing the settings in the [INIT] we create a mapping:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.init = function () {<br />
    <br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: this.longpos<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}</code></div></div>we have also initialized two arrays:<br />
this.montharr //here we set the values for each month directly. This will also set the length to 12<br />
this.timearr //here we only init a empty array since we dont know/have the content yet.<br />
<br />
&gt;&gt;&gt;WE CAN CHECK A ARRAY LENGTH IN THE DEBUG LINE:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>log.debug('Array length ' + this.myArray.length);</code></div></div><br />
add the main code to the update function, that will execute before we can use it:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>trenda.update = function (candle) {<br />
    <br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}</code></div></div><br />
Now we setup the main counter in the [INIT] that will count the candles for the backtest period.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0 //candle counter<br />
        };<br />
    this.logic = logic;</code></div></div><br />
<br />
<br />
The final code with the debug lines using the time array:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #0<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
<br />
    //first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.logic.longpos = false;<br />
        this.advice('short');<br />
        log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.logic.longpos = true;<br />
        this.advice('long');<br />
        log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;save this code as: trendatron_1.js<br />
&gt;&gt;&gt;&gt;&gt;save also the latest settings.toml from above, as trendatron_1.toml (File type "all files")<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;run the code<br />
<br />
<br />
The code works but looks alllready stuffed with nothing in there yet.<br />
&gt;&gt;&gt;&gt;&gt;We create subroutines/functions that can be called from every where:<br />
(this makes sense for functions that are called more than once, or that are only to be initialized, like the timecursor (set and forget)).<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.indInit();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
    //update price.close<br />
    this.price.close = this.candle.close;<br />
<br />
    //update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
    //add debug line and display the rsi value<br />
    //log.debug('RSI result = ' + resultRSI);<br />
<br />
    //lets trade...<br />
    if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
<br />
<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,//this.candle<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
looks better but lets use the [update] as its ment to, and the [check] for the final strategic statements:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial:     trendatron #2<br />
            rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
<br />
trenda.init = function () {<br />
<br />
    this.allInit();<br />
<br />
    this.userMap();<br />
<br />
    this.indInit();<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
    this.timeCursor();<br />
    this.price.close = this.candle.close;<br />
    this.resultRSI = this.tulipIndicators.myrsi.result.result;<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
<br />
    //lets trade...<br />
    if (this.resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
        this.goShort();<br />
    }<br />
    else if (this.resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
        this.goLong();<br />
    }<br />
}<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
//&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;<br />
//&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;&lt;<br />
trenda.goShort = function () {<br />
    this.logic.longpos = false;<br />
    this.advice('short');<br />
    log.debug('&gt;&gt;&gt; ' + this.timearr + ' Short price.close = ' + this.price.close);<br />
}<br />
trenda.goLong = function () {<br />
    this.logic.longpos = true;<br />
    this.advice('long');<br />
    log.debug(' &lt;&lt;&lt;' + this.timearr + ' Long price.close = ' + this.price.close);<br />
}<br />
<br />
<br />
trenda.indInit = function () {<br />
    // define the indicators we need     //move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);<br />
}<br />
<br />
trenda.allInit = function () {<br />
<br />
    //first fetch settings from .toml<br />
    this.customRSIsettings = this.settings.RSI;<br />
<br />
    //add candle.close<br />
    price =<br />
        {<br />
            close: 0,<br />
        };<br />
    this.price = price;<br />
<br />
    logic =<br />
        {<br />
            longpos: false,<br />
            globalcount: 0<br />
        };<br />
    this.logic = logic;<br />
}<br />
trenda.userMap = function () {<br />
<br />
    this.longpos = this.settings.___trendatron___.__longPos;<br />
    month = this.settings._backtest_start_.______month;<br />
    day = this.settings._backtest_start_.__________day;<br />
    hour = this.settings._backtest_start_._____hour;<br />
    minute = this.settings._backtest_start_._minute;<br />
<br />
    this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];<br />
    this.month = month;<br />
    this.day = day;<br />
    this.hour = hour;<br />
    this.minute = minute;<br />
    this.timearr = [];<br />
    this.candlesize = this.settings._backtest_start_.candle_size;<br />
}<br />
trenda.timeCursor = function () {<br />
    if (this.logic.globalcount == 0) {<br />
        this.mcount = this.minute;<br />
        this.hcount = this.hour;<br />
        this.dcount = this.day;<br />
        this.moncount = this.month;<br />
    }<br />
<br />
    y = this.candlesize;<br />
    for (i = 0; i &lt; y; i++) {<br />
        this.logic.globalcount++;//COUNT BACKTEST CANDLES<br />
<br />
        z = this.moncount - 1;<br />
        this.monthframe = this.montharr[z];<br />
        candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////<br />
        this.candleminute = candleminute;<br />
        //HOUR COUNT<br />
        if (this.mcount == 59) {<br />
            this.hcount++;//HOUR COUNT<br />
            this.mcount = 0;<br />
        }<br />
        else if (this.mcount &lt; 59) {<br />
            this.mcount++;<br />
        }<br />
        //DAY COUNT<br />
        if (this.hcount == 24) {<br />
            this.dcount++;//DAY COUNT<br />
            this.hcount = 0;<br />
        }<br />
        //MONTHDAY<br />
        if (this.dcount &gt; (this.monthframe)) {<br />
            this.moncount++;<br />
            this.dcount = 1<br />
        }<br />
        //MONTH<br />
        else if (this.moncount &gt; 12) {<br />
            this.moncount = 1;<br />
        }<br />
        this.candlehour = this.hcount;//HOUR<br />
        this.candleday = this.dcount;//DAY<br />
        this.candlemonth = this.moncount;//MONTH<br />
        this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];<br />
    }<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
much better ;-)<br />
its now modular to comment/uncomment functions, besides it has become somewhat structurized.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>//this.timeCursor();</code></div></div>now the whole function is switched off<br />
<br />
<br />
thats it for the timecursor and subcircuits.<br />
in the next short tutorial a simple cpu-prozessing-time messurement tool and debug functions are the topic.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[TUT] STRATEGIE#1 BASSic TULIP RSI TRADER]]></title>
			<link>https://forum.gekko.wizb.it/thread-56936.html</link>
			<pubDate>Thu, 26 Apr 2018 03:50:30 +0000</pubDate>
			<guid isPermaLink="false">https://forum.gekko.wizb.it/thread-56936.html</guid>
			<description><![CDATA[WARNING: THIS IS A GUIDE FOR BEGINNERS FROM A BLOODY BEGINNER AS YOU WILL SEE<br />
PRO-CODERS PLEASE ADD CORRECTIONS SO I CAN LEARN! THANKS TO MIKE<br />
<br />
In the following tutorial sequals you can learn: <br />
-how to develop a strategie, <br />
-build some useful tools for our debug purposes<br />
-build a little trend generator<br />
-add a pseudo stoploss (loose halve the bag is better then...)<br />
<br />
&gt;&gt;&gt;ONLY START THE SIMULATION WHEN I ASK YOU TO (incomplete snippets wont work)<br />
<br />
If you are not to much into electronics/logic/debug...no worries you will learn by the examples,<br />
and with the diffrent code modules you can build your own.<br />
Ask questions AND i strongly recomend to watch some nice youtube java tutorials :<br />
(basic code structure, conventions, operators, statements, var/obj/this.global/arrays!)<br />
<a href="https://www.youtube.com/watch?v=7WiPGP_0AUA&amp;list=PL9DF6E4B45C36D411" target="_blank" rel="noopener" class="mycode_url">Cave of programming</a><br />
<br />
The performance wont be the goal of this tutorals. Its more for educational purpose.<br />
<br />
You need a serious code editor that works for you. <br />
after notepad++ and eclipse strugle i use now Visual studio code. perfect love it nice!!<br />
<br />
<br />
cli == cmd == terminal (command line interface)<br />
<br />
bracket convention:<br />
the brackets can be used in three different ways, doing exactly the same<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) <br />
{<br />
  do_something;<br />
}</code></div></div><div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) {<br />
  do_something;<br />
}</code></div></div><div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) {do_something;}</code></div></div><br />
<br />
to create a comment in the strat use double backlash:<br />
//my comment<br />
<br />
for a whole comment-block use asterix+backlash: //the editor will help with colors... <br />
/*<br />
my<br />
comment<br />
block<br />
*/<br />
<br />
the = sign-ology<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>a = b; //basic code convention: the right value will always be moved into the left variable (a value WILL BE LOST)<br />
a = b + c; //on the right we can add operators, do calculations before we move the result into a<br />
if (a == b){ //here the == is a comparator function (is it the same as ???)<br />
    do_stuff<br />
}<br />
<br />
a = b + c; //the semikolon tells the compiler to do whats before...<br />
a = b + c * x / 3,14; //first it calculates the multiply/divide then the Add/subtract then the result will be moved into a<br />
a = (b + c) * x / 3,14; //first it calculates whats inside the brackets then the result will be moved into a</code></div></div><br />
<br />
<br />
<br />
<br />
first we begin with the core of our strategie without eny content:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
<br />
var method = {};<br />
<br />
method.init = function()<br />
{<br />
<br />
}<br />
<br />
method.update = function(candle) {<br />
<br />
}<br />
<br />
method.log = function() {<br />
<br />
}<br />
<br />
method.check = function(candle)<br />
{<br />
<br />
}<br />
<br />
module.exports = method;</code></div></div>The compiler needs some basic functions in order to work.<br />
Also the order must be correct:<br />
-init<br />
-update<br />
-log<br />
-check<br />
-export<br />
<br />
the log function is not too useful so we have only three main sections:<br />
-init<br />
-update<br />
-check<br />
<br />
the export function is only for the compiler, to add our strat to gekko.<br />
<br />
<br />
<br />
Now we begin even smaller and create our first VAR (variable).<br />
This is necessary to initialize the ram since the computer can not place numbers in the air.<br />
A var is a vessel that can hold enything we move inside.<br />
example:<br />
//house would be our object (object based code technique)<br />
house<br />
//house contains...<br />
kitchen, restroom, basement<br />
//kitchen contains...<br />
stove, fridge, sink<br />
//fridge contains...<br />
keg of b...<br />
<br />
//when we use that object hirarchy in our code, we would write for keg:<br />
house.kitchen.fridge.keg //(simpified)<br />
<br />
now our computer knows where is the keg and therefor thus initialize the ram for us.<br />
if we have a var/number/value we can only use it locally where it is created:<br />
in this example i create a var in [update] and tell the strat in the [check] to display the value in the cli<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.update = function(candle) <br />
{<br />
var myvalue = 0;//here we create/define myvalue as a local object<br />
}<br />
<br />
method.check = function(candle) {<br />
log.debug (myvalue); //in here myvalue would not be readable because first we must assign it as a global object<br />
}</code></div></div><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.update = function(candle) <br />
{<br />
var myvalue = 0;//here we create/define myvalue as a local object<br />
this.myvalue = myvalue; //now we make it global by move myvalue into this.myvalue (this. is the global parameter)<br />
}<br />
<br />
method.check = function(candle) {<br />
  log.debug (this.myvalue); //now it is avilable everywhere in our strat and updated, evertime the code use it somewhere<br />
}</code></div></div><br />
lets create our first var:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var method = {};</code></div></div><br />
since this is the var for my strat i name mine:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};</code></div></div><br />
our strat:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
<br />
<br />
now we add a indicator, fetch the settings from the settings (.toml) and update the indicator before use.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it with the candle data<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;NOTE: THE INDICATOR WILL AUTOMATICLY FIND THE NECESSARY CANDLE DATA<br />
&gt;&gt;&gt;&gt;&gt;WE ONLY HAVE TO DEFINE THE INPUT LENGTH OF THE AVERAGING<br />
<br />
<br />
the settings.toml file look like this:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 70<br />
low = 30</code></div></div><br />
Now its time to save these files to the gekko folder:<br />
use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_0.js //and save<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_0.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
We need also to import other variables:<br />
&gt;&gt;we tell gekko where to find the user settings and that we wanna use it in our strat<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var config = require ('../core/util.js').getConfig();</code></div></div><br />
add all to our strat //this special vars are placed before the init (like drivers from the op-system of gekko)<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require ('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
&gt;&gt;&gt;copy/paste the finished code into your editor and safe it<br />
&gt;&gt;&gt;&gt;start gekko user interface in the cli<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>node gekko --ui</code></div></div>go to backtest and select:<br />
-Binance<br />
-BTC-USDT<br />
-21 days period<br />
-1 minute candles<br />
-10 minute warmup<br />
-select your strat<br />
&gt;&gt;&gt;&gt;&gt;start backtest...<br />
//NOTE THAT WE WOULD KEEP THESE SETTINGS THROUGOUT OUR DEVELOPEMENT FOR CONSISTENCY<br />
&gt;&gt;&gt;&gt;result = 0.0000&lt;&lt;&lt;&lt;<br />
....what it dos not show enything?!?!?<br />
Allright now we need to create our messurement tools in order to find out what it REALLY does.<br />
its simple:<br />
EVERY FUNCTION WE DESIGN MUST ALSO HAVE ITS OWN DEBUG LINE THAT SHOWS US IN THE CLI:<br />
&gt;&gt;&gt;IF, WHEN, WHAT, AND HOW MUCH DID HAPPEN<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
&gt;&gt;&gt;relounch gekko and run new code<br />
now we see the rsi value calculated and displayed on every candle<br />
<br />
time to give advice to the trader!<br />
&gt;&gt;&gt;add our first statement:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;run the new code<br />
it should display lots of trades and a positive result<br />
<br />
the trader recieves the advice from our strat, if the rsi thresholds are reached, and automaticly executes the rest (place order...and more..)<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.advice('short');</code></div></div>nice!<br />
<br />
add debug lines and switch-off the unneccessary one simply by commenting it<br />
&gt;&gt;&gt;NOTICE EVERY PART OF CODE CAN BE SWITCHED OFF/ON BY MAKE A COMMENT OUT OF IT<br />
<br />
add debug lines that shows/triggers at goShort/goLong and displays the candle.close price<br />
this must be after the long/short event but in the same if-statement...<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;run new code<br />
<br />
&gt;&gt;&gt;&gt;&gt;ERROR oops the cli says:<br />
TypeError: Cannot read property 'close' of undefined<br />
&gt;&gt;&gt;&gt;&gt;&gt;it says in our strat .js at line:40 row:51<br />
<br />
ok the candle.close is not defined/initialized yet<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
    {<br />
        close: 0,//this.candle<br />
    };<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;no more error but the price.close = 0<br />
<br />
we have defined and initialized our price.close but we do not move candle.close into it &gt;&gt;&gt; BEFORE we wanna use it<br />
(candle data are global variables that are beeing updated by the candleBatcher inside gekko)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>hey are you still here? then you made it grz!<br />
<br />
<br />
...only one thing for the rsi-bass-strat:<br />
&gt;&gt;&gt;if the if statement does sell/buy, it is maybe still in the rsi threshold trigger region and try to make the same trade till-<br />
the rsi moves out of the trigger region.&gt;&gt;&gt;&gt;&gt;THATS BAD CODE PRACTICE !!!!!<br />
&gt;&gt;&gt;&gt;&gt;&gt;SOLUTION WE ADD DECLARATION<br />
a boolean is like a var &gt;&gt;it can hold a value but only a "1" or "no 1" (0 or 1)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>myBoolean = true; //we move true into myBoolean</code></div></div><br />
<br />
apply to our strat:<br />
you MUST name all your values in a way that make most sense FOR YOU to work with afterwards<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
    {<br />
        longpos: false<br />
    };<br />
    this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos == true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos == false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;in the init we first create/init our globlal object<br />
&gt;&gt;&gt;&gt;in the check section, we block the other state in the if statement<br />
&gt;&gt;&gt;&gt;&gt;in the buy/sell function we set the new state &gt;&gt;&gt;now the buy/sell function is finished-<br />
but on the next candle it CANT FALL BACK<br />
(((THE strategie code will be executed one time per candle)))<br />
<br />
in this way we will ALWAYS declair all states in advance for not bouncing back/forth a billion times per second.<br />
&gt;&gt;&gt;&gt;&gt;ITS CALLED BUTTON DEBOUNCE OR DEBOUNCE<br />
(this tiny smart circuit is in every device nowadays, otherways digital buttons/codes would not work well)<br />
<br />
still there then we make it more advanced:<br />
&gt;&gt;&gt;we have declared that the boolean must be equal to ==<br />
&gt;&gt;&gt;&gt;THIS IS NOT A GOOD PRACTICE EITHER BECAUSE IF THE BOOLEAN IS NEVER EQUAL TO...THEN IT NEVER HAPPEN<br />
&gt;&gt;&gt;&gt;&gt;WE DECLARE IT WITH NOT<br />
boolean !== false //...IF NOT FALSE THEN...<br />
&gt;&gt;&gt;&gt;&gt;&gt;THIS EXCLUDES THE UNWANTED STATE<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;THEREFORE ENY OTHER STATE CAN HAPPEN EXEPT THE UNWANTED ONE<br />
it need little practice to wrap the head around these logic topologies<br />
thought the computer must ALWAYS KNOW WHAT TO DO for not bouncing !!!<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;when the code is lounched then the startup states are most critical <br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;the NOT statement helps alot<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
    {<br />
        longpos: false<br />
    };<br />
    this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;&gt;&gt;the computer knows nothing so we do define everything proper<br />
__________________________________________________________________________________________<br />
this is it for tutorial part one...rsi<br />
<br />
the strat looks now very messy and the debug also<br />
in the next tut we create some tools.]]></description>
			<content:encoded><![CDATA[WARNING: THIS IS A GUIDE FOR BEGINNERS FROM A BLOODY BEGINNER AS YOU WILL SEE<br />
PRO-CODERS PLEASE ADD CORRECTIONS SO I CAN LEARN! THANKS TO MIKE<br />
<br />
In the following tutorial sequals you can learn: <br />
-how to develop a strategie, <br />
-build some useful tools for our debug purposes<br />
-build a little trend generator<br />
-add a pseudo stoploss (loose halve the bag is better then...)<br />
<br />
&gt;&gt;&gt;ONLY START THE SIMULATION WHEN I ASK YOU TO (incomplete snippets wont work)<br />
<br />
If you are not to much into electronics/logic/debug...no worries you will learn by the examples,<br />
and with the diffrent code modules you can build your own.<br />
Ask questions AND i strongly recomend to watch some nice youtube java tutorials :<br />
(basic code structure, conventions, operators, statements, var/obj/this.global/arrays!)<br />
<a href="https://www.youtube.com/watch?v=7WiPGP_0AUA&amp;list=PL9DF6E4B45C36D411" target="_blank" rel="noopener" class="mycode_url">Cave of programming</a><br />
<br />
The performance wont be the goal of this tutorals. Its more for educational purpose.<br />
<br />
You need a serious code editor that works for you. <br />
after notepad++ and eclipse strugle i use now Visual studio code. perfect love it nice!!<br />
<br />
<br />
cli == cmd == terminal (command line interface)<br />
<br />
bracket convention:<br />
the brackets can be used in three different ways, doing exactly the same<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) <br />
{<br />
  do_something;<br />
}</code></div></div><div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) {<br />
  do_something;<br />
}</code></div></div><div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.check = function(candle) {do_something;}</code></div></div><br />
<br />
to create a comment in the strat use double backlash:<br />
//my comment<br />
<br />
for a whole comment-block use asterix+backlash: //the editor will help with colors... <br />
/*<br />
my<br />
comment<br />
block<br />
*/<br />
<br />
the = sign-ology<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>a = b; //basic code convention: the right value will always be moved into the left variable (a value WILL BE LOST)<br />
a = b + c; //on the right we can add operators, do calculations before we move the result into a<br />
if (a == b){ //here the == is a comparator function (is it the same as ???)<br />
    do_stuff<br />
}<br />
<br />
a = b + c; //the semikolon tells the compiler to do whats before...<br />
a = b + c * x / 3,14; //first it calculates the multiply/divide then the Add/subtract then the result will be moved into a<br />
a = (b + c) * x / 3,14; //first it calculates whats inside the brackets then the result will be moved into a</code></div></div><br />
<br />
<br />
<br />
<br />
first we begin with the core of our strategie without eny content:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
<br />
var method = {};<br />
<br />
method.init = function()<br />
{<br />
<br />
}<br />
<br />
method.update = function(candle) {<br />
<br />
}<br />
<br />
method.log = function() {<br />
<br />
}<br />
<br />
method.check = function(candle)<br />
{<br />
<br />
}<br />
<br />
module.exports = method;</code></div></div>The compiler needs some basic functions in order to work.<br />
Also the order must be correct:<br />
-init<br />
-update<br />
-log<br />
-check<br />
-export<br />
<br />
the log function is not too useful so we have only three main sections:<br />
-init<br />
-update<br />
-check<br />
<br />
the export function is only for the compiler, to add our strat to gekko.<br />
<br />
<br />
<br />
Now we begin even smaller and create our first VAR (variable).<br />
This is necessary to initialize the ram since the computer can not place numbers in the air.<br />
A var is a vessel that can hold enything we move inside.<br />
example:<br />
//house would be our object (object based code technique)<br />
house<br />
//house contains...<br />
kitchen, restroom, basement<br />
//kitchen contains...<br />
stove, fridge, sink<br />
//fridge contains...<br />
keg of b...<br />
<br />
//when we use that object hirarchy in our code, we would write for keg:<br />
house.kitchen.fridge.keg //(simpified)<br />
<br />
now our computer knows where is the keg and therefor thus initialize the ram for us.<br />
if we have a var/number/value we can only use it locally where it is created:<br />
in this example i create a var in [update] and tell the strat in the [check] to display the value in the cli<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.update = function(candle) <br />
{<br />
var myvalue = 0;//here we create/define myvalue as a local object<br />
}<br />
<br />
method.check = function(candle) {<br />
log.debug (myvalue); //in here myvalue would not be readable because first we must assign it as a global object<br />
}</code></div></div><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>method.update = function(candle) <br />
{<br />
var myvalue = 0;//here we create/define myvalue as a local object<br />
this.myvalue = myvalue; //now we make it global by move myvalue into this.myvalue (this. is the global parameter)<br />
}<br />
<br />
method.check = function(candle) {<br />
  log.debug (this.myvalue); //now it is avilable everywhere in our strat and updated, evertime the code use it somewhere<br />
}</code></div></div><br />
lets create our first var:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var method = {};</code></div></div><br />
since this is the var for my strat i name mine:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};</code></div></div><br />
our strat:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
<br />
<br />
now we add a indicator, fetch the settings from the settings (.toml) and update the indicator before use.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it with the candle data<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;NOTE: THE INDICATOR WILL AUTOMATICLY FIND THE NECESSARY CANDLE DATA<br />
&gt;&gt;&gt;&gt;&gt;WE ONLY HAVE TO DEFINE THE INPUT LENGTH OF THE AVERAGING<br />
<br />
<br />
the settings.toml file look like this:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>[RSI]<br />
optInTimePeriod = 15<br />
<br />
[trsRSI]<br />
high = 70<br />
low = 30</code></div></div><br />
Now its time to save these files to the gekko folder:<br />
use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code strat above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_0.js //and save<br />
WARNIG: MY CODE INDENTS HAVE BEEN BIT  MESSED UP HERE<br />
JUST: in your editor right-click choose [format document] before save...<br />
<br />
use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....)<br />
&gt;select all and delete the content<br />
&gt;&gt;copy/paste my example code user settings above<br />
&gt;&gt;&gt;Save as: rename to:<br />
&gt;&gt;&gt;&gt;trendatron_0.toml <br />
&gt;&gt;&gt;&gt;&gt;Save as type //&lt;&lt;&lt;SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) <br />
<br />
<br />
We need also to import other variables:<br />
&gt;&gt;we tell gekko where to find the user settings and that we wanna use it in our strat<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>var config = require ('../core/util.js').getConfig();</code></div></div><br />
add all to our strat //this special vars are placed before the init (like drivers from the op-system of gekko)<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require ('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
    var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
    this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function(candle) {<br />
<br />
}<br />
<br />
trenda.log = function() {<br />
<br />
}<br />
<br />
trenda.check = function(candle)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
    var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
&gt;&gt;&gt;copy/paste the finished code into your editor and safe it<br />
&gt;&gt;&gt;&gt;start gekko user interface in the cli<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>node gekko --ui</code></div></div>go to backtest and select:<br />
-Binance<br />
-BTC-USDT<br />
-21 days period<br />
-1 minute candles<br />
-10 minute warmup<br />
-select your strat<br />
&gt;&gt;&gt;&gt;&gt;start backtest...<br />
//NOTE THAT WE WOULD KEEP THESE SETTINGS THROUGOUT OUR DEVELOPEMENT FOR CONSISTENCY<br />
&gt;&gt;&gt;&gt;result = 0.0000&lt;&lt;&lt;&lt;<br />
....what it dos not show enything?!?!?<br />
Allright now we need to create our messurement tools in order to find out what it REALLY does.<br />
its simple:<br />
EVERY FUNCTION WE DESIGN MUST ALSO HAVE ITS OWN DEBUG LINE THAT SHOWS US IN THE CLI:<br />
&gt;&gt;&gt;IF, WHEN, WHAT, AND HOW MUCH DID HAPPEN<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//now use it...<br />
}<br />
<br />
module.exports = trenda;</code></div></div><br />
&gt;&gt;&gt;relounch gekko and run new code<br />
now we see the rsi value calculated and displayed on every candle<br />
<br />
time to give advice to the trader!<br />
&gt;&gt;&gt;add our first statement:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;run the new code<br />
it should display lots of trades and a positive result<br />
<br />
the trader recieves the advice from our strat, if the rsi thresholds are reached, and automaticly executes the rest (place order...and more..)<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>this.advice('short');</code></div></div>nice!<br />
<br />
add debug lines and switch-off the unneccessary one simply by commenting it<br />
&gt;&gt;&gt;NOTICE EVERY PART OF CODE CAN BE SWITCHED OFF/ON BY MAKE A COMMENT OUT OF IT<br />
<br />
add debug lines that shows/triggers at goShort/goLong and displays the candle.close price<br />
this must be after the long/short event but in the same if-statement...<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;run new code<br />
<br />
&gt;&gt;&gt;&gt;&gt;ERROR oops the cli says:<br />
TypeError: Cannot read property 'close' of undefined<br />
&gt;&gt;&gt;&gt;&gt;&gt;it says in our strat .js at line:40 row:51<br />
<br />
ok the candle.close is not defined/initialized yet<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
    {<br />
        close: 0,//this.candle<br />
    };<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;no more error but the price.close = 0<br />
<br />
we have defined and initialized our price.close but we do not move candle.close into it &gt;&gt;&gt; BEFORE we wanna use it<br />
(candle data are global variables that are beeing updated by the candleBatcher inside gekko)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>hey are you still here? then you made it grz!<br />
<br />
<br />
...only one thing for the rsi-bass-strat:<br />
&gt;&gt;&gt;if the if statement does sell/buy, it is maybe still in the rsi threshold trigger region and try to make the same trade till-<br />
the rsi moves out of the trigger region.&gt;&gt;&gt;&gt;&gt;THATS BAD CODE PRACTICE !!!!!<br />
&gt;&gt;&gt;&gt;&gt;&gt;SOLUTION WE ADD DECLARATION<br />
a boolean is like a var &gt;&gt;it can hold a value but only a "1" or "no 1" (0 or 1)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>myBoolean = true; //we move true into myBoolean</code></div></div><br />
<br />
apply to our strat:<br />
you MUST name all your values in a way that make most sense FOR YOU to work with afterwards<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
    {<br />
        longpos: false<br />
    };<br />
    this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos == true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos == false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;in the init we first create/init our globlal object<br />
&gt;&gt;&gt;&gt;in the check section, we block the other state in the if statement<br />
&gt;&gt;&gt;&gt;&gt;in the buy/sell function we set the new state &gt;&gt;&gt;now the buy/sell function is finished-<br />
but on the next candle it CANT FALL BACK<br />
(((THE strategie code will be executed one time per candle)))<br />
<br />
in this way we will ALWAYS declair all states in advance for not bouncing back/forth a billion times per second.<br />
&gt;&gt;&gt;&gt;&gt;ITS CALLED BUTTON DEBOUNCE OR DEBOUNCE<br />
(this tiny smart circuit is in every device nowadays, otherways digital buttons/codes would not work well)<br />
<br />
still there then we make it more advanced:<br />
&gt;&gt;&gt;we have declared that the boolean must be equal to ==<br />
&gt;&gt;&gt;&gt;THIS IS NOT A GOOD PRACTICE EITHER BECAUSE IF THE BOOLEAN IS NEVER EQUAL TO...THEN IT NEVER HAPPEN<br />
&gt;&gt;&gt;&gt;&gt;WE DECLARE IT WITH NOT<br />
boolean !== false //...IF NOT FALSE THEN...<br />
&gt;&gt;&gt;&gt;&gt;&gt;THIS EXCLUDES THE UNWANTED STATE<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;THEREFORE ENY OTHER STATE CAN HAPPEN EXEPT THE UNWANTED ONE<br />
it need little practice to wrap the head around these logic topologies<br />
thought the computer must ALWAYS KNOW WHAT TO DO for not bouncing !!!<br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;when the code is lounched then the startup states are most critical <br />
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;the NOT statement helps alot<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>/*<br />
Tutorial: &nbsp;&nbsp;&nbsp;&nbsp;trendatron #1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsi trader<br />
philipp wyler<br />
2018-04-25<br />
*/<br />
<br />
var _ = require('lodash');<br />
var log = require('../core/log.js');<br />
var config = require('../core/util.js').getConfig();<br />
<br />
var trenda = {};<br />
<br />
trenda.init = function () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add candle.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;price =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close: 0,//this.candle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price = price;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;logic =<br />
    {<br />
        longpos: false<br />
    };<br />
    this.logic = logic;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//first fetch settings from .toml<br />
&nbsp;&nbsp;&nbsp;&nbsp;var customRSIsettings = this.settings.RSI;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// define the indicators we need &nbsp;&nbsp;&nbsp;&nbsp;//move the settings into &gt;&gt;&gt;rsi input length<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.addTulipIndicator('myrsi', 'rsi', customRSIsettings);<br />
}<br />
<br />
trenda.update = function (candle) {<br />
<br />
}<br />
<br />
trenda.log = function () {<br />
<br />
}<br />
<br />
trenda.check = function (candle) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update price.close<br />
&nbsp;&nbsp;&nbsp;&nbsp;this.price.close = this.candle.close;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//update the indicator before using it<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultRSI = this.tulipIndicators.myrsi.result.result;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//add debug line and display the rsi value<br />
&nbsp;&nbsp;&nbsp;&nbsp;//log.debug('RSI result = ' + resultRSI);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//lets trade...<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (resultRSI &gt; this.settings.trsRSI.high &amp;&amp; this.logic.longpos !== false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('short');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goShort price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else if (resultRSI &lt; this.settings.trsRSI.low &amp;&amp; this.logic.longpos !== true) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.logic.longpos = true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.advice('long');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug('goLong price.close = ' + this.price.close);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
module.exports = trenda;</code></div></div>&gt;&gt;&gt;&gt;&gt;the computer knows nothing so we do define everything proper<br />
__________________________________________________________________________________________<br />
this is it for tutorial part one...rsi<br />
<br />
the strat looks now very messy and the debug also<br />
in the next tut we create some tools.]]></content:encoded>
		</item>
	</channel>
</rss>