Cross MA-RSI

MQL4 스크립트

작업 종료됨

실행 시간 16 시간
고객의 피드백
Programmer motion helpful and professional. Recommended!!

명시

Hi, I need to correct this code. When the MA3 crosses the RSI2 from the bottom up, it must appear to the arrow. I wrote this code but it does not work. Thanks, Max.


#property indicator_chart_window
#property indicator_buffers 1

#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 clrGreen
#property indicator_label1 "Buy"

input int Period_RSI=2;
input int Period_MA=3;

//--- indicator buffers
double Buffer1[];


//+------------------------------------------------------------------+
//|                    |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   
  
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                          |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
  double RSI[];
  double MA[];
  RSI[0]= iRSI(NULL,PERIOD_CURRENT,Period_RSI,PRICE_CLOSE,0);
  MA[0]= iMA(NULL,PERIOD_CURRENT,Period_MA,0,MODE_SMA,PRICE_CLOSE,0);
  
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(300-1, rates_total-1-50)) continue; 
      //Indicator Buffer 1
      if (iMAOnArray(RSI,0,Period_MA,0,0,1)< iRSIOnArray(MA,0,Period_RSI,0)//Cross MA-RSI
      && iMAOnArray(RSI,0,Period_MA,0,0,0)>iRSIOnArray(MA,0,Period_RSI,0)
      
      )
        {
         Buffer1[i] = Low[i] - 10 *Point();
        }
      else
        {
         Buffer1[i] = 0;
        }
     
     }
   return(rates_total);
  }

응답함

1
개발자 1
등급
(885)
프로젝트
1410
67%
중재
123
32% / 41%
기한 초과
218
15%
무료
게재됨: 1 코드
2
개발자 2
등급
(590)
프로젝트
789
71%
중재
9
33% / 33%
기한 초과
22
3%
무료
게재됨: 8 코드
3
개발자 3
등급
(221)
프로젝트
412
61%
중재
13
38% / 23%
기한 초과
163
40%
무료
게재됨: 45 기고글, 1 코드
4
개발자 4
등급
(1156)
프로젝트
1462
63%
중재
21
57% / 10%
기한 초과
43
3%
무료
5
개발자 5
등급
(2313)
프로젝트
2912
63%
중재
122
44% / 25%
기한 초과
429
15%
작업중
6
개발자 6
등급
(1122)
프로젝트
1810
61%
중재
14
64% / 7%
기한 초과
84
5%
무료

프로젝트 정보

예산
10 - 15 USD
기한
에서 1  3 일