kwang1:
The solution should be : double CExpertSignal::Direction() -> double CExpertSignal::Direction(double& base_price) and int CSignalMA::LongCondition() -> int CSignalMA::LongCondition(double& base_price)
Is it correct???
Files:
ExpertSignal.mqh
26 kb
SignalStoch.mqh
23 kb
kwang1:
//+------------------------------------------------------------------+ //| Generating a buy signal. | //| INPUT: price - reference for placing the price of opening, | //| sl - reference for placing the stop loss price, | //| tp - reference for the take profit price, | //| expiration - reference for placing the expiration time. | //| OUTPUT: true if there is a signal, otherwise - false. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CExpertSignal::CheckOpenLong(double& price,double& sl,double& tp,datetime& expiration) { bool result =false; double direction=Direction(m_base_price); printf("1111,%f",m_base_price); //--- the "prohibition" signal if(direction==EMPTY_VALUE) return(false); //--- check of exceeding the threshold value if(direction>=m_threshold_open) { //--- there's a signal result=true; //--- try to get the levels of opening if(!OpenLongParams(price,sl,tp,expiration)) result=false; } //--- zeroize the base price m_base_price=0.0; //--- return the result return(result); }
//+------------------------------------------------------------------+ //| Detecting the "weighted" direction. | //| INPUT: no. | //| OUTPUT: >0 - if the probability of price growth is greater, | //| =0 - if the direction is not determined | //| (small probability), | //| <0 - if the probability of price falling is greater. | //| REMARK: no. | //+------------------------------------------------------------------+ double CExpertSignal::Direction(double& price) { CExpertSignal *filter; long mask; double direction; double result=m_weight*(LongCondition(price)-ShortCondition(price)); int number=0; // number of "voted" //--- int total=m_filters.Total(); //--- for debugging //printf(__FUNCTION__+" : %s %d",EnumToString(m_period),total); //--- loop by filters for(int i=0;i<total;i++) { //--- mask for bit maps mask=((long)1)<<i; //--- check of the flag of ignoring the signal of filter if((m_ignore&mask)!=0) continue; filter=m_filters.At(i); direction=filter.Direction(price); //--- the "prohibition" signal if(direction==EMPTY_VALUE) return(EMPTY_VALUE); //--- check of flag of inverting the signal of filter if((m_invert&mask)!=0) result-=direction; else result+=direction; number++; } //--- normalization if(number!=0) result/=number; //--- return the result return(result); } //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| "Voting" that price will fall. | //| INPUT: no. | //| OUTPUT: number of "votes" that price will fall. | //| REMARK: no. | //+------------------------------------------------------------------+ int CSignalStoch::ShortCondition(double& price) { int result=0; int idx =StartIndex(); //--- check direction of the main line if(DiffMain(idx)<0.0) { //--- main line is directed downwards, confirming a possibility of falling of price 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) && DiffMainSignal(idx)<0.0 && DiffMainSignal(idx+1)>0.0) result=m_pattern_2; // signal number 2 //--- if the models 3 or 4 are used, look for divergences if((IS_PATTERN_USAGE(3) || IS_PATTERN_USAGE(4))) { //--- perform the extended analysis of the oscillator state ExtStateStoch(idx); //--- if the model 3 is used, look for the "divergence" signal if(IS_PATTERN_USAGE(3) && CompareMaps(1,1)) // 0000 0001b result=m_pattern_3; // signal number 3 //--- if the model 4 is used, look for the "double divergence" signal if(IS_PATTERN_USAGE(4) && CompareMaps(0x11,2)) // 0001 0001b return(m_pattern_4); // signal number 4 } } price=20; //--- return the result return(result); }
kwang1:
Everything was done as planned.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register