[TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - Printable Version +- Gekko Forum (https://forum.gekko.wizb.it) +-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html) +--- Forum: Guides (https://forum.gekko.wizb.it/forum-22.html) +--- Thread: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER (/thread-56936.html) Pages:
1
2
|
[TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - susitronix - 04-26-2018 WARNING: THIS IS A GUIDE FOR BEGINNERS FROM A BLOODY BEGINNER AS YOU WILL SEE PRO-CODERS PLEASE ADD CORRECTIONS SO I CAN LEARN! THANKS TO MIKE In the following tutorial sequals you can learn: -how to develop a strategie, -build some useful tools for our debug purposes -build a little trend generator -add a pseudo stoploss (loose halve the bag is better then...) >>>ONLY START THE SIMULATION WHEN I ASK YOU TO (incomplete snippets wont work) If you are not to much into electronics/logic/debug...no worries you will learn by the examples, and with the diffrent code modules you can build your own. Ask questions AND i strongly recomend to watch some nice youtube java tutorials : (basic code structure, conventions, operators, statements, var/obj/this.global/arrays!) Cave of programming The performance wont be the goal of this tutorals. Its more for educational purpose. You need a serious code editor that works for you. after notepad++ and eclipse strugle i use now Visual studio code. perfect love it nice!! cli == cmd == terminal (command line interface) bracket convention: the brackets can be used in three different ways, doing exactly the same Code: method.check = function(candle) Code: method.check = function(candle) { Code: method.check = function(candle) {do_something;} to create a comment in the strat use double backlash: //my comment for a whole comment-block use asterix+backlash: //the editor will help with colors... /* my comment block */ the = sign-ology Code: a = b; //basic code convention: the right value will always be moved into the left variable (a value WILL BE LOST) first we begin with the core of our strategie without eny content: Code: /* Also the order must be correct: -init -update -log -check -export the log function is not too useful so we have only three main sections: -init -update -check the export function is only for the compiler, to add our strat to gekko. Now we begin even smaller and create our first VAR (variable). This is necessary to initialize the ram since the computer can not place numbers in the air. A var is a vessel that can hold enything we move inside. example: //house would be our object (object based code technique) house //house contains... kitchen, restroom, basement //kitchen contains... stove, fridge, sink //fridge contains... keg of b... //when we use that object hirarchy in our code, we would write for keg: house.kitchen.fridge.keg //(simpified) now our computer knows where is the keg and therefor thus initialize the ram for us. if we have a var/number/value we can only use it locally where it is created: in this example i create a var in [update] and tell the strat in the [check] to display the value in the cli Code: method.update = function(candle) Code: method.update = function(candle) lets create our first var: Code: var method = {}; since this is the var for my strat i name mine: Code: var trenda = {}; our strat: Code: var trenda = {}; now we add a indicator, fetch the settings from the settings (.toml) and update the indicator before use. Code: var trenda = {}; >>>>>WE ONLY HAVE TO DEFINE THE INPUT LENGTH OF THE AVERAGING the settings.toml file look like this: Code: [RSI] Now its time to save these files to the gekko folder: use your editor and load a existing gekko strategie.js file from the gekko folder (gekko/strategies/.....) >select all and delete the content >>copy/paste my example code strat above >>>Save as: rename to: >>>>trendatron_0.js //and save WARNIG: MY CODE INDENTS HAVE BEEN BIT MESSED UP HERE JUST: in your editor right-click choose [format document] before save... use your editor and load a existing gekko strategie.toml file from the gekko folder (gekko/config/strategies/.....) >select all and delete the content >>copy/paste my example code user settings above >>>Save as: rename to: >>>>trendatron_0.toml >>>>>Save as type //<<<SELECT TYPE: ALL FILES (SCROLL UP TO FIND IT..!) We need also to import other variables: >>we tell gekko where to find the user settings and that we wanna use it in our strat Code: var config = require ('../core/util.js').getConfig(); add all to our strat //this special vars are placed before the init (like drivers from the op-system of gekko) Code: /* >>>copy/paste the finished code into your editor and safe it >>>>start gekko user interface in the cli Code: node gekko --ui -Binance -BTC-USDT -21 days period -1 minute candles -10 minute warmup -select your strat >>>>>start backtest... //NOTE THAT WE WOULD KEEP THESE SETTINGS THROUGOUT OUR DEVELOPEMENT FOR CONSISTENCY >>>>result = 0.0000<<<< ....what it dos not show enything?!?!? Allright now we need to create our messurement tools in order to find out what it REALLY does. its simple: EVERY FUNCTION WE DESIGN MUST ALSO HAVE ITS OWN DEBUG LINE THAT SHOWS US IN THE CLI: >>>IF, WHEN, WHAT, AND HOW MUCH DID HAPPEN Code: /* >>>relounch gekko and run new code now we see the rsi value calculated and displayed on every candle time to give advice to the trader! >>>add our first statement: Code: /* it should display lots of trades and a positive result the trader recieves the advice from our strat, if the rsi thresholds are reached, and automaticly executes the rest (place order...and more..) Code: this.advice('short'); add debug lines and switch-off the unneccessary one simply by commenting it >>>NOTICE EVERY PART OF CODE CAN BE SWITCHED OFF/ON BY MAKE A COMMENT OUT OF IT add debug lines that shows/triggers at goShort/goLong and displays the candle.close price this must be after the long/short event but in the same if-statement... Code: /* >>>>>ERROR oops the cli says: TypeError: Cannot read property 'close' of undefined >>>>>>it says in our strat .js at line:40 row:51 ok the candle.close is not defined/initialized yet Code: /* we have defined and initialized our price.close but we do not move candle.close into it >>> BEFORE we wanna use it (candle data are global variables that are beeing updated by the candleBatcher inside gekko) Code: /* ...only one thing for the rsi-bass-strat: >>>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- the rsi moves out of the trigger region.>>>>>THATS BAD CODE PRACTICE !!!!! >>>>>>SOLUTION WE ADD DECLARATION a boolean is like a var >>it can hold a value but only a "1" or "no 1" (0 or 1) Code: myBoolean = true; //we move true into myBoolean apply to our strat: you MUST name all your values in a way that make most sense FOR YOU to work with afterwards Code: /* >>>>in the check section, we block the other state in the if statement >>>>>in the buy/sell function we set the new state >>>now the buy/sell function is finished- but on the next candle it CANT FALL BACK (((THE strategie code will be executed one time per candle))) in this way we will ALWAYS declair all states in advance for not bouncing back/forth a billion times per second. >>>>>ITS CALLED BUTTON DEBOUNCE OR DEBOUNCE (this tiny smart circuit is in every device nowadays, otherways digital buttons/codes would not work well) still there then we make it more advanced: >>>we have declared that the boolean must be equal to == >>>>THIS IS NOT A GOOD PRACTICE EITHER BECAUSE IF THE BOOLEAN IS NEVER EQUAL TO...THEN IT NEVER HAPPEN >>>>>WE DECLARE IT WITH NOT boolean !== false //...IF NOT FALSE THEN... >>>>>>THIS EXCLUDES THE UNWANTED STATE >>>>>>>THEREFORE ENY OTHER STATE CAN HAPPEN EXEPT THE UNWANTED ONE it need little practice to wrap the head around these logic topologies thought the computer must ALWAYS KNOW WHAT TO DO for not bouncing !!! >>>>>>>>when the code is lounched then the startup states are most critical >>>>>>>>>the NOT statement helps alot Code: /* __________________________________________________________________________________________ this is it for tutorial part one...rsi the strat looks now very messy and the debug also in the next tut we create some tools. RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - ankasem - 04-26-2018 hi nice share thanks RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - AlfonsoMX - 04-30-2018 Thanks for sharing your Knoledge I´m trying to build a strategy that has worked for me lately with Stoch, MACD and RSI I really apreciate Your time posting this Tutorials for beginners. I have some knoledge about programing but coding a strategy is beyond my experience. Thanks again man! RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - susitronix - 04-30-2018 i have to thank. thanks Mike its amazing what i have learnd with gekko/java script. we will build a little strategie but, that tryes to keep up with the big boys. found that its pretty difficult with the RSI since in the sidways market the RSI falls back to the middle and neglect to goShort, >>>therefore keep that bag when the trend goes down (wedge analysis, crack the resistance...). RSI seems usefull for the Long signal (sometimes!) since my new Trendline indicator is not finished yet, a intresting idea has derived: a simple trailing loss. tryed with RSI-long and trailling-stop short, but it instantly goes long again after the short because the loss does best with -3%. thats where the RSI has its lower threshold. did not tryed hard only one night. it seems that this parameter must be dynamicly adjusted. imagine: the long level creates a lower and a upper zone. the lower zone would hardwired trigger at -1.2% inorder to have enough headroom for the nois. but if it goes above long level, the sample+hold would charge up. the upper zone from 0% to 1% above long would have -2% trailing loss. then from 1%-2% above long it would go to -3% trailing loss. >>>but then at some point it should switch to -0.5% for to goShort..??? I guess this cant work that way because of the the market signal is very dynamique. so we would try to make trend analysis, that indicates the trend.angle and the trend.amplitude. thatway we may teach our gekko to set the trailing stop to -0.5% or so. Since it goes so fast sometimes, a reactive mecanism is better than nothing but a pro-active goodness would be more in-time. Also if there is a crack in the support, then it should not really try to trade. Its seems hard to catch the harsh down/moon trends where the timing would tradeoff aginst smoothness/persistance. a trend line indicator works better there. it would sample the highs and lows and draw a vector line based on the difference low-low. this blocks the higher harmonic by a sort of integrating mechanism while live from a shorter averaging in order to be smooth, than regular indicators. offcourse it very much blocks the frequencys below the macro.trend frequency. and if there is a crack in the resistance then i could reset and preload the newest difference, into the averaging cells (support/resistance vectors) for a faster trend reversal RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - susitronix - 04-30-2018 just fund a nice article and code to trailing loss. zschro/GekkoSchaffTrendCycle I have missed out the blog for 2month. beasicly its a simple sample and hold but with a absolut procentage threshold. since it seems to be hard or unreliable to work with direct price values, its very nice and ANALOG, to work with %-calculation all over the place because this does not take much cpu time at all..! RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - arianna - 09-14-2020 I enjoy it for creating the details, keep up the truly amazing perform continuing Shibabrata Bhaumik RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - arianna - 09-16-2020 This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post! chudjen99 RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - arianna - 09-17-2020 We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work سایت بازی رولت زنده RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - arianna - 09-17-2020 You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog. ก๋วยจั๊บญวนสำเร็จรูป RE: [TUT] STRATEGIE#1 BASSic TULIP RSI TRADER - arianna - 09-19-2020 The article posted was very informative and useful. You people are doing a great job. Keep going. trial instagram followers |