Now I have created with "New" in MetaEditor 5 a EA is working well but too sensitive. I want to "reassure" the MACD signal and my new parameter "Diff = 0.000008" as installed in ctl. I tried everything possible and find no way.
What does that mean ?
Find a way to do what ? What have you tried ?
What does that mean ?
Find a way to do what ? What have you tried ?
I want to manipulate the current MACD signal with Diff.
Example:previous signal = 1 and the current signal < (1 - Diff) then short
Please where I can manipulate with "+ Diff" and "- Diff"?
I want to manipulate the current MACD signal with Diff.
Example:previous signal = 1 and the current signal < (1 - Diff) then short
Please where I can manipulate with "+ Diff" and "- Diff"?
I think you have to create you own class derived from CSignalMACD and then overload the LongCondition(void) and ShortCondition(void).
Something like :
#include <Expert\Signal\SignalMACD.mqh> class CMySignalMACD : public CSignalMACD { protected: double m_diff; // Diff public: //--- methods of setting adjustable parameters void SetDiff(double value) { m_diff=value; } } int CSignalMACD::LongCondition(void) { // In this function replace 0.0 with m_diff where appropriate int result=0; int idx =StartIndex(); //--- check direction of the main line if(DiffMain(idx)>0.0) { //--- the main line is directed upwards, and it confirms the possibility of price growth if(IS_PATTERN_USAGE(0)) result=m_pattern_0; // "confirming" signal number 0 //--- if the model 1 is used, look for a reverse of the main line if(IS_PATTERN_USAGE(1) && DiffMain(idx+1)<0.0) result=m_pattern_1; // signal number 1 //--- if the model 2 is used, look for an intersection of the main and signal line if(IS_PATTERN_USAGE(2) && State(idx)>0.0 && State(idx+1)<0.0) result=m_pattern_2; // signal number 2 //--- if the model 3 is used, look for an intersection of the main line and the zero level if(IS_PATTERN_USAGE(3) && Main(idx)>0.0 && Main(idx+1)<0.0) result=m_pattern_3; // signal number 3 //--- if the models 4 or 5 are used and the main line turned upwards below the zero level, look for divergences if((IS_PATTERN_USAGE(4) || IS_PATTERN_USAGE(5)) && Main(idx)<0.0) { //--- perform the extended analysis of the oscillator state ExtState(idx); //--- if the model 4 is used, look for the "divergence" signal if(IS_PATTERN_USAGE(4) && CompareMaps(1,1)) // 0000 0001b result=m_pattern_4; // signal number 4 //--- if the model 5 is used, look for the "double divergence" signal if(IS_PATTERN_USAGE(5) && CompareMaps(0x11,2)) // 0001 0001b return(m_pattern_5); // signal number 5 } } //--- return the result return(result); } int CMySignalMACD::LongCondition(void) { // See SignalMACD.mqh ... return(result); }and replace CSignalMACD with CMySignalMACD within your EA.
I think you have to create you own class derived from CSignalMACD and then overload the LongCondition(void) and ShortCondition(void).
Something like :
and replace CSignalMACD with CMySignalMACD within your EA.Ah ? I will try but don't expect nothing before tomorrow.
OK. Above is the complete code ...
PS: has occurred to me, after having compiled a script is displayed immediately in the new chart! Hopefully this is in the tester, too.
What are you talking about ?
BUT
If I create a new EA with MQL5 Wizard using MACD as signal, that works, it goes to CSignalMACD::LongPosition. So you have to create a new one and apply modifications I suggested above. That would work.
- 2011.01.11
- MetaQuotes Software Corp.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Example:
/*
//MACD
line := ema(price, first_period) - ema(price, second_period);
line_signal := ema(line, signal_period);
line_histogram := line - line_signal;
if positionvolume() = 0 and (line[i]-0.000008) > line[i-1] then begin
buy(lots);
end;
if positionvolume() = 0 and (line[i]+0.000008) < line[i-1] then begin
sell(lots);
end;
*/
Can anyone help?