Hi Guys,
Just checked the source code about the "always trend is up" issue.
We can find a code segment at line 1359
//+-----------------------------------------------------------------+
//| Calculation of Trend Direction |
//+-----------------------------------------------------------------+
double ima_0 = iMA(Symbol(), 0, MAPeriod, 0, MODE_EMA, PRICE_CLOSE, 0);
if (ForceMarketCond_ == 3) {
if (BID > ima_0 + MADistance_)
{
Trend = 0;
}
else if (ASK < ima_0 - MADistance_)
{
Print("Print Trend Set to 1");
Trend = 1;
}
else
Trend = 2;
}....
The variable “Trend” will decide what kind of trend information to display on the screen, which has been defined and set to default value to 0 (means up trend) at the beginning of the method start(). However the logic to for calculating real-time trending was included in a "if" block checked by OncePerBar(). That's why the correct trend state just shown at beginning and reset to default up trend in a second.
IMO, The Solution is pretty simple, just move the code out of if block is or remove the reinitialize code at the beginning of start() method. At last, this is just a quick glance at the code regrading the issue. Still need confirmation from Richard for the update.
Just checked the source code about the "always trend is up" issue.
We can find a code segment at line 1359
//+-----------------------------------------------------------------+
//| Calculation of Trend Direction |
//+-----------------------------------------------------------------+
double ima_0 = iMA(Symbol(), 0, MAPeriod, 0, MODE_EMA, PRICE_CLOSE, 0);
if (ForceMarketCond_ == 3) {
if (BID > ima_0 + MADistance_)
{
Trend = 0;
}
else if (ASK < ima_0 - MADistance_)
{
Print("Print Trend Set to 1");
Trend = 1;
}
else
Trend = 2;
}....
The variable “Trend” will decide what kind of trend information to display on the screen, which has been defined and set to default value to 0 (means up trend) at the beginning of the method start(). However the logic to for calculating real-time trending was included in a "if" block checked by OncePerBar(). That's why the correct trend state just shown at beginning and reset to default up trend in a second.
IMO, The Solution is pretty simple, just move the code out of if block is or remove the reinitialize code at the beginning of start() method. At last, this is just a quick glance at the code regrading the issue. Still need confirmation from Richard for the update.
1