OptionsLevel
Download scriptThis script is designed to visually map out specific option price levels on your trading chart. It simplifies the way traders view complex options data by automatically drawing horizontal lines and informative text labels based on user-provided data.
Core Functionality
The tool acts as a visual reference for "Calls" and "Puts." Instead of you having to manually calculate where these levels sit on the price scale, the script takes raw input values—such as Strike Prices and Premiums—and plots them accurately on your screen.
How it Works
- Price Calculation: The logic distinguishes between Calls and Puts. For Calls, it adds the premium to the strike price; for Puts, it subtracts the premium from the strike price. It then applies a multiplier to ensure the resulting price aligns correctly with the decimal format of your specific market.
- Visual Mapping: Once the levels are calculated, the script draws horizontal trend lines across a designated section of your chart. These lines help you identify "zones" where significant option activity might occur.
- Dynamic Labeling: Alongside each line, the script can display important market statistics including:
- VOL (Volume): The amount of trading activity for that specific level.
- OI (Open Interest): The total number of outstanding contracts.
- PT (Premium): The premium price associated with that strike.
- Customization: The script is highly adjustable, allowing you to control the visual appearance—such as line thickness, style, colors (e.g., Red for Calls and Lime for Puts), font size, and the specific time frames where the lines should appear.
User Experience
When you load this indicator, it clears out old markers and redraws your specified levels instantly. It provides a clean, organized snapshot of key option data directly on your trading candles, allowing for quicker identification of support, resistance, or high-activity zones without needing to constantly reference external data sheets.
//+------------------------------------------------------------------+
//| OptionsLevel.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input double Call_1_Strike = 1115; // Call Strike Price 1
input double Call_1_Prem = 7.6; // Call Premium 1
input double Call_1_Vol = 471; // Call Volume 1
input double Call_1_OI = 1513; // Call Open Interest 1
input double Call_2_Strike = 1120; // Call Strike Price 2
input double Call_2_Prem = 5.8; // Call Premium 2
input double Call_2_Vol = 419; // Call Volume 2
input double Call_2_OI = 3016; // Call Open Interest 2
input double Call_3_Strike = 1130; // Call Strike Price 3
input double Call_3_Prem = 3.1; // Call Premium 3
input double Call_3_Vol = 696; // Call Volume 3
input double Call_3_OI = 2738; // Call Open Interest 3
input double Put_1_Strike = 1080; // Put Strike Price 1
input double Put_1_Prem = 1.9; // Put Premium 1
input double Put_1_Vol = 694; // Put Volume 1
input double Put_1_OI = 2541; // Put Open Interest 1
input double Put_2_Strike = 1100; // Put Strike Price 2
input double Put_2_Prem = 6.2; // Put Premium 2
input double Put_2_Vol = 655; // Put Volume 2
input double Put_2_OI = 3148; // Put Open Interest 2
input double Put_3_Strike = 1090; // Put Strike Price 3
input double Put_3_Prem = 3.5; // Put Premium 3
input double Put_3_Vol = 286; // Put Volume 3
input double Put_3_OI = 7061; // Put Open Interest 3
input double Multiplier = 0.001; // Premium Multiplier
input string Line_Inputs="**** Line Inputs *****";
input int LineWidth = 2; // Line Width
input int LineStyle = 0; // Line Style
input int LineStart = 0; // Start bar of the line
input int LineEnd = 15; // End bar of the line
input color CallColor = Red; // Call Line Color
input color PutColor = Lime; // Put Line Color
input string Text_Inputs="**** Text_Inputs *****";
input int StartText = 6; // Start bar of the text
input int FontSize = 6; // Font Size
input string FontName = "Arial"; // Font Name
input color CallText = Blue; // Call Text Color
input color PutText = Blue; // Put Text Color
input bool ShowText = true; // Show Text
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0,0,OBJ_TEXT);
ObjectsDeleteAll(0,0,OBJ_TREND);
}
//+------------------------------------------------------------------+
//| Put Line Function |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price1,datetime time2,double price2,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
//--- set line color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- set the display style of the line
ObjectSetInteger(0,name,OBJPROP_STYLE,LineStyle);
//--- set line thickness
ObjectSetInteger(0,name,OBJPROP_WIDTH,LineWidth);
//--- enable (true) or disable (false) the mode of continuing the line display to the right
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
}
//+------------------------------------------------------------------+
//| Put Text Function |
//+------------------------------------------------------------------+
void Text(string name,const string text,double price,datetime time,const color clr)
{
ObjectDelete(0,name);
//--- create a "Text" object
ObjectCreate(0,name,OBJ_TEXT,0,time,price);
//--- set the text
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- set the font of the text
ObjectSetString(0,name,OBJPROP_FONT,FontName);
//--- set the font size
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
//--- set the method binding
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_UPPER);
//--- set the color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| 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[],
const int &spread[])
{
double pr=0;
// Call 1
if(Call_1_Strike>0)
{
pr=NormalizeDouble(Call_1_Strike*0.001+Call_1_Prem*Multiplier,_Digits);
PutTrendLine("Call_1",time[LineStart],pr,time[LineEnd],pr,CallColor);
if(ShowText)
Text("Call 1 Text ","VOL="+DoubleToString(Call_1_Vol,0)+" OI="+DoubleToString(Call_1_OI,0)+" PT="+DoubleToString(Call_1_Prem,1),pr,time[StartText],CallText);
}
// Call 2
if(Call_2_Strike>0)
{
pr=NormalizeDouble(Call_2_Strike*0.001+Call_2_Prem*Multiplier,_Digits);
PutTrendLine("Call_2",time[LineStart],pr,time[LineEnd],pr,CallColor);
if(ShowText)
Text("Call 2 Text ","VOL="+DoubleToString(Call_2_Vol,0)+" OI="+DoubleToString(Call_2_OI,0)+" PT="+DoubleToString(Call_2_Prem,1),pr,time[StartText],CallText);
}
// Call 3
if(Call_3_Strike>0)
{
pr=NormalizeDouble(Call_3_Strike*0.001+Call_3_Prem*Multiplier,_Digits);
PutTrendLine("Call_3",time[LineStart],pr,time[LineEnd],pr,CallColor);
if(ShowText)
Text("Call 3 Text ","VOL="+DoubleToString(Call_3_Vol,0)+" OI="+DoubleToString(Call_3_OI,0)+" PT="+DoubleToString(Call_3_Prem,1),pr,time[StartText],CallText);
}
// Put 1
if(Put_1_Strike>0)
{
pr=NormalizeDouble(Put_1_Strike*0.001-Put_1_Prem*Multiplier,_Digits);
PutTrendLine("Put_1",time[LineStart],pr,time[LineEnd],pr,PutColor);
if(ShowText)
Text("Put 1 Text ","VOL="+DoubleToString(Put_1_Vol,0)+" OI="+DoubleToString(Put_1_OI,0)+" PT="+DoubleToString(Put_1_Prem,1),pr,time[StartText],PutText);
}
// Put 2
if(Put_2_Strike>0)
{
pr=NormalizeDouble(Put_2_Strike*0.001-Put_2_Prem*Multiplier,_Digits);
PutTrendLine("Put_2",time[LineStart],pr,time[LineEnd],pr,PutColor);
if(ShowText)
Text("Put 2 Text ","VOL="+DoubleToString(Put_2_Vol,0)+" OI="+DoubleToString(Put_2_OI,0)+" PT="+DoubleToString(Put_2_Prem,1),pr,time[StartText],PutText);
}
// Put 3
if(Put_3_Strike>0)
{
pr=NormalizeDouble(Put_3_Strike*0.001-Put_3_Prem*Multiplier,_Digits);
PutTrendLine("Put_3",time[LineStart],pr,time[LineEnd],pr,PutColor);
if(ShowText)
Text("Put 3 Text ","VOL="+DoubleToString(Put_3_Vol,0)+" OI="+DoubleToString(Put_3_OI,0)+" PT="+DoubleToString(Put_3_Prem,1),pr,time[StartText],PutText);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Comments