# still a newbie please need Coding Help.

I am trying to come up with an indicator that draws a rectangle on chart whenever a fair value gap is detected .

its based on the ICT trading concepts for those who are familiar with it. I want to draw a rectangle  in between the 3 bars if the high of a candle at index 1 is longer than the low of candle at index 3 and vice versa for buy side fair value gap. So to my understanding i would need 2 buffers , one for low price values and high price values and i will need two indicator plots to draw the rectangle. I have tried to read documentation but im still confused on how to proceed. i have also tried to follow youtube videos but then in the the videos the custom indicators they are creating are based on inbuilt technical indicators yet what i want to do is based purely on price action on the chart so it was so confusing trying to understand and follow their steps. Especially how to copy highs and lows for the specific bars on the Oncalculate function.  please advise what resources may help me for my exact scenario or just advise what i should be doing instead . I have attached some code of how far i went. Not very far lol

```#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_FILLING
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID

double Bufferlow[];
double Bufferhigh[];
input int BarstoCount = 3;

int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Bufferlow,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[],
{
if(IsStopped()) return(0);
if(rates_total < BarstoCount) return(0);  //checking if we have enough bars to calculate

//--- return value of prev_calculated for next call
return(rates_total);
}```

1. Seleucus: . I have attached some code of how far i went.

You didn't go anywhere; there is no code to detect your want, no code to draw a rectangle, etc.

2. Seleucus: whenever a fair value gap is detected .

Until you can state your requirements in concrete terms, it can not be coded.

3. Seleucus: if the high of a candle at index 1 is longer than the low of candle at index 3
A high /  low of a candle is a price. It is not a distance. There is no “longer.” № 2.

William Roeder #:
1. You didn't go anywhere; there is no code to detect your want, no code to draw a rectangle, etc.

2. Until you can state your requirements in concrete terms, it can not be coded.

3. A high /  low of a candle is a price. It is not a distance. There is no “longer.” № 2.
What I explained up there may not have been very clear. Essentially, I don't want someone to code it for me , I want to code it myself so I just need some guidance regarding how to copy the high and low prices of the bars in Oncalculate function so that I can then use those values to draw the rectangle bordering the low price and high price of the selected bars. The code I included, I know it isn't much but what I wanted was to get feedback if I'm on the right track. I've attached a picture of what it is I'm trying to code an indicator for. I'm hoping it may give you a better clue of what I'm trying to achieve so that you can then give relevant guidance.
Files:

Seleucus #: I just need some guidance regarding how to copy the high and low prices of the bars in Oncalculate function

The code I included, I know it isn't much but what I wanted was to get feedback if I'm on the right track.

1. You have the high and low arrays in the function. Set them to as-series and just read the values. Why do you need to copy? What's the problem?

To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5
2. Right track for what? All you posted was the initial template for an indicator; you haven't coded anything yet.