Can I have an indicator refresh by time not by tick? - page 2

 
Propaganda:

Thanks everybody, I can now resume programming.


For some reason I though looping an indicator would drag down the system... well I guess not so much for a quadcore 2.4Ghz. My thinking was aligned with programing PICmicro MCUs, those little guys are standerd at 8Mhz and timing sensitive applications must be coded with that limitation in mind.

Can you post the framework of the start() function to show the loop code that you've got to work as required? Extract any sensitive stuff you don't want us to see of course.

Appreciated.


CB

 

Nothing works. Everything freezes MT4. I will just run it as an EA so I can debug the program. The codes needs to be refreshed because it has user inputs unlike something along the lines of MACD or ZIGZAG


*edit*

 
Propaganda:

Nothing works. Everything freezes MT4. I will just run it as an EA so I can debug the program. The codes needs to be refreshed because it has user inputs unlike something along the lines of MACD or ZIGZAG


*edit*

Thats why I asked ErrorProgrammer to try it out.


CB

 
Propaganda wrote >>

Nothing works. Everything freezes MT4. I will just run it as an EA so I can debug the program. The codes needs to be refreshed because it has user inputs unlike something along the lines of MACD or ZIGZAG

*edit*

So the problem is, i think, that we need to stop it checking everytime it can check...I assume u tried the last one of my suggestions...but then I wonder why it doesn't freeze checking on the IndicatorCounted function.

we need to get it out the loop.

Give me the source code and I will have a look...I am a beginner though, learning quickly but still a beginner

 

Hi Guys

I would approach the problem slightly differently by leaving the indicator as normal and adding a supervisory piece of code that decides on every tick if the algorithm times is right to run. If no ticks come for a long period it would mean on the first new tick that the indicator algorithm would be executed as many times as the number of time periods that have expired since the last tick. Lets face it I don't think anybody would be trading if there are no ticks so it won't matter if the code doesn't run in real time during no tick periods. Do you grasp what I'm suggesting?

 

Yeah...that was kind of my approach...I've made up an Example with the RSI provided in the basic Custom indis coming with MetaTrader.

You need to compile it though because it tells me within the while(i>=1 && ...) that I use an illegal assignement.#

Maybe I'm missing something or my MetaTrader is going crazy which I don't think so.

 

A late nite typo... ;)

while(i>=0 && TimeCurrent()%Refreshingrates=0) //Added the "Refresher" here

c/=0/==0/

 

thanks fbj, actually it wasn't a late night typo, sadly - I just forgot the assignment issue because I had to do with mathematics before...

So basically my idea works...but the problem still is, that we:

  • need to calculate the indi through once before we let it have selecting its "refreshments"
  • need to make shure that it recalculates even when the given period is not hit, but hit for example one tick earlier(because TimeCurrent is just updated with every incoming tick)
  • we have to say, that it is impossible for the indicator to recaculate in a period less than a second...in my opinion...Sorry!

Attached is the version of the Refreshing RSI :D

Files:
Reason: