gekko icon indicating copy to clipboard operation
gekko copied to clipboard

MACD Broken??

Open DarthNoodle opened this issue 9 years ago • 11 comments

Hi,

i am trying to run the MACD strategy and it doesnt seem to work in the UI. Also the debug output it produces is along the likes of:

2017-06-02 11:04:41 (DEBUG): calculated MACD properties for candle: 2017-06-02 11:04:41 (DEBUG): short: 0.00000373 2017-06-02 11:04:41 (DEBUG): long: 0.00000371 2017-06-02 11:04:41 (DEBUG): macd: 0.00000002 2017-06-02 11:04:41 (DEBUG): signal: 0.00000003 2017-06-02 11:04:41 (DEBUG): macdiff: -0.00000001

The settings i have are: var MACDSettings = { // EMA weight (a) // the higher the weight, the more smooth (and delayed) the line short: 26, long: 55, signal: 9, // the difference between the EMAs (to act as triggers) thresholds: { down: -0.015, up: 0.015, // How many candle intervals should a trend persist // before we consider it real? persistence: 1 } }

i am using the latest version, can you please advise?

DarthNoodle avatar Jun 02 '17 10:06 DarthNoodle

Why do you think it doesn't work? Does it error somewhere? Wrong results?

Also: Are you seeing that debug logging when running a backtest in the UI?

askmike avatar Jun 02 '17 11:06 askmike

all backtests when run through the UI dont show any logs, i have to run it through the console to see any logs being dumped out. that includes already present strategies. that output is from the stock MACD strategy i have manually stepped through the market on and the MACD and the values are different.

the goal is just to detect when the signal crosses the base line. am i doing it wrong? i thought with the stock strategy it worked but that doesn't appear to be the case :(

DarthNoodle avatar Jun 02 '17 12:06 DarthNoodle

i have to run it through the console to see any logs being dumped out.

If you configure debug to be true in your config you will see debug output.

i have manually stepped through the market on and the MACD and the values are different.

So you are manually calculating MACD? What calculations are you using?


I am pretty confident MACD is not broken, but please give some more context here:

  • Why do you think it is broken? What is different from what you were expecting?
  • What market are you running?
  • Are you running live or backtest?

I am closing this since at this point I have no reason to believe the answer to your main question MACD Broken?? is yes.

askmike avatar Jun 02 '17 12:06 askmike

But feel free to keep commenting :)

askmike avatar Jun 02 '17 12:06 askmike

debug is set to true in the config.js file:

config.debug = true; // for additional logging / debugging config.silent = false;

i am running it against SC/BTC on polo and am only using the stock MACD strategy which doesn't work on the UI and produces no output on the console.

here is some more output (when run from the console):

2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000512 2017-06-02 13:26:03 (DEBUG): long: 0.00000510 2017-06-02 13:26:03 (DEBUG): macd: 0.00000002 2017-06-02 13:26:03 (DEBUG): signal: -0.00000000 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000002 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000513 2017-06-02 13:26:03 (DEBUG): long: 0.00000511 2017-06-02 13:26:03 (DEBUG): macd: 0.00000002 2017-06-02 13:26:03 (DEBUG): signal: 0.00000000 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000002 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000515 2017-06-02 13:26:03 (DEBUG): long: 0.00000512 2017-06-02 13:26:03 (DEBUG): macd: 0.00000003 2017-06-02 13:26:03 (DEBUG): signal: 0.00000001 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000002 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000517 2017-06-02 13:26:03 (DEBUG): long: 0.00000513 2017-06-02 13:26:03 (DEBUG): macd: 0.00000004 2017-06-02 13:26:03 (DEBUG): signal: 0.00000002 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000003 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000519 2017-06-02 13:26:03 (DEBUG): long: 0.00000514 2017-06-02 13:26:03 (DEBUG): macd: 0.00000005 2017-06-02 13:26:03 (DEBUG): signal: 0.00000002 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000003 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000519 2017-06-02 13:26:03 (DEBUG): long: 0.00000514 2017-06-02 13:26:03 (DEBUG): macd: 0.00000005 2017-06-02 13:26:03 (DEBUG): signal: 0.00000003 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000002 2017-06-02 13:26:03 (DEBUG): In no trend 2017-06-02 13:26:03 (DEBUG): calculated MACD properties for candle: 2017-06-02 13:26:03 (DEBUG): short: 0.00000520 2017-06-02 13:26:03 (DEBUG): long: 0.00000515 2017-06-02 13:26:03 (DEBUG): macd: 0.00000005 2017-06-02 13:26:03 (DEBUG): signal: 0.00000003 2017-06-02 13:26:03 (DEBUG): macdiff: 0.00000002

DarthNoodle avatar Jun 02 '17 12:06 DarthNoodle

What do you mean "doesnt work" and "produces no output"? Are you looking at a white screen?

askmike avatar Jun 02 '17 12:06 askmike

it produces output to the UI, but no trades are performed. the macdiff doesnt go past 0.00000009 on 6 months worth of back data so the threasholds arnt triggered. there have been some epic swings on this coin and the MACD would have changed to the threshold point.

DarthNoodle avatar Jun 02 '17 12:06 DarthNoodle

when i run the backest in the UI it produces the summary below with a graph but no trades are made, no output is produced on the console (e.g. debug output). this holds true for all of the stock and custom strategies. The output that is displayed on the UI shows no trades were made (when using the MACD strategy).

if i want to see any kind of debug output i have to run the backtest from the console where even the stock strategies produce debug output similar to what i have shown above.

the MACD values/thresholds which the stock strategy uses to execute trades done even come close to the maccdiff numbers by an order of 6 decimal points. that lead me to believe the MACD functionality is a little skewif.

does that explain it better?

DarthNoodle avatar Jun 02 '17 13:06 DarthNoodle

Ah! I understand now, sorry about that.

What is happening is that you are trading an asset with a very low price: around 0.00000392. This means that difference between the two EMAs (within the MACD indicator) are always very small. So whatever happens to the price, the thresholds are not likely to get hit. So Gekko works, MACD works but you need to configure the thresholds a lot lower if you want them to get hit:

[thresholds]
down = -0.025 # <--- lower this one
up = 0.025 # <--- lower this one
persistence = 1

Keep in mind that Gekko is extremely bad in simulating low volume markets, read here for details on common gotchas.


Note that Gekko is a toolbox that will automate the strategy you program or configure, if you don't see any trades that simply means your strategy (as per your configuration) did not signal any trades.

askmike avatar Jun 02 '17 13:06 askmike

What would be an example of the lowered thresholds? Is there a common one that people typically use for alt coins using BTC currency

bvanhou avatar Apr 14 '18 22:04 bvanhou

Use ppo it's the same thing as macd as far as your computer is concerned. If you chart the data the lines and crossovers are the exact same as macd only it is price percentage instead of price. This means you wouldn't have to have individual thresholds for each market and instead focus on writing good strategy that can make use of the same thresholds on all markets

generalectric avatar Apr 14 '18 23:04 generalectric