Disliked{quote} - use the </> button to paste in code lines - the i parameter isn't being used in getKalmanValue() - instead of checking color line buffers, which paint the previous candle too and can cause issues, just compare the current line value to the previous line value to get the slope - can keep everything in one spot, like- int get_signal(int i) { //0=none, 1=up, -1=down int signal = 0; //get values of current and previous //use buffer that is the neutral, not for coloring double val_0 = iCustom(...,i); double val_1 = iCustom(...i+1); //compare...Ignored
I used the code you have given me with this new code, im experiencing the same issue. I uploaded a screenshot. I am not sure what the error is, because its generating false signals in the middle of the Kalman now. Pasting the code that i used.
I'll link my Exit indicator, it's basically the same as the Kalman with color changing. Thats why I used GetKalmanIndicatorValue, but it didnt seem to work so maybe my logic was wrong.
//-------------------------------------------------------------------------------Exit indicator function (reference) -------------------------------------------------------------------
bool check_Exit_Indicator_Buy(int i)
{
if (!Use_Exit_Ind)
{
return true;
}
double val_up = getExitIndicatorValue(0, i);
double val_dn = getExitIndicatorValue(1, i);
return val_up != EMPTY_VALUE && val_dn == EMPTY_VALUE;
}
bool check_Exit_Indicator_Sell(int i)
{
if (!Use_Exit_Ind)
{
return true;
}
double val_up = getExitIndicatorValue(0, i);
double val_dn = getExitIndicatorValue(1, i);
return val_up == EMPTY_VALUE && val_dn != EMPTY_VALUE;
}
//-------------------------------------------------------------------------------- Kalman indicator -----------------------------------------------------------------------------
int get_signal(int i)
{
//0=none, 1=up, -1=down
int signal = 0;
if (check_Kalman_Buy(i))
{
signal = 1;
}
else if (check_Kalman_Sell(i))
{
signal = -1;
}
return signal;
}
bool check_Kalman_Buy(int i)
{
if (!Use_Kalman)
{
return false;
}
double val_0 = iCustom(_Symbol, _Period, "Kalman", Mode, K, Sharpness, i, 1);
double val_1 = iCustom(_Symbol, _Period, "Kalman", Mode, K, Sharpness, i, 0);
if (val_1 > val_0)
{
return true;
}
return false;
}
bool check_Kalman_Sell(int i)
{
if (!Use_Kalman)
{
return false;
}
double val_0 = iCustom(_Symbol, _Period, "Kalman", Mode, K, Sharpness, i, 1);
double val_1 = iCustom(_Symbol, _Period, "Kalman", Mode, K, Sharpness, i, 0);
if (val_1 < val_0)
{
return true;
}
return false;
}
Attached File(s)