Unfilled Gap Detector Indicator with Price Level as Output

 

Hello Forex TSD:

I'm searching for an Unfilled Gap Detector Indicator with Price Level as Output.

Essentially, the indicator would detect the Highest and Lowest Unfilled Gap, between Time = Current Bar [0] and Time = 0000 GMT, and then output those two Price Levels both in numeric value (ie: Highest = $1.35801, Lowest = $1.34621) and by printing a horizontal line on the chart where the Unfilled Gap resides (Green line for Highest, Red line for Lowest).

The idea here, is to maintain the option of suppressing any trade Long that gets triggered above the Lowest Unfilled Gap Price Level, and suppressing any trade Short that gets triggered below the Highest Unfilled Gap Price Level.

I already have an indicator called: iGap.mq4. It does a very good job of detecting ALL gaps in a chart. However, only need the Highest Unfilled and Lowest Unfilled Gaps between Current Bar [0] and 0000 GMT (MT4 server time) - both in numeric Price Level output, as well as Green line for Highest and Red line for Lowest, where the Gaps occur respectively. (see code for iGap.mq4 attached below)

Your help is appreciated.

Thanks,

Trajectory7

Files:
i-gap.mq4  4 kb
 

Unfilled Gap Dectector Indicator Idea (need help)

I'm calling it the UnfilledGapDetector.mq4 and I need someone to code it.

I have looked at other Gap indicators but none of them have the functionality necessary to actually be used in trade decision support. So, if you have the MQL coding skills, I'd appreciate your taking a whack at this one for me. I have loads of other ideas that I might be willing to bring to the forum as well, for some reciprocity on this one. Here are the details of what I'm looking for.

Indicator Functions: (what the indicator should be able to do)

- Detect Highest Unfilled Gap above current close price, between Current Bar [0] Time and 0000 GMT (MT4 server time).

- Detect Lowest Unfilled Gap below current close price, between Current Bar [0] Time and 0000 GMT (MT4 server time).

Output: (how the indicator should output the modes)

Total outputs = 6

Mode 0 = HUFG-Value

Mode 1 = HUFG-Line

Mode 2 = HUFG-Distance

Mode 3 = LUFG-Value

Mode 4 = LUFG-Line

Mode 5 = LUFG-Distance

Output Mode Descriptions: (how the indicator's signals should be labeled inside the indi)

HUFG-Value = Output as numeric value for price level where gap resides (example: $1.36801)

HUFG-Line = Output as green dotted horizontal line across chart at HUFG (example: ...........)

HUFG-Distance = Output as numeric value for Bars ago from HUFG-Value (example: 27)

LUFG-Value = Output as numeric value for price level where gap resides (example: $1.35027)

LUFG-Line = Output as green dotted horizontal line across chart at HUFG (example: ...........)

LUFG-Distance = Output as numeric value for Bars ago from HUFG-Value (example: 53)

Time Frame for the Indicator: (self explanatory)

M1, as the indicator output can be used for all other higher time frames.

How would I use such an Indicator?:

As a trade suppressor.

- If the trade triggered is Long, and current close bar [0] is > LUFG-Value, the do not execute trade.

- If the trade triggered is Short, and the current close bar [0] is < HUFG-Value, then do not execute trade.

-or-

If you are ALREADY in a Short position, and the Entry is > LUFG-Value, then Hold the position.

If you are ALREADY in a Long position, and the Entry is < HUFG-Value, then Hold the position.

Conclusion:

I don't need an EA for this, but if you want one for yourself, that's ok. I only need the indicator with the six (6) mode/signals as output for later use in an iCustom import.

There are a few Gap Indicators out there, but none of them do what this one would - because this one is ONLY concerned with the Highest Unfilled Gap and the Lowest Unfilled Gap, for use as a trade suppressor. Whereas, others are actually trying to trade the gaps. I'm trying to avoid them by not allowing a trade against them to be triggered. However, as you can see from above, this could be used as a sort of Hold Indicator as well, just as long as the condition above remain in true.

Thanks for the help,

Conceptual

BTW: The indicator called i-Gap.mq4, seems to do a very good job of detecting ALL gaps on a chart. So, if that code could be used as the baseline and modified to result in the above requirements, that might (I'm not sure) same the coder some time, energy and effort.

i-Gap.mq4 code here: (I replaced most of the comment lines with the phrase "unreadable characters" as that may apply)

#property copyright "Êèì Èãîðü Â. aka KimIV"

#property link "http://www.kimiv.ru"

//----

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 PaleGreen

#property indicator_color2 LightSalmon

//------- unreadable characters -------------------------------

extern int SizeGAP =5; // unreadable characters

extern int NumberOfBars=1500; // unreadable characters

//------- unreadable characters --------------------------------------

int ArrowInterval;

//------- unreadable characters ---------------------------------

//------- unreadable characters ------------------------------------------

double SigBuy[];

double SigSell[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

void init()

{

SetIndexBuffer(0, SigBuy);

SetIndexStyle (0, DRAW_ARROW);

SetIndexArrow (0, 233);

SetIndexEmptyValue(0, EMPTY_VALUE);

//

SetIndexBuffer(1, SigSell);

SetIndexStyle (1, DRAW_ARROW);

SetIndexArrow (1, 234);

SetIndexEmptyValue(1, EMPTY_VALUE);

ArrowInterval=GetArrowInterval();

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

void start()

{

double ms[2];

int LoopBegin, sh;

//----

if (NumberOfBars==0) LoopBegin=Bars-1;

else LoopBegin=NumberOfBars-1;

//----

for(sh=LoopBegin; sh>=0; sh--)

{

ms[0]=EMPTY_VALUE;

ms[1]=EMPTY_VALUE;

GetSignals(sh, ms);

SigBuy[sh]=ms[0];

SigSell[sh]=ms[1];

}

}

//+------------------------------------------------------------------+

//| unreadable characters |

//+------------------------------------------------------------------+

void GetSignals(int nb, double& ms[])

{

double Cl1=Close[nb+1];

double Op0=Open [nb];

//----

if (Cl1>Op0+SizeGAP*Point) ms[0]=Low[nb]-ArrowInterval*Point;

if (Cl1<Op0-SizeGAP*Point) ms[1]=High[nb]+ArrowInterval*Point;

}

//+------------------------------------------------------------------+

//| unreadable characters |

//+------------------------------------------------------------------+

int GetArrowInterval()

{

int p=Period();

switch(p)

{

case 1: return(3);

case 5: return(5);

case 15: return(7);

case 30: return(10);

case 60: return(15);

case 240: return(20);

case 1440: return(50);

case 10080: return(100);

case 43200: return(200);

}

}

//+------------------------------------------------------------------+

 

Working on improving this:

Need help with Unfilled Gap Detector Indicator.

Thanks a million.

 

Might there be an experienced and erudite MQL coder who wants to take a crack at this one?

Your help is appreciated, thanks!

Reason: