Your speed_ac function is wrong, the if else blocks are backwards. the should look like this
void speed_ac() { double ac[]; ArrayResize(ac,5); for(int i=0; i<5; i++) ac[i]=iAC(Symbol(),tf,i); //--- index_ac=0; //--- buy signal if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3] && ac[3]>ac[4]) index_ac=4; else if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3]) index_ac=3; else if(ac[0]>ac[1] && ac[1]>ac[2]) index_ac=2; else if(ac[0]>ac[1]) index_ac=1; //-- sell signal else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3] && ac[3]<ac[4]) index_ac=-4; else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3]) index_ac=-3; else if(ac[0]<ac[1] && ac[1]<ac[2]) index_ac=-2; else if(ac[0]<ac[1]) index_ac=-1; }
well the basic idea is interesting at first
you should take a look on speed and acceleration (file in attachment)
I think you will be able to set up a better strategy than AC
Good luck
jaguar1637 from http://beathespread.com
well the basic idea is interesting at first
you should take a look on speed and acceleration (file in attachment)
I think you will be able to set up a better strategy than AC
Good luck
jaguar1637 from http://beathespread.com
Especially this part of the code:
if(StringSubstr(Symbol(),3,3)=="JPY") { MUL_SPEED=1000.0; MUL_SPEED2=1.0; } else { MUL_SPEED=1000.0; MUL_SPEED2=1.0; }
I slightly corrected your code
well the basic idea is interesting at first
you should take a look on speed and acceleration (file in attachment)
I think you will be able to set up a better strategy than AC
Good luck
jaguar1637 from http://beathespread.com
hi
Well, there is another possibility, regarding the replacement of AC, PFE , and also DPO
Your speed_ac function is wrong, the if else blocks are backwards. the should look like this
Hi,
I noticed the same error in the speed_ac function. Thanks for the hint. This error limits the return values for index_ac to 0, 1 or -1 affecting the Buy(), Sell(), Buy_close() and the Sell_close() function.
Here is my version returning the index_ac value and with the additional advantage of minimizing the number comparisons:
int speed_ac () { double ac[5]; for (int i = 0; i < 5; i++) { ac[i] = iAC (m_symbol, m_timeframe, i); } if (ac[0] > ac[1]) { if (ac[1] > ac[2] { if (ac[2] > ac[3]) { if (ac[3] > ac[4]) { return 4; } return 3; } return 2; } return 1; } if (ac[0] < ac[1]) { if (ac[1] < ac[2] { if (ac[2] < ac[3]) { if (ac[3] < ac[4]) { return -4; } return -3; } return -2; } return -1; } return 0; }
Similarly I changed the depth_trend function:
int depth_trend () { double rsi = iRSI (m_symbol, m_timeframe, m_RSI_period, PRICE_CLOSE, 0); if (rsi > 90.0) return 4; if (rsi > 80.0) return 3; if (rsi > 70.0) return 2; if (rsi > 60.0) return 1; if (rsi < 10.0) return -4; if (rsi < 20.0) return -3; if (rsi < 30.0) return -2; if (rsi < 40.0) return -1; return 0; }
The use of these function in OnTick() is the following:
void OnTick() { int index_rsi = depth_trend(); int index_ac = speed_ac(); ... }
Now I' m finishing my modifications and I'm looking forward to see test results for this good idea of Alexander.
Happy trading
Matthias
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Trading Ideas Based on Prices' Direction and Movement Speed has been published:
The article provides a review of an idea based on the analysis of prices' movement direction and their speed. We have performed its formalization in the MQL4 language presented as an expert advisor to explore viability of the strategy being under consideration. We also determine the best parameters via check, examination and optimization of an example given in the article.
Any movement in our world can be characterized by its direction, acceleration and speed. It works in liquid markets as well. This implies one important rule which says that never a one strong directed movement of the price can harshly end. It can be compared with a train: when a whole train set brakes at its full speed, its brake way can be up to one kilometer.
So when does a trend begin? When majority of market participants change their opinion to the contrary for some reasons whether it pertains to global change in direction or change in some important factors influencing on the market or news. With that a considered collective opinion is formed and the trend begins. Market participants have increasing belief that movement is becoming stronger and will go on further. It has a direction, acceleration and a certain speed because big players enter the market with large positions. This is where those, who entered at the beginning of the movement and gave it an impulse and speed, start gaining profit. Other traders enter the market later and with less attractive price. But unlike the first traders, they try to use the price movement direction.
The trend ends when changes occur. But why is the price still moving in the same way? Why doesn't it change abruptly? The reason of such behavior is that those, who were accelerating and pushing the price in the desired direction, start closing their positions and thereby suppress the trend. And those, who were just "riding the wave", still believe that nothing has changed and even try to move the price. But this "train" does not just stop. It starts moving in the opposite direction and here the story ends.
3. Enhancement of entry and exit efficiency
It is known that some trading indicators get up their speed of response to the trend change when we use a larger period. But more false signals appear as well.
The alternative way is not to change the calculation period to the lower side but to track it on several timeframes.
Fig. 3. Trend on different timeframes based on RSI and AC signals
Author: Alexander Fedosov