The code you posted will calculate ALL values of ALL candles/periods on each tick.
You need to limit your for-loop to only calculate the most current period, after all periods ha e been calculated ONCE.
Read the docs on how to use OnCalculate and take a look at how the sample codes of indicators provided with MT5 do it.
You are doing it wrong at the moment.
Thank youDominik Egert #:
It makes sense. Will work on it. Thank you
The code you posted will calculate ALL values of ALL candles/periods on each tick.
You need to limit your for-loop to only calculate the most current period, after all periods ha e been calculated ONCE.
Read the docs on how to use OnCalculate and take a look at how the sample codes of indicators provided with MT5 do it.
You are doing it wrong at the moment.
for (int i=0; i<Bars; i++)
Do your lookbacks correctly #9 — #14 & #19
.
Awesome! Thank you sir!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Every time when the market get volatile my computer get freeze. I know, maybe I running more indicators than I need but as I'm learning I need them.
On my indicators I use basically this format to plot them.
I believe my computer get freeze because it calculates on every tick, and on times of high volumes there is a lot of activity every tck.
If Am I right, is there a way to limit the number of interactions, lets say like limit to one or two every second?
O there is a way to code to avoid this?
Thank you
PD. Sorry, I think this belong to the indicators threads but couldn't find the way to move it.