Download MetaTrader 5

am i doing this right? Used ArrayCopySeries to bring highs/lows to my entry TF, now I need to get iLowest shift from higher TF

To add comments, please log in or register
Brian Kester
823
Brian Kester  

Can anyone just please verify i am on the right track  before i go further-- 

used ArrayCopySeries  to bring the higher timeframe bar data into my lower time frame.

now i want to run iLowest on that data, but i think that will return the current TF bar shift, but i need to find that higher TF bar shift. 

Do I need to make my own function to get iLowest and iHighest from that higher TF bar data while the current chart is on the lower TF?

I think thats what i have to do, but thought i would check with my gurus first since ArrayCopySeries  is new to me. Thanks ahead of time.

whroeder1
15917
whroeder1  
  1. "I used ArrayCopySeries " Why? Are you using the data?
  2. iLowest runs on a chart not an array. You can't "run iLowest on that data".
  3. Perhaps you should read the manual. Either iLowest on the chart or ArrayMinimum - Array Functions - MQL4 Reference on the array.
  4. Perhaps you should read the manual. Why do you think you "need to make your own function" to get the lowest and highest?
whroeder1
15917
whroeder1  
Brian Kester: 4. I have never used  ArrayMinimum before and new to arrays in general. I know what iLowest and iHighest does and know that could work except that it returns the bar shift of the current timeframe, not the higher TF. 
Wrong. It returns the shift of what ever TF you are looking at.
Brian Kester
823
Brian Kester  
whroeder1:
Wrong. It returns the shift of what ever TF you are looking at.

understood (I think)>>>   ChartPeriod()   vs   selected Period() 

Brian Kester
823
Brian Kester  


After working with it, Array Minimum helps some things for me, but only helps to find the low when you know the range to search. I may have approached my question here a bit poorly. Please try again to help me understand if I'm doing this the best way.

ArrayMinimum doesnt help to increase the speed of identifying the next low when its 100,000+ bars back or more. 

I need the next lower low, but if its 100,000+ bars back, my question is do I have to do a 'for' loop for 100,000+ iterations just to get the next low? I am starting to think that's just how I have to do it.

for example: 

to find the next lower low (lets say its 100,584 bars back) 

with a "for" loop-

is Low[2] < Low[1] ?  no. check next bar.

is Low[3] < Low[1] ?  no.  check next bar.

is Low[4] < Low[1] ?  no.  check next bar.

...next

...next

etc... 

... 100,000+ iterations later....

.. is Low[100,584] < Low[1]  YES. The next lower low after Low[1] is Low[100,584].

 

Do i have to go through all these iterations to get this "next low shift"? Or is there some faster way than im doing it? 


Keith Watford
Moderator
10651
Keith Watford  

     double last_bar_low=Low[1];
     for (int i=2;i<Bars;i++)
       {
       if(Low[i]<last_bar_low)
          {
          Print("The next lowest bar is ",i,". Low is ",Low[i]);
          break;
          }
       }
.
Brian Kester
823
Brian Kester  
Keith Watford:

     double last_bar_low=Low[1];
     for (int i=2;i<Bars;i++)
       {
       if(Low[i]<last_bar_low)
          {
          Print("The next lowest bar is ",i,". Low is ",Low[i]);
          break;
          }
       }
.

is there a way to know how fast does MT4 does 100,000 iterations of the loop? any idea?

 

I though of one way to check faster- you check next month candle that is lower, then check next week, then next day, h4, h1,30,5, and finally (in less than 100,000 loops) you get that next lower M1 candle 100,000 candles back.

it takes several  loops but faster than 100,000+ iterations  on the M1 right? 

 

i think this solves it unless anyone knows a faster way. 

Mladen Rakic
61868
Mladen Rakic  
Brian Kester:

After working with it, Array Minimum helps some things for me, but only helps to find the low when you know the range to search. I may have approached my question here a bit poorly. Please try again to help me understand if I'm doing this the best way.

ArrayMinimum doesnt help to increase the speed of identifying the next low when its 100,000+ bars back or more. 

I need the next lower low, but if its 100,000+ bars back, my question is do I have to do a 'for' loop for 100,000+ iterations just to get the next low? I am starting to think that's just how I have to do it.

for example: 

to find the next lower low (lets say its 100,584 bars back) 

with a "for" loop-

is Low[2] < Low[1] ?  no. check next bar.

is Low[3] < Low[1] ?  no.  check next bar.

is Low[4] < Low[1] ?  no.  check next bar.

...next

...next

etc... 

... 100,000+ iterations later....

.. is Low[100,584] < Low[1]  YES. The next lower low after Low[1] is Low[100,584].

 

Do i have to go through all these iterations to get this "next low shift"? Or is there some faster way than im doing it? 


If you want the lowest low (or whatever extreme) for the whole series, why don't you save the current lowest low so far in a buffer and that way you have to check only one value?

Other than that, looping over 100.000 items will not be fast in any coding language - try changing your logic

Keith Watford
Moderator
10651
Keith Watford  
Brian Kester:

is there a way to know how fast does MT4 does 100,000 iterations of the loop? any idea?

 

I though of one way to check faster- you check next month candle that is lower, then check next week, then next day, h4, h1,30,5, and finally (in less than 100,000 loops) you get that next lower M1 candle 100,000 candles back.

it takes several  loops but faster than 100,000+ iterations  on the M1 right?

To see how long it takes


     uint  first_count=GetTickCount();
     //your loop
     uint  time_in_milliseconds=GetTickCount()-first_count;


I would think that it would be very rare that you would need to loop through 100,000 bars to find the most recent lower low. In my example, the break takes you out of the loop as soon as the low is found.

Also, you would only need to do it once per bar.

Keith Watford
Moderator
10651
Keith Watford  
Mladen Rakic:

If you want the lowest low (or whatever extreme) for the whole series, why don't you save the current lowest low so far in a buffer and that way you have to check only one value?

Other than that, looping over 100.000 items will not be fast in any coding language - try changing your logic

Unless I have misunderstood, the OP wants to find the most recent lower low, not the lowest.

I need the next lower low, but if its 100,000+ bars back, my question is do I have to do a 'for' loop for 100,000+ iterations just to get the next low? I am starting to think that's just how I have to do it.


To add comments, please log in or register