Forex Zone - Forex Forum

Indi Coding

Discussion started on MT4 / MT5 Indicators

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
Hi all
I started learning MQL, so hopefully one of these weeks (years :-[) I can help with coding here.
As I am still in the beginning of tutorials, I can only do very basic stuff, like the "Hello world" to appear on a chart or calling an alert etc.
What I want to ask any coder please, 
How do I get the highest close of x amount of candles, and the draw (paint) that line on a chart.
Same with the lowest close of c amount of candles. 
I tried Close(120) but it obviously only give me candle # 120's close (And not even a dot on the chart :o)
Thanks for the help
Francois
 

Linkback: https://www.forex.zone/mt4-mt5-indicators/8/indi-coding/196/
#1 - August 23, 2018, 01:35:13 PM

Administrator
  • Hero Member
  • Posts: 4825
  • Points: 34701
  • Likes Received: 4920
  • Reputation: +220/-14
You don't want to use just the Close[] array since that will just give you the close of x shift. What you need to do is use iHighest() with Close[].

So to find the highest close price of the last 120 candles, it would look something like this:

Code: [Select]
Close[iHighest(NULL,0,MODE_CLOSE,120,0)]

Drawing a horizontal line after you get this is simple. You can use the ObjectCreate() function.
#2 - August 23, 2018, 03:07:17 PM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
Thanks.
No wonder it only returned 1 value
;D
#3 - August 23, 2018, 04:44:17 PM

Members:

0 Members and 1 Guest are viewing this topic.