Getting the index of the lowest close price for the last 30 Candles.

MQL5 전문가 컨설팅

작업 종료됨

실행 시간 28 분
피고용인의 피드백
Excellent customer and developer. Thanks.
고객의 피드백
Developer was very patient and knowledgeable will definately work with The Huy Phan again

명시

I have written an EA buy I am struggling to use ILowest within a loop.

If I print out ILowest I get the correct value. But If I iterate through a loop and increase the start position of ILowest I get different values.

Surely the logic is the same for printing it out on each new candle as it is changing the start index.

I require help to work out this logic.

Basically I want to save the previous lowest candle for the last 25 candles into an arraybased on close price.

If candle[1] is the lowest array[0] = 0

if candle[2] is also lowest array[1]=0

if candle[3] is second lowest array[2]=1 

   if(!isNewBar() && InpTradeOnNewBar)
     {
      return;
     }
       
  //Something like this can be done
  ArrayResize(buyarr,30)

  buyarr[0] = ilowest(Symbol(),Period(),Mode_close,InpLookBackPeriod,1) - 1;

  //Shift values up one

   if(CopyRates(Symbol(),Period(),0,InpLookBackPeriod,BuyRates) < InpLookBackPeriod ||
      CopyRates(Symbol(),Period(),0,InpSLookBackPeriod,SellRates) < InpSLookBackPeriod)
     {
      return;
     }

   buyrank=iLowest(Symbol(),Period(),MODE_CLOSE,InpLookBackPeriod,1) - 1;
   sellrank=iHighest(Symbol(),Period(),MODE_CLOSE,InpSLookBackPeriod,1) - 1;


   
   Print(buyrank); //this prints the correct value. I would like to save this value for the previous 25 candles

   ArrayResize(buyarr,InpLookBackPeriod);

   for(int i=0; i<InpLookBackPeriod; i++)
     {
      buyarr[i] = iLowest(Symbol(),Period(),MODE_CLOSE,InpLookBackPeriod,i+1) - 1;
     }
ArrayPrint(buyarr); // This prints out totally incorrect values.

응답함

1
개발자 1
등급
(71)
프로젝트
103
20%
중재
6
0% / 83%
기한 초과
3
3%
무료
2
개발자 2
등급
(169)
프로젝트
204
30%
중재
25
40% / 44%
기한 초과
12
6%
무료
3
개발자 3
등급
(75)
프로젝트
124
44%
중재
14
29% / 50%
기한 초과
17
14%
무료
4
개발자 4
등급
(361)
프로젝트
643
26%
중재
92
72% / 14%
기한 초과
12
2%
작업중
게재됨: 1 코드

프로젝트 정보

예산
30+ USD
기한
 1 일