Trying to build an indicator that draws horizontal line on 52weeks high and low in two previous year
- Femi Kikas: what i have done so far by using mql4 refernce :
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - Femi Kikas: datetime date = Year;
Assuming that Year is an int; you can't use that int as seconds from 1970. E.g. 2019 is Thursday, January 1, 1970 12:33:39 AM UTC. Perhaps you want to use StructToTime. Or something like TimeCurrent() - 52 * PeriodSeconds(PERIOD_W1)
- Femi Kikas: int bar =int iBarShift(NULL,0,date);
Do not post code that will not compile.
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
- Femi Kikas:
Trying to build an indicator that draws horizontal line on 52weeks high and low in two previous year
What you posted isn't doing multiple years.
I have an indicator that does this and a tested strategy that I have built around it which helps me to achieve great result in trading. I use the weekly horizontal lines as key price and I wait for a rejection on it on a lower time frame.
I have sent you a message, if you are interested, pls get in touch.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am a complete noob to building indicators;however i have searched throughout mt4 forum maybe i can find indies like this or similar already built but to no avail. read up some things and tried building one myself ,ran to all types of errors.
what i have done so far by using mql4 refernce :
datetime date = Year;
int bar =int iBarShift(NULL,0,date);
string name ="UniqueName";
double highestPrice = High[iHighest(Symbol(), 0, MODE_HIGH, bar, 1)];
bool ObjectCreate(name, OBJ_HLINE, 0, Time[0],highestPrice, 0, 0);
any help will be appreciated,just tryna build a simple indicator that draws horizontal line of highest high,lowest low within a timeframe of 1 year,and average price of both high and low. and have the lines for the past two years high,low and average price of the high and low.