question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IsEmaBullishCross Or IsEmaBearishCross Always false

See original GitHub issue

Hello I am trying to figure out how to know if the Ema is Bullish or Bearish.

I did a backtesting using IsEmaBullishCross and IsEmaBearishCross and they are working fine

` var buyRule = Rule.Create(ic => ic.IsEmaBullishCross(21, 55)); var sellRule = Rule.Create(ic => ic.IsEmaBearishCross(21, 55));

        var runner = new Trady.Analysis.Backtest.Builder()
            .Add(candles)
            .Buy(buyRule)
            .Sell(sellRule)`

The problem is when I am trying to get the buy signal and sell signal from the exchange always is False.

I am using the IndexedCandle like this:

` var ic = new IndexedCandle(candles, candles.Count - 1); var buyRule =(ic => ic.IsEmaBullishCross(21, 55)); var sellRule = (ic => ic.IsEmaBearishCross(21, 55));

`

Maybe I am doing something wrong.

I would appreciate some help.

I did my own testing and I found something very interesting I implemented my own indicator called TemaIndicator I followed the examples and I did thisd

//public static bool IsTemaBullishCross(this IIndexedOhlcv ic, int periodCount1, int periodCount2) // => ic.Get<ExponentialMovingAverageOscillator>(periodCount1, periodCount2).ComputeNeighbour(ic.Index) // .IsTrue((prev, current, _) => prev.Tick.IsNegative() && current.Tick.IsPositive());

    //public static bool IsTemaBearishCross(this IIndexedOhlcv ic, int periodCount1, int periodCount2)
    //    => ic.Get<TemaIndicatorOcillator>(periodCount1, periodCount2).ComputeNeighbour(ic.Index)
    //         .IsTrue((prev, current, _) => prev.Tick.IsPositive() && current.Tick.IsNegative());

Same as many extensions when I use them with back testing is working fine but with real data never always they return false like macd crossing, emabearishcross, emabullishcross etc…

I modified this extension like this:

public static bool IsTemaBullishCross(this IIndexedOhlcv ic, int periodCount1, int periodCount2)
    {

// original code var test = ic.Get<ExponentialMovingAverageOscillator>(periodCount1, periodCount2).ComputeNeighbour(ic.Index) .IsTrue((prev, current, _) => prev.Tick.IsNegative() && current.Tick.IsPositive());

// traditional way var tema1 = ic.Get<TemaIndicator>(periodCount1).Compute()[ic.Index]; var tema2 = ic.Get<TemaIndicator>(periodCount2).Compute()[ic.Index]; if (tema1.Tick.Value > tema2.Tick.Value) { return true; } else { return false; }

    }

and finally the cross was fired …

there is a bug with the extensions.

I would like to help to fix the problem but for now is the only way I found to fix them.

Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
RickPonscommented, Sep 14, 2018

@lppkarl thank you Now is working properly!

0reactions
karlwanclcommented, Sep 13, 2018

@RikardoPons Once you’ve tested ok, it would be good to help to close this issue. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IsEmaBullishCross Or IsEmaBearishCross Always false · Issue #53
Hello I am trying to figure out how to know if the Ema is Bullish or Bearish. I did a backtesting using IsEmaBullishCross...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found