Hi,
I've made some changes to the code in the trendDirect function and it seems to work properly now.
Here is the modified trendDirect function. Just replace the entire function with this if you want.
Code: Select all
bool trendDirect(string symbol, int type)
{
double mA = iMA(symbol, PERIOD_H4, 240, 0, MODE_LWMA, PRICE_OPEN, 0);
double aO = GetAo(symbol, PERIOD_H4, 0);
double sT = iStochastic(symbol, PERIOD_H4, 5, 3, 3, MODE_LWMA, 1, MODE_SIGNAL, 0);
double lO = iLow(symbol, PERIOD_H4, 0);
double hO = iHigh(symbol, PERIOD_H4, 0);
double gRSI = GetSlopeRSI(symbol, PERIOD_H4, 0);
if (!UseRSIInsteadOfStoch)
{
if (type == OP_BUY)
{
if (useBothForPullback)
{
if (lO > mA && sT < 20 && aO < 0)
return(true);
}
else
if (lO > mA && sT < 20) // || aO < 0)
return(true);
}
if (type == OP_SELL)
{
if (useBothForPullback)
{
if (hO < mA && sT > 80 && aO > 0)
return(true);
}
else
if (hO < mA && sT > 80) // || aO > 0)
return(true);
}
}
if (UseRSIInsteadOfStoch)
{
if (type == OP_BUY)
{
if (useBothForPullback)
{
if (lO > mA && gRSI < RSITMAlowlevel && aO < 0)
return(true);
}
else if (lO > mA && gRSI < RSITMAlowlevel) // || aO < 0)
return(true);
}
if (type == OP_SELL)
{
if (useBothForPullback)
{
if (hO < mA && gRSI > RSITMAhighlevel && aO > 0)
return(true);
}
else if (hO < mA && gRSI > RSITMAhighlevel) // || aO > 0)
return(true);
}
}
return(false);
}