Future highs in backtesting - page 2

 

Ok but Im asking how to get the ihighest which means the highest price of 40 bars in the future but I have to do something like this.

 for(int i=Future-1; i>=0;i--)
{

iB=iB-K;

H=iHigh(NULL, pTF,iHighest( NULL,pTF, MODE_HIGH, K, iB) );
L=iLow(NULL, pTF,iLowest( NULL,pTF, MODE_LOW, K, iB));

if(fhval == 0)fhval = H;
else if(H > fhval)fhval = H;

if(flval == 0)flval = L;
else if(L < flval)flval = L;

}


and its not working for me. I want to get a better solution than this. Thats what Im asking. I just want the highest value on future bars with ihighest? Is that possible and how?

 
 
      int time = Time[0]+40*Period()*60;  // 40 bars in future
      int iB=iBarShift(NULL,NULL, time);

      double fhval=High[iHighest(NULL,0,MODE_HIGH,40,iB)];
      double flval=Low[iLowest(NULL,0,MODE_LOW,40,iB)];
        

Look I want something like this please?

40 bars in the future and the ihighest of that. And I just want this please..

The above I need to figure out the iBarShift and what bar it is. The above is not working.

 

So my question I can actually ask something different like. Can you help me correct iBarshift so that I can find the future bar number 40 bars in the future?

Can you help me with that please?

 
bonechair:

So my question I can actually ask something different like. Can you help me correct iBarshit so that I can find the future bar number 40 bars in the future?

Can you help me with that please?


https://docs.mql4.com/series/ibarshift

iBarShift will return -1 if there is no data available.

There is sample code on the above page which explains how to use it.

 
CodeMonkey:


https://docs.mql4.com/series/ibarshift

iBarShift will return -1 if there is no data available.

There is sample code on the above page which explans how to use it.

Perhaps you should have read the whole thread . . .
 
RaptorUK:
Perhaps you should have read the whole thread . . .

1. You cannot use it to predict the future.


2. The original poster hasn't bother to post any debug information.


3. A simple query to ibarshift will tell him if the response is -1. If that is the case then there is no data available, and he cannot use it in the manner he intended.

 
CodeMonkey:
1. You cannot use it to predict the future.
Actually you can . . . make a copy of the symbol in question to an offline chart with a modified symbol name, now iBarshift() can be used from the Strategy Tester on the modified symbol to get information on bars in the future . . . the OP's issue is that he/she doesn't want to make any effort to solve his/her issue, he/she wants a two line code solution.
 

I just want to get this working on something Im working on.

datetime GetTime(int iBar){

  return( Time[0] + iBar * Period() * 60 );

}

      int iB=iBarShift(Symbol(),Period(), GetTime(Future));  //Future = 40bars

I tried this one to get future time in strategy testing but Im getting zero on iB.

Anybody got a solution with src code please? It cant be that hard can it? I looked everywhere today for simple solution.

 
bonechair:

I just want to get this working on something Im working on.

I tried this one to get future time in strategy testing but Im getting zero on iB.

The Strategy Tester can only see as far forward as the current tick on the symbol it has created in the .fxt file.
Reason: