Yes I can do so. Its too long for adding it here (>64.000 characters).
I will attach it as file.
Yes I can do so. Its too long for adding it here (>64.000 characters).
I will attach it as file.
Indicator code CANNOT have *.txt* extension
Please attach the correct file.
Indicator code CANNOT have *.txt* extension
Please attach the correct file.
This is not the whole indicator. It is just the OnCalc code.
This is not the whole indicator. It is just the OnCalc code.
We still do not understand: do you have an old code or MQL5?
We still do not understand: do you have an old code or MQL5?
This is written in MQL5.
Edit: Sorry for confusion. Yes its MQL4 codeThis is written in MQL5.
This is an old code (let me remind you that in MQL5 the indicator handle is CREATED ONCE and it is done in OnInit).
I will move your topic to the section for the old terminal.
-
iMA(NULL,CS_TIMEFRAME, …
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20 Your code if((iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx)>iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+1)) && (iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+1)>iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+2)) && (iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+2)>iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+3))) { Up=true; } else { Up=false; } // Market Trend Down if((iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx)<iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+1)) && (iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+1)<iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+2)) && (iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+2)<iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+3))) { Down=true; } else { Down=false; }
Don't dupicate (copy and paste) function calls. double MA0=iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx); double MA1=iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+1); double MA2=iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+2); double MA3=iMA(NULL,CS_TIMEFRAME,5,0,MODE_EMA,PRICE_CLOSE,_barShiftx+3); if((MA0>MA1) && (MA1>MA2) && (MA2>MA3) { Up=true; } else { Up=false; } if((MA0<MA1) && (MA1<MA2) && (MA2<MA3) { Down=true; } else { Down=false; }
Simplify your code. Up = MA0>MA1 && MA1>MA2 && MA2>MA3; Down = MA0<MA1 && MA1<MA2 && MA2<MA3;
Increase Order after stoploss - MQL4 programming forum #1.3 2017.05.29-
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int i = MathMax(barsToCount,FiboBars); while (i >= 0)
You are computing the max every tick. After the first tick you should only be computing bar zero of the current timeframe, and bar zero of other timeframes.
See How to do your lookbacks correctly #9 … #14 & #19.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20 Your code Don't dupicate (copy and paste) function calls. Simplify your code. Increase Order after stoploss - MQL4 programming forum #1.3 2017.05.29 - You are computing the max every tick. After the first tick you should only be computing bar zero of the current timeframe, and bar zero of other timeframes.
See How to do your lookbacks correctly #9 … #14 & #19.
Thank you for your reply and thanks a lot for the practical suggestions to simplify the code. I can see now the difference if somebody looks at a code just from the point of the desired output or if you look at the code as a programmer.
I will read your link about the lookbacks. Thats probably the key to improve performance.
Thanks again!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good morning,
I am still in the learning process so please dont be offended if I ask silly questions.
I am working on an indicator and recently added some part of code which calculates a raff channel.
The code was a bit enhanced by me so it can calculate the regression on another timeframe.
This is what it actually looks like:
Unfortunately I am facing 2 problems.
1) I am actually running in an error (if c2 == 0.0)
2) The indicator is very slow (2021.06.28 06:00:17.934 EURUSD.r,H1: indicator(s) working too slowly, total calculation time 8531 ms)
As TF3 I am using W1 timeframe. barsToCount is set to 200.
I tried all wekend to find the problem but could not figure it out.
Any help would be appreciated.
Thank you.