OPEN-SOURCE SCRIPT

Futures Margin Lookup Table

98
This script applies a table to your chart, which provides the intraday and overnight margin requirements of the currently selected symbol.
In this indicator the user must provide the broker data in the form of specifically formatted text blocks. The data for which should be found on the broker website under futures margin requirements.

The purpose for it's creation is due to the non-standard way each individual broker may price their margins and lack of information within TradingView when connected to some (maybe all) brokers, including during paper trading, as the flat percentage rule is not accurate.

An example of information could look like this


MES;Micro S&P;$50;$2406
ES;E-Mini S&P;$500;$24,053
GC;Gold;$500;$16500
NQ;E-Mini Nasdaq;$1,000;$34,810
FDAX;Dax Index;€2,000;€44,311



Each symbol begins a new line, and the values on that line are separated by semicolons (;)
Each line consists of the following...
SYMBOL : Search string used to match to the beginning of the current chart symbol.
NAME: Human readable name
INTRA: Intraday trading margin requirement per contract
OVERNIGHT: Overnight trading margin requirement per contract


The script simply finds a matching line within your provided information using the current chart symbol.
So for example the continuous chart for
NQ1!

would match to the user specified line starting with NQ... as would the individual contract dates such as NQM2025, NQK2025, etc.

NOTES:
  1. There is a possibility that symbols with similar starting characters could match. If this is the case put the longer symbol higher in the list.
  2. There is also a line / character limit to the text input fields within pinescript. Ensure the text you enter / paste into them is not truncated. If so there are 3 input fields for just this purpose. Find the last complete line and continue the remaining symbol lines on the subsequent inputs.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.