Indicator work in progress (Shows the total change in price in pips for 7 currencies over 24 hours.)

 

I hope someone may be able too help the over works quite well however it seems too use far too much data and stops MT4 from opening or at least takes 10 mins too open.

I was thinking there may be a better way of doing this may be using moving average i know i may loose some accuracy but may be worth it for speed.

Also do you see any errors in the program

Regards,

Peter

Files:
7.mq4  10 kb
 

One reason it's slow is that you get all 1000 historical Open prices every time a tick comes in.

A) the 999 'old bar' values only change one per bar, or even better ...

B) if you shuffle the array along on New Bar, you only need get the 999 old ones first time in (or don't display for first 1000 bars)

C) if you use Open price (as you are) then even the Current Bar 0 value never changes as more ticks come in.

 
brewmanz:

One reason it's slow is that you get all 1000 historical Open prices every time a tick comes in.

A) the 999 'old bar' values only change one per bar, or even better ...

B) if you shuffle the array along on New Bar, you only need get the 999 old ones first time in (or don't display for first 1000 bars)

C) if you use Open price (as you are) then even the Current Bar 0 value never changes as more ticks come in.



So is it possible to get it to only update on just the bar and not ticks because as you said it it only uses the opening price and not the tick for calculations.

Sorry I'm really not a programmer so any advice would be great.

Also it designed too work on a 5 min chart.

 
      static datetime s1BarTickTime = 0;
      bFirstTickOfBar = false;
      if(s1BarTickTime != Time[ix])
      {
         bFirstTickOfBar = true;
         s1BarTickTime = Time[ix];
      }

is one way to check for first tick of bar.

Copied straight out of my code; not checked that it's suitable for your purposes; if it helps, fine; if it blows up your computer or loses you a brazilian dollars etc, sorry no responsibility.

 

wouldnt that indicate a false first tick of new bar the first time it is run before the static datetime is set to Time[0] ?

 

ummmmm no. that 'first bar' is the oldest bar in the chart - not part way through a current bar.

Should your EA/indicator does not process any history bars, this situation is still 'the first tick received of this bar'

Reason: