backtest not working or strategy problem ?
Hi so after i tried to test my strategy on the backtest nothing happens even with only a MACD and RSI
https://gist.github.com/Pedro942/4edb1bcac372bba9254080553ff39231

The signals depend on a lot of things: the market you are trying to run over, the numbers you use. If you comment out the if checks, like the one below you can figure out if those prevent your strat from signaling:
- https://gist.github.com/Pedro942/4edb1bcac372bba9254080553ff39231/#file-strat-js-L66
- https://gist.github.com/Pedro942/4edb1bcac372bba9254080553ff39231/#file-strat-js-L76
If you comment those out and your strat is still not signaling there might be something else wrong. I am closing this since it's not an issue with Gekko. Please just keep responding & don't open new issues.
Can't the problem be in these lines : var MACDsaysBUY = parameters.down < 0; var MACDsaysSELL = parameters.up > 0;
Can you explain me how The var MACDsaysBUY work ? I mean parameters.down are the threeshold i've set in parameters but what is the variable for the current value of the macd ? It should be like this i think : MACDsaysBUY = parameters.down == actualMACD.VALUE Or parameters.down > actualMACD.VALUE
You are correct!
Here is an improved version: Let me know how that works.
https://gist.github.com/askmike/5e5e10c538f617ecb2544217eab76647
Well I tried it but still nothing happens with different parameters, I can't see the part where gekko is supposed to execute a buy or sell maybe that's what missing i mean it just give the advice to go short or go long, and then switches from short to long. Any idea ?
everything happens after this.advice('short') and this.advice('long') if that code never runs Gekko won't do any trading / simulating.
Did you also not get any signal after commenting the ifcheck out?
Actually i just tried to comment the ifcheck out and I did get the signals but it doesn't work the way i want it to work i just buys on every candle then sells on the next one : (it's clearer when i put it on 1 day candles.

well this means that signals are working: If you comment the logic out that only buys/sells under certain conditions (the ifchecks) gekko works fine and is buying and selling.
So the rest is 100% in the variables in your ifchecks. I suggest logging (using console.log and checking the commmandline) these numbers to see why they never happen.
Okay Mike thank you for the help i'm going to get a close eye into the console and see if theres something i can change i'll let you know the results.
Hi Mike sorry again i don't know how to run console.log
Add logging to the strategy in the method log section for viewing on command line backtest
ie: log.debug('\t', 'RSI:', rsi.result['outReal']) ;
You will need to have this include as well at the top of your strategy
var log = require('../core/log.js');
Well I really can't figure out what's wrong I tried everything, but still all seems to be good but practically it doesn't work, did I miss importing the native indicators ? Or i don't really know what's wrong ? the file is put in the Strategies directory of the gekko i'm really lost. can someone please help me try to fix this ? :(
https://gist.github.com/Pedro942/a73491ec5a00e30edf688e7bbb6e5ef7
Pedro I am sorry but I am not sure if Gekko is the tool for you:
Gekko is simply a tool that will automate your strategies (scripts), but there is a requirement that you have to write these strategies yourself in javascript. If you have trouble doing this you have the following options:
- Limit yourself to the example strategies, these work out of the box and you can tweak settings using the "strategy parameters".
- Ask (or pay) someone who can write javascript to do that for you if you now exactly what you want. Unfortunately the this issues board is not the place to ask this. This is for things related to gekko's development (bugs, updates, discussions about internals).
- If you really want to do it yourself: learn javascript.
Okay then I think you're right i have to other choice than choose between native indicators or learning js. Well I still have an issue tho i backtested a strategy with only cci and it seems like in live trading all works fine but still no trades have been made i'e setup the candle size at 16 and history at 10 wich means it needs at least 160 min to start then meet one of the conditions to buy or sell. I'm going to wait 24h if the indicators conditions have been met and still no trade happened i'm going to post the issue. Thank you for all the effort and the time you dedicated to my request and to this project. You're such a nice person. Hope that one day we will meet IRL.