-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IsEmaBullishCross Or IsEmaBearishCross Always false #53
Comments
@RikardoPons Sorry for late response. I have double checked and tested the code on IsEmaBullishCross, and it should be correct for the result. You have mentioned that you have changed the logic from the original one to your traditional one, and works. But they are different in concept, my code is determining if an "intersection point" exists when ema10 cross ema30 upwards for IsEmaBullishCross, similar for IsEmaBearishCross. But your code is determining if ema10 is larger than ema30 which includes the case of "intersect", so you may find a larger set of result when using this logic. I've also included a test case "TestBullishCrossAlwaysFalseAsync" and the verification excel for the case for the reference. Thanks. |
Thank you for your answer. I think I found a possible issue but it is not from your code. I am getting data from som Exchanges like Bittrex and Binance but I realized there are missing candles in the request sometimes. I guess this is affecting the interection when I use IsEmaBullishCross for example. |
okay. May I close the issue as it's a fixed issue? |
The issue should have fixed, but no response from @RikardoPons . Close. |
I am sorry for the late reply. I could not fix the problem. I mean when I do backtesting the method is working fine but... when I do a request to get the candles the result is always false. I am struggling with this issue now.. |
Do you mean you want to get all the candles that should fulfill a condition or not? |
I am getting the candles from the exchange trying to find a buy signal or sell signal.. If I download these candles and I do a backtesting everything is fine I can get the buy and sell signals only when I do backtesting.. If I get the candles from the exchange and I apply the algo using this method Always is false. |
May I know how you are trying to apply the algo to determine the condition in code level? It may be misuse of the method. Could you paste the code to let me test it? |
For example I want to apply this algo just it is working when I use backtesting. ` var buyRule = (ic.IsEmaBullishCross(21, 55) && ((ic.Ema(8) > ic.Ema(13)) && ic.Ema(21)> ic.Ema(55))); |
Is the Ema method declared by you? I have to confirm this first. |
Yes I did my own extension. It's forking fine. You can try just using IsEmaBullishCross and IsEmaBearishCross and I got the same result for example trying to get a buy signal and sell signal using Emas strategy 12,26 whatever always raturn false. But did some testing and your code looks fine my theory is the candles I'm requesting each period of time must be synchronized with the exchange and get the candles few seconds after the exchange update the their feed. I will try to do that. Just I'm thinking why just in backtesting your methods are working fine and they don't work when I am requesting the candles from the exchange |
Okay. I have to check it later as I am now busy with another project, I will get back to you later. |
@RikardoPons I've just checked the logic, the index you use in transaction differs the actual index by 1. The buy/sell procedure should be |
If I understand my code should be like this I will try it! Thank you! |
@RikardoPons Once you've tested ok, it would be good to help to close this issue. Thanks. |
@lppkarl thank you Now is working properly! |
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));
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(periodCount1, periodCount2).ComputeNeighbour(ic.Index)
// .IsTrue((prev, current, _) => prev.Tick.IsNegative() && current.Tick.IsPositive());
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:
// original code
var test = ic.Get(periodCount1, periodCount2).ComputeNeighbour(ic.Index)
.IsTrue((prev, current, _) => prev.Tick.IsNegative() && current.Tick.IsPositive());
// traditional way
var tema1 = ic.Get(periodCount1).Compute()[ic.Index];
var tema2 = ic.Get(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!
The text was updated successfully, but these errors were encountered: