查找最近的日期 - 页 2

 
angevoyageur:

类似这样的事情?

只是其中的一个解决方案。

有一些问题......我只能在tick数据上使用它,否则前一个最高点总是=1。

但主要的问题是,在tick数据上,有时会无缘无故地将前一个最高点变为=1。

再次感谢您的支持

文档

 
dr.house7:

有一些问题......我只能在tick数据上使用它,否则前一个最高点总是=1。

但主要的问题是,在tick数据上,有时会无缘无故地将前一个最高点变为=1。

再次感谢您的支持

文档

如果你能展示你所使用的代码,我才能提供帮助。
 
angevoyageur:
只有当你展示你所使用的代码时,我才能提供帮助。

是这样就够了还是需要整个代码?

谢谢Ange的支持...

文档

int checkEntry()
  {
  datetime lastdealtime;
  HistorySelect(0, TimeCurrent());  
  lastdealtime = HistoryDealGetInteger(HistoryDealGetTicket(HistoryDealsTotal()-1),DEAL_TIME);
  //Print("lastdealtime :",lastdealtime);
  
//--- time filter
   if(!checkTimeLimits()) return(_doNothing);

double ema1[2],
       ema2[2];
       
       //

//-- get current Spread
   int spread=int(SymbolInfoInteger(_Symbol,SYMBOL_SPREAD));

//-- Get indicator and timeserie data
  if(CopyBuffer(handle_ema1,0,0,2,ema1)           !=2  ||
  if(CopyBuffer(handle_ema2,0,0,2,ema2)           !=2  ||
                
     
     CopyHigh(_Symbol,_Period,0,2,high)!=2          || 
      CopyLow(_Symbol,_Period,0,2,low)!=2 
     
     ) return(_doNothing);
//-------
MqlDateTime currentTime; TimeCurrent(currentTime);

TouchTime=TimeCurrent();

if(ema1[1] > ema2[1] && ema1[0]< ema2[0]) 
           {
           if(TouchTime != emacross1_TouchTime) 
           {
           drawArrow1(TouchTime,ema1,"Wingdings 3",ArrowSize,"p",ArrowColor); 
           emacross1_TouchTime= TouchTime;
           
           }
        
      
          } 
int touchedline[10];
int temp = 0;
int valuearray = 0;

touchedline[0]=emacross1_TouchTime;
touchedline[1]=emacross2_TouchTime;
touchedline[2]=emacross3_TouchTime;
touchedline[3]=emacross4_TouchTime;
touchedline[4]=emacross5_TouchTime;
touchedline[5]=emacross6_TouchTime;
touchedline[6]=emacross7_TouchTime;
touchedline[7]=emacross8_TouchTime;
touchedline[8]=emacross9_TouchTime;
touchedline[9]=emacross10_TouchTime;


int highest=-1, previoushighest=-1;

   for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         previoushighest=highest;
         highest=i;
         temp=touchedline[i];
        }
     }
     
Print("act_highest :",highest);
Print("prv_highest :",previoushighest);
 
dr.house7:

是这样就够了还是需要整个代码?

谢谢Ange的支持...

文档

是的, 现在意识到 如果 最高值是touchedline[0],我的 建议 不起作用所以在这种情况下,你必须找到其他方法,例如使用ArrayMaximum()
 
angevoyageur:
是的。 现在意识到 如果 最高值是touchedline[0],我的建议不起作用 。所以在这种情况下,你必须找到其他方法,例如使用ArrayMaximum()

你好,Ange。

我已经尽力了,但我认为这有点复杂......我写了这个,但没有用,有什么建议吗? 谢谢

int index_max;

for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         index_max=ArrayMaximum(touchedline[i],0,WHOLE_ARRAY); // maximum in High
         temp=touchedline[i];         
        }
     }
 
dr.house7:

你好,Ange。

我已经尽力了,但我认为这有点复杂......我写了这个,但没有用,有什么建议吗? 谢谢

   int highest=-1,previoushighest=-1;

   for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         previoushighest=highest;
         highest=i;
         temp=touchedline[i];
        }
     }     
   if(previoushighest==-1) previoushighest=ArrayMaximum(touchedline,1,WHOLE_ARRAY);

   Print("act_highest :",highest);
   Print("prv_highest :",previoushighest);
没有时间测试,我也不认为这是最好的解决方案。但我认为它应该是有效的。
 
angevoyageur:
没有时间去测试,我也不假装这是最好的解决方案。但我认为它应该是有效的。
我试过了,但现在以前的和现在的大部分时间都给我同样的结果
 
dr.house7:
我试过了,但现在以前的和现在的大部分时间都给我同样的结果。
对不起,我没有时间,在这种情况下试图提供帮助不是一个好主意。 在浪费 你的时间。
 
angevoyageur:
对不起,我没有时间,在这种情况下试图提供帮助并不是一个好主意。 在浪费 你的时间。
总之,谢谢你
 
angevoyageur:
对不起,我没有时间,在 这种情况 下试图提供帮助不是一个好主意。 在浪费 你的时间。

对不起,你说的 "这些情况 "是什么意思?