Not finding my answer, i resorted to MSU (Making Sh!t Up) and coded a really crude version of trend ID. Funnily enough, it seems to be working pretty well (although no perfect).
Basically, I took a 240MA (user adjustable), took three samples of it and compared the values. Code looks like this (please hold the laughter...):
Code: Select all
string trendMA(int shift)
{
double oldMA, olderMA, newMA;
string MATrend = "No trend";
newMA = iMA(NULL, TradingTimeFrame, MAPeriod, shift, MODE_LWMA, PRICE_OPEN, shift);
oldMA = iMA(NULL, TradingTimeFrame, MAPeriod, shift, MODE_LWMA, PRICE_OPEN, 10);
olderMA = iMA(NULL, TradingTimeFrame, MAPeriod, shift, MODE_LWMA, PRICE_OPEN, 24);
if(newMA < oldMA)
{
if (oldMA < olderMA) MATrend = "Down";
}
if(newMA > oldMA)
{
if (oldMA > olderMA) MATrend = "Up";
}
return(MATrend);
}The other issue I have is that I've put in a max order limit for my EA which simply gets OrdersTotal() which is assigned to a variable, and compares it to a user input. This is one of two (one for long, one for short):
Code: Select all
if (currentOrders >= maxTrades)
{
Alert("sell signal received, max trades in place... trade skipped!");
SendShort = false;
} Thanks in advance to the coding gurus for any help provided.