- Help you with what? You haven't stated a problem, you stated a want. You have only four choices:
-
Search for it. Do you expect us to do your research for you?
-
Beg at:
- Coding help - MQL4 programming forum
- Make It No Repaint Please! - MQL4 programming forum
- MT4 to MT5 code converter - MQL5 programming forum
- Please fix this indicator or EA - General - MQL5 programming forum - Page 193 #1027
- Requests & Ideas (MQL5 only!) - Expert Advisors and Automated Trading - MQL5 programming forum
-
MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours. -
or pay (Freelance) someone to code it.
Hiring to write script - General - MQL5 programming forum 2019.08.21
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
No free help 2017.04.21 -
- How grateful? Not compiled, not tested, just typed.
double percentrank(double value, const double& arr[], int length=WHOLE_ARRAY, int iBeg=0){ if(length == WHOLE_ARRAY) length = ArraySize(arr) - iBeg; int iEnd = length + iBeg; int count=0; while(iBeg < iEnd) if(arr[iBeg++] <= value) ++count; return double(count) / length; }
Not compiled, not tested, just typed.
- Help you with what? You haven't stated a problem, you stated a want. You have only four choices:
-
Search for it. Do you expect us to do your research for you?
-
Beg at:
- Coding help - MQL4 programming forum
- Make It No Repaint Please! - MQL4 programming forum
- MT4 to MT5 code converter - MQL5 programming forum
- Please fix this indicator or EA - General - MQL5 programming forum - Page 193 #1027
- Requests & Ideas (MQL5 only!) - Expert Advisors and Automated Trading - MQL5 programming forum
-
MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours. -
or pay (Freelance) someone to code it.
Hiring to write script - General - MQL5 programming forum 2019.08.21
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
No free help 2017.04.21 -
- How grateful? Not compiled, not tested, just typed. Not compiled, not tested, just typed.
Thanks for your help, this is my code, the result must be between 0 and 100 but for some reason the result is a negative value, you know why ?
Actually what I'm looking to graph is a line with this formula: PercentRank1(iATR(17),23) where 23 is the number of the historical bars.
//+------------------------------------------------------------------+ //| CCP PRUEBAS.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot ATR #property indicator_label1 "ATR" #property indicator_type1 DRAW_LINE #property indicator_color1 clrAqua #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- indicator buffers double ATRBuffer[]; double tmpArray[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ double PercentRank1(double r_period, int shift) { double pcrank, rank; //int i; ArrayCopy(tmpArray, High, 0, shift, r_period); ArrayCopy(tmpArray, Low, r_period, shift, r_period); ArrayCopy(tmpArray, Close, r_period * 2, shift, r_period); ArraySort(tmpArray, r_period * 3); rank = ArrayBsearch(tmpArray, Close[shift], r_period * 3); pcrank = rank /(r_period * 3 - 1); return (pcrank); } int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ATRBuffer); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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 limit = rates_total-prev_calculated; for(int i=0; i<limit; i++) { ATRBuffer[i] = PercentRank1(iATR(NULL,0,17,i),23) } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
ATRBuffer[i] = PercentRank1(iATR(NULL,0,17,i),23)
Prices are 1.2345º. ATR is 0.00xxx. You will never find an ATR in the range of prices.
Los precios son 1.2345º. ATR es 0.00xxx. Nunca encontrará un ATR en el rango de precios.
So, I don't understand why in tradingview pinescript if it works, and the formula is exactly the same, the calculation results are between 0 and 100.
Ok
.
![Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions](https://c.mql5.com/36/37/documentation-on-mql5-constants__17.png)
- www.mql5.com
Yes, this is the result of tradingview, I am looking for exactly the same but in mql4
https://i.ibb.co/R2mZngN/j45j45j.png
Post a clickable link or insert the picture please. See the editor toolbar buttons.
I already corrected my comment, now if you can see the images :)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thank you.