Basic Overview
Basic Overview
IV & Delta are used for forecasting price movements and volatility expectations.
WTB helps track support, and WTT identifies zones with high liquidity and trading
activity.
OI & Volume changes help in identifying fresh positions and trend reversals.
Overview of Functions
NIFTY
1. Flow of ImportChain Function
Initialize Spreadsheet
● Write the extracted data into the 'DATA' sheet starting from cell B3.
2. ImportValue(url)
Purpose: This function imports specific data about the Nifty index from a given URL and
updates the Google Sheet based on a trigger cell's value.
Key Components:
● Spreadsheet and Sheet Access: The function retrieves the active spreadsheet and
accesses the sheet named 'DATA'.
● Trigger Cell Check: It checks the value of a specific cell (A11). If this cell contains 1, it
proceeds to fetch data; otherwise, it logs that the script execution is turned off.
● Data Fetching: It uses UrlFetchApp.fetch(url) to get data from the specified API
endpoint. The URL is hardcoded to fetch today's spot data for Nifty.
● Data Extraction: The JSON response is parsed, and specific fields (like symbol name,
last trade price, high, low, etc.) are extracted into an array.
● Sheet Update: Finally, it writes this extracted data into the sheet starting from row 3
and column 31.
3. GetDate(url)
Purpose: This function retrieves the start date for contributors related to the Nifty index.
Key Components:
● Error Handling: It uses a try-catch block to handle potential errors during API calls.
● API Call: It fetches data from another API endpoint that provides a list of contributor
dates for Nifty.
● Date Extraction: The start date is extracted from the JSON response and returned as
an array.
4. GetData(url)
Purpose: This function retrieves summary data about the Nifty index.
Key Components:
● API Call and Data Parsing: Similar to the previous functions, it fetches data from a
specified URL and parses the JSON response.
● Summary Data Extraction: It extracts summary statistics such as positive and
negative counts and their respective sums.
● Return Values: The function returns these values as an array.
5. Function: SaveData()
● Purpose: Append the first row of the "Record" sheet to the end of the sheet.
● Process:
1. Retrieve the active spreadsheet.
2. Access the "Record" sheet.
3. Get values from the range A1:FZ1 (first row).
4. Append these values as a new row at the bottom of the "Record" sheet.
6. Function: Clear()
● Purpose: Clear contents in a specified range (A5:FZ600) of the "Record" sheet without
affecting filtered rows.
● Process:
1. Retrieve the active spreadsheet.
2. Activate the range A5:FZ600 in the "Record" sheet.
3. Clear contents while skipping filtered rows.
4. Reactivate cell A5 for user convenience.
7. Function: SetValues()
● Purpose: Copy values from one range (A2:AE250) to another (starting at I2) within the
"Change" sheet.
● Process:
○ Retrieve the active spreadsheet.
○ Access the "Change" sheet.
○ Copy values from A2:AE250 and paste them into I2 using PASTE_VALUES.
○ Log a message indicating successful execution.
8. Function Refresh
NIFTY LiVE
● End
○ The function completes execution.
The function Clear() is designed to clear the contents of a specific range in a Google
Sheets spreadsheet, specifically in the "Record" sheet. The range targeted for clearing is
from cell A5 to TL500. The function also ensures that it skips any filtered rows when clearing
the contents.
● Start: The function is invoked.
● Access Spreadsheet: It retrieves and references the active spreadsheet.
● Select Range: It activates a specific range (A5:TL500) in the "Record" sheet.
● Clear Contents: It clears only the contents of that range while skipping filtered rows
(the second clear call is unnecessary).
● Return Focus: Finally, it reactivates cell A5 for user convenience.
3. Function: onEdit(e)
onEdit(e): This function is triggered whenever a user edits the spreadsheet.
This function handles actions based on specific checkbox selections in the "Test" sheet.
Key Components
● Parameters:
● e: An event object that contains information about the edit event, including the
range that was edited.
● Variables:
● sheetName: A constant that specifies the name of the sheet ("Test") where the
script will operate.
● range: The range of cells that were edited.
● sheet: The specific sheet object corresponding to the edited range.
Logic Flow
● Check Sheet Name:
○ The function first checks if the edited sheet is named "Test".
● Checkbox Actions:
○ It then checks which specific cell was edited and whether it is checked
(i.e., true):Cell T9 Checked
● Reset Checkbox:
○ After processing any of these actions, it unchecks the checkbox that
was edited, ensuring it resets for future interactions.
These two functions allow for manual incrementing or decrementing of the value in cell AJ1.
addvalue()
● Retrieves the current value from cell AJ1.
● Increments that value by 1.
● Updates cell AJ1 with the new value.
devalue()
● Retrieves the current value from cell AJ1.
● Decrements that value by 1.
● Updates cell AJ1 with the new value.
5. Function archiveCopy()
a. Initialization
● Access Active Spreadsheet: The function starts by accessing the currently
active Google Spreadsheet using SpreadsheetApp.getActive().
● Select Specific Sheet: It then selects a sheet named 'OC' where the relevant
data and trigger cell are located.
b. Retrieve Trigger Value
● Read Trigger Cell: The script reads the value from cell AK5 in the 'OC' sheet.
This cell acts as a trigger to determine whether to execute the file copy
operation.
c. Conditional Execution
● Check Trigger Condition: The function checks if the value retrieved from AK5
equals 1:
● If true (i.e., trigger condition is met), it proceeds to copy the file.
● If false, it logs a message indicating that script execution is turned off,
and no further actions are taken.
e. Date Formatting
● Get Time Zone: The script retrieves the current time zone for accurate date
formatting.
● Format Current Date: It formats the current date into a specific string format
(e.g., "dd-MM-yyyy") to create a meaningful name for the copied file.
● Create New File Name: The formatted date is concatenated with the string
"NIFTY" to create a new file name (e.g., "NIFTY 03-12-2024").
1. Script Initialization
● Load Configuration: The script loads the configuration settings defined in the
JSON.
● Time Zone: Set to "Asia/Kolkata".
● Logging: Exception logging is configured to use Stackdriver.
● Runtime Version: The script uses the V8 JavaScript engine.
2. Define Macros
● Macro Definitions: The script defines a list of macros that will appear in the
Google Sheets menu.
● Each macro has:Menu Name
3. User Interaction
● Open Google Sheets: The user opens a Google Sheets document where the
script is deployed.
● Access Custom Menu:
● The user navigates to the custom menu created by the script, which
displays all defined macros.
4. Execute Macro
● Select Macro: The user selects a macro from the menu (e.g., "Clear",
"GetData").
● Trigger Function Execution:
● The corresponding function (e.g., Clear, GetData) is executed.
● The function performs its defined task within the spreadsheet (e.g.,
clearing data, fetching data).
6. End of Execution
● The script completes its execution and returns control back to the user in
Google Sheets.
NIFTY:
Macros used
- Clear
- ROC
- GetData
List of Macros
● Clear: Executes the Clear function.
● ROC: Executes the ROC function.
● DATA: Executes the DATA function.
● DATAA: Executes the DATAA function.
● GetData: Executes the GetData function (listed twice).
● get: Executes the get function.
● get 1: Executes the get1 function.
● GETY: Executes the GETY function.
● GG: Executes the GG function.
● gety: Executes the gety function.
—------------------------------------------------------------------------------------------------------------------------
1. Expiry Date
2. Today Date
1. Resistance:
○ Based on Volume (Strong/Weak)
○ Based on OI (WTB/Strong/Weakens)
○ Based on Delta (e.g., IV: 2.05/Delta: 0.07)
2. Support:
○ Based on Volume (Strong/Weak)
○ Based on OI (WTB/Bullish/Bearish)
○ Based on Delta (e.g., IV: 7.71/Delta: -0.40)
SENTIMENT ANALYSIS:
1. Bullishness:
○ Based on OI (Strong/Weak)
○ Based on Volume (Bearish/Bullish)
2. Bearishness:
○ Resistance (WTB)
○ Support (Volume-Based Weakening)
● Call OI: Open Interest in call options for a specific strike price, indicating
resistance levels.
● Put OI: Open Interest in put options for a specific strike price, indicating
support levels.
● OI Change: Changes in OI over time, suggesting new positions being built
or unwound.
● Volume: Total traded volume of options contracts, indicating liquidity
and activity.
● Net OI Change: The aggregated OI change across all strikes for calls/puts.
● Resistance:
○ OI-Based Resistance: Strikes with the highest call OI.
○ Volume-Based Resistance: Strikes with high call volume but weak
OI changes (WTB - Weakening Trend Base).
● Support:
○ OI-Based Support: Strikes with the highest put OI.
○ Volume-Based Support: Strikes with high put volume but weak OI
changes.
Trading Metrics
Derived Metrics
Time-Based Metrics
● Zero Line Analysis: Tracks strike-specific OI changes over time to identify
resistance/support trends.
● Historical Resistance/Support Zones: Evaluated over months to
highlight recurring patterns (WTB/WTT over "N months").
—--------------------------------------
References:
https://unofficed.com/courses/options-chain/lessons/theory-of-open-interest/
https://unofficed.com/courses/options-chain/lessons/the-16-types-of-options-trading/
https://unofficed.com/courses/options-chain/lessons/how-to-see-the-option-chain/topic/different-tools-
for-options-chain/
https://unofficed.com/courses/max-pain-theory/