How to program to identify HH (Higher High) or LL (Lower Low) or LH (Lower High) or Higher Low( HL) above and below each Peak as shown in below chart?
What are Higher High, Higher Low, Lower High and Lower Low? 11 replies
Can someone program high/low bars? 0 replies
Higher High/Higher Low indicator conversion from 4 to 5 decimals. Help anyone? 2 replies
Can u point me to code 2 show each bar with a higher high & higher low? 2 replies
DislikedHow to program to identify HH (Higher High) or LL (Lower Low) or LH (Lower High) or Higher Low( HL) above and below each Peak as shown in below chart?Ignored
using System; using System.Drawing; using OpenQuant.API; using OpenQuant.API.Indicators; public class MyStrategy : Strategy { private int barcount = 0; private double barclose = 0; private double barlow = 0; private double barhigh = 0; private double barlowest = 999999.0; private double barhighest = 0.0; private double HH1 = 0; private double HH2 = 0; private double LL1 = 0; private double LL2 = 0; private bool is_high = true; private bool is_low = false; private int HLbarcount = 0; DateTime barlowestDateTime; DateTime barhighestDateTime; TimeSeries HL; public override void OnStrategyStart() { HL = new TimeSeries("High-Low", Color.White); Draw(HL, 0); } public override void OnBar(Bar bar) { if ((bar.Close > 0) && (bar.High > 0) && (bar.Low > 0) && (bar.Open > 0)) { if (Mode != StrategyMode.Simulation) { DataManager.Add(Instrument, bar); } barcount++; HLbarcount++; barclose = bar.Close; barhigh = bar.High; barlow = bar.Low; if (barcount > 1) { if ((barlow) < barlowest) { barlowest = barlow; barlowestDateTime = bar.DateTime; } if ((barhigh) > barhighest) { barhighest = barhigh; barhighestDateTime = bar.DateTime; } } if (barcount > 4) { if ((HLbarcount > 3) && (is_low) && (Bars.Ago(0).High > Bars.Ago(3).High) && (Bars.Ago(0).Low > Bars.Ago(1).Low) && (Bars.Ago(0).Low > barlowest)) { LL2 = LL1; LL1 = barlowest; if (LL1 != LL2) { is_high = true; is_low = false; HL.Add(barlowestDateTime, barlowest); barhighest = Bars.HighestHigh(4); barhighestDateTime = bar.DateTime; HLbarcount = 0; HH1 = 0; HH2 = 0; Console.WriteLine("{0} LL1 = {1} barhighest = {2}", barlowestDateTime, LL1, barhighest); } } if ((HLbarcount > 3) && (is_high) && (Bars.Ago(0).Low < Bars.Ago(3).Low)&& (Bars.Ago(0).High < Bars.Ago(1).High) && (Bars.Ago(0).High < barhighest)) { HH2 = HH1; HH1 = barhighest; if (HH1 != HH2) { is_low = true; is_high = false; HL.Add(barhighestDateTime, barhighest); barlowest = Bars.LowestLow(4); barlowestDateTime = bar.DateTime; HLbarcount = 0; LL1 = 0; LL2 = 0; Console.WriteLine("{0} HH1 = {1} barlowest = {2}", barhighestDateTime, HH1, barlowest); } } } } else { Console.WriteLine("Instrument: {0}, Date/Time: {1}", Instrument, bar.DateTime); } } }
DislikedHi TickJob
I’ll try to offer a little more detail than the last poster.
It’s possible that there’s a custom indicator that already does this, but I’ve searched my library (of over 500 MT4 indicators), and can’t find one.
Re defining “local” highs and lows, what appears obvious to the naked eye is not necessarily as simple to model mathematically. I wrote a charting package about 5 years back (not quite as comprehensive as MT4 though! ), and was forced to address these same kind of issues.
One approach is “slicing” the chart into sections, or cycles. It’s then a matter of looping through the bars/candles to find the highest high and/or lowest low in each section. At least that’s the way I approached it.
Here are some possible starting points:
1. Very primitive: X bars in each section, where X is an arbitrary value. An alternative view is to take each bar on the chart and find the highest high and lowest low X bars forward or backward from that point.
2. Use trend following indicators, or oscillators to define the sections as “phases”. As a simple example, when a faster moving average crosses above a slower moving average you’re in an “upward” phase; when it moves below the slower MA, you’re in a “downward” phase. Then it’s a case of finding the highest high in each upward phase, and lowest low in each downward phase. Experiment with various MA calibrations (optimizations) to capture the “cycles” that you wish, or combinations of trend followers (MAs, SAR, countback lines, or oscillators [e.g. RSI, Stochastic or MACD crossing a trigger line, or the midpoint]) to get something close to the desired result. Virtually all of these are all built into MQL4 as functions (iMA, iMACD, iRSI, etc), so it’s not necessary to manually code each algorithm.
3. Instead of slicing the chart into sections, use something like Tom Demark supply and demand points, i.e. a high that’s higher than all of the highs X bars either side of it is a local high; vice versa for a low. One problem with using TD supply/demand points is that it’s possible to get two or more local highs without an intervening low, or vice versa; so you would need to compare them and exclude all but the most extreme one. I’ve included the Demark.MQ4 indicator below. For further explanation, see my posts here: http://www.forexfactory.com/showthread.php?t=37073
4. I’ve included the Zigzag .MQ4 indicator below. Not 100% sure how its algorithm operates; you’ll need to reverse engineer the code for yourself, or perform a search of the forum here for more info.
Of course once you’ve established local highs and lows, it’s simply a case of comparing successive highs and lows to establish whether each is higher or lower than its predecessor.
For whatever it's worth, method #2 was the way I ended up doing it.
Hope this gives you a starting point. It’s not necessarily a trivial task.
Good luck
DavidIgnored
DislikedI've been trying to upload asluncos indiccators and I'm not having any luck perhaps you could give me some tips on how too do so?Ignored
If it is from another source, simply download it and copy it to the correct folder.
Then exit, and re-run MT4. This causes MT4 to re-compile and re-load all new or changed indicators.
Press Ctrl-N to load the Navigator panel at left. The new indicators, scripts, experts should appear in the "Custom Indicators", "Scripts" or "Expert Advisors" trees.
In the case of indicators and scripts, drag them onto your chart(s) to execute them.
Hope I've helped get you one step closer to an answer.
Best wishes
David
DislikedFor whatever it's worth, method #2 was the way I ended up doing it.Ignored
Disliked{quote}I'm sorry sir, but I don't recall which indicator it was (the post is more than 13 years old).Ignored
Disliked{quote} hey sir, so i was programming an ea and i am quite new to it. i wanted to program it in such a way that it should identify a break of structure on h4, for instance the price on h4 breaks a previous high ( hence we are bullish) i wanted the ea to recognize that i cannot find material on youtube where i can see how do i make it recognize the previous high and also make it recognize whether the price has broken that level or not can u recommend me what to do?Ignored