Falcon23:
hi there i wanted to know how to convert
this from mql 4 to mql 5 code
MQL5:
//--- main loop int limit=prev_calculated-1; if(prev_calculated==0) limit=0; for(int i=limit; i<rates_total; i++) { *** }
Falcon23 # :
hi there thanks for the reply where should i fill the prev_calculated var and where?
hi there thanks for the reply where should i fill the prev_calculated var and where?
What do you mean where ??? It is always there!
//+------------------------------------------------------------------+ //| 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[]) {
im a newBee sir actually i can not find any equivalents for
IndicatorCounted
function if u could give me a detailed reply on how to convert the code above which is from mql4 to mql5 i would be thankfull.
Falcon23 # :
im a newBee sir actually i can not find any equivalents for
im a newBee sir actually i can not find any equivalents for
function if u could give me a detailed reply on how to convert the code above which is from mql4 to mql5 i would be thankfull.
There are none 'IndicatorCounted'. Please read the help: OnCalculate
A simple indicator:
//+------------------------------------------------------------------+ //| Simple Indicator.mq5 | //| Copyright © 2022, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2022, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot High #property indicator_label1 "High" #property indicator_type1 DRAW_LINE #property indicator_color1 clrYellowGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input int Input1=9; //--- indicator buffers double HighBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,HighBuffer,INDICATOR_DATA); //--- 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=prev_calculated-1; if(prev_calculated==0) limit=0; for(int i=limit; i<rates_total; i++) { HighBuffer[i]=high[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Result:

Documentation on MQL5: Event Handling / OnCalculate
- www.mql5.com
OnCalculate - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
Simple_Indicator.mq5
5 kb
See How to do your lookbacks correctly #9 — #14 & #19.

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
hi there i wanted to know how to convert
this from mql 4 to mql 5 code