Plot GEX support and resistance levels via an indicator
Plot GEX support and resistance levels via an indicator
If you lack programming skills or the cost of developing Gex indicators is prohibitively high, you can plot rectangles to represent gamma flips and gamma walls using simple indicators. The data can be sourced from Barchart, and these values can be plotted on the chart via the indicator before the market opens.
I have developed an indicator to plot GEX support and resistance levels. Below are the corresponding EasyLanguage and Pine Script code implementations, respectively.
EasyLanguage
#region - Usings -
using elsystem;
using elsystem.collections;
using elsystem.drawing;
using elsystem.drawingobjects;
using elsystem.io;
using tsdata.common;
using tsdata.marketdata;
#endregion
Input:
double GammaFlipPrice( 6900 ), // Gamma Flip价格(手动输入)
double GammaFlipRange( 1 ), // 矩形上下边沿距离(点数,可调节)
string GammaFlipColor( "blue" ), // 矩形颜色
int GammaFlipAlpha( 255 ), // 透明度
//int GammaFlipBorderWidth( 1 ), // 边框宽度
//int GammaFlipBorderStyle( 0 ), // 边框样式
//int GammaFlipFillPattern( 0 ), // 填充样式
double GammaWall1(0),
double GammaWall2(0),
double GammaWall3(0),
double GammaWall4(0),
string GammaWallColor("red"),
int GammaWallAlpha(120);
vars:
Rectangle GammaflipBox(null),
Rectangle GammaWallBox1(null),
Rectangle GammaWallBox2(null),
Rectangle GammaWallBox3(null),
Rectangle GammaWallBox4(null);
method Rectangle drawBoxDT(datetime x1, double y1, datetime x2 , double y2, int extend, string border_color, int border_width, int border_style, int fill_pattern, int colorAlpha, string fill_color )
variables:
Rectangle Box;
begin
//Box = Rectangle.Create(BNPoint.Create( Maxbarsback -1 + x1, y1), BNPoint.Create( Maxbarsback -1 + x2 , y2));
Box = Rectangle.Create(DTPoint.Create(x1, y1), DTPoint.Create(x2, y2));
if extend = 1 then Begin
Box.ExtLeft = true;
Box.ExtRight = false;
End
else if extend = 2 then Begin
Box.ExtRight = true;
Box.ExtLeft = false;
End
else if extend = 0 then Begin
Box.ExtLeft = false;
Box.ExtRight = false;
end;
Box.FillPattern = fill_pattern astype int ;
Box.Color = Color.FromARGB( colorAlpha, GetRValue( color.FromNameToRGB(border_color) ), GetGValue( color.FromNameToRGB(border_color) ), GetBValue( color.FromNameToRGB(border_color) ) ); //border color
Box.FillColor = Color.FromARGB( colorAlpha, GetRValue( color.FromNameToRGB(fill_color) ), GetGValue( color.FromNameToRGB(fill_color) ), GetBValue( color.FromNameToRGB(fill_color) ) );
Box.Style = border_style Astype int ; // border style
Box.Weight = border_width Astype int ; //border width
box.Persist = true;
return Box;
end;
// Gamma Flip 矩形
if GammaFlipPrice > 0 and LastBarOnChartEx = True then
Begin
if GammaflipBox = Null Then
Begin
GammaflipBox = drawBoxDT(Bardatetime[200], GammaFlipPrice + GammaFlipRange,
//Bardatetime, GammaFlipPrice - GammaFlipRange, 2, GammaFlipColor, GammaFlipBorderWidth, GammaFlipBorderStyle, GammaFlipFillPattern, GammaFlipAlpha, GammaFlipColor );
Bardatetime, GammaFlipPrice - GammaFlipRange, 2, GammaFlipColor, 1, 0, 0, GammaFlipAlpha, GammaFlipColor );
DrawingObjects.Add(GammaflipBox);
end;
end;
// Gamma Wall1
if GammaWall1 > 0 and LastBarOnChartEx = True then
Begin
if GammaWallBox1 = Null Then
Begin
GammaWallBox1 = drawBoxDT(Bardatetime[200], GammaWall1 + GammaFlipRange,
Bardatetime, GammaWall1 - GammaFlipRange, 2, GammaWallColor, 1, 0, 0, GammaWallAlpha, GammaWallColor);
DrawingObjects.Add(GammaWallBox1);
end;
end;
// Gamma Wall2
if GammaWall2 > 0 and LastBarOnChartEx = True then
Begin
if GammaWallBox2 = Null Then
Begin
GammaWallBox2 = drawBoxDT(Bardatetime[200], GammaWall2 + GammaFlipRange,
Bardatetime, GammaWall2 - GammaFlipRange, 2, GammaWallColor, 1, 0, 0, GammaWallAlpha, GammaWallColor);
DrawingObjects.Add(GammaWallBox2);
end;
end;
// Gamma Wall3
if GammaWall3 > 0 and LastBarOnChartEx = True then
Begin
if GammaWallBox3 = Null Then
Begin
GammaWallBox3 = drawBoxDT(Bardatetime[200], GammaWall3 + GammaFlipRange,
Bardatetime, GammaWall3 - GammaFlipRange, 2, GammaWallColor, 1, 0, 0, GammaWallAlpha, GammaWallColor);
DrawingObjects.Add(GammaWallBox3);
end;
end;
// Gamma Wall4
if GammaWall4 > 0 and LastBarOnChartEx = True then
Begin
if GammaWallBox4 = Null Then
Begin
GammaWallBox4 = drawBoxDT(Bardatetime[200], GammaWall4 + GammaFlipRange,
Bardatetime, GammaWall4 - GammaFlipRange, 2, GammaWallColor, 1, 0, 0, GammaWallAlpha, GammaWallColor);
DrawingObjects.Add(GammaWallBox4);
end;
end;
PineScript
Its a private invite only indicator. Message me if you need access.