Elevated Leverage index System - ELiSELEVATED LEVERAGE index SYSTEM (ELiS) tries to solve the problem of adjusting meaningful leverage in futures and margin trading.
The biggest problem for traders is adjusting the leverage level manually.
Concerning about the volatilities it's very hard to set a meaningful leverage level.
ELiS includes 4 different volatility component which are:
1- nATR: Normalized Average True Range which is actually ATR/price to stabilize ATR's value differences when price changes are high on long term periods.
2- Standard Deviation
3- Kairi based nATR
4- Bollinger %B
which are scaled from 0 to 100 and takes different averages with different combinations & ratios and combines them as an index.
This index calculates an average volatility to set the true leverage level when trading futures especially in Crypto and FX markets.
There are 5 risk levels of "GEARS" like on automobiles to set the max leverage for risk management.
Gear 1 - CONSERVATIVE: max leverage level can be 20 for swing traders and beginners
Gear 2 - STANDARD: max leverage level can be 25 (default) for day traders
Gear 3 - AVERAGE: max leverage level can be 33 for day traders
Gear 4 - RISKY: max leverage level can be 50 for scalpers
Gear 5 - AGRESSIVE: max leverage level can be 100 for advanced scalpers
default length for ATR, Standard Deviation and %B are all 50
Simply:
When markets aren't volatile: ELiS indicateshigher leverage values to maximize profits.
When markets are volatile enough: ELiS indicates lower values to reduce risk level.
hope you all enjoy ELiS on profitable trades.
Margintrading
Margin Buying Pressure Zones Longs & ShortsShows the Margin Pressure Zones for longs and shorts Longs & Shorts based on 2 Base prices to be configured by you.
For definition of "Margin Pressure Zones" see: www.investopedia.com
How to use Leverage and Margin in PineScriptEn route to being absolutely the best and most complete trading platform out there, TradingView has just closed 2 gaps in their PineScript language.
It is now possible to create and backtest a strategy for trading with leverage.
Backtester now produces Margin Calls - so recognizes mid-trade drawdown and if it is too big for the broker to maintain your trade, some part of if will be instantly closed.
New additions were announced in official blogpost , but it lacked code examples, so I have decided to publish this script. Having said that - this is purely educational stuff.
█ LEVERAGE
Let's start with the Leverage. I will discuss this assuming we are always entering trades with some percentage of our equity balance (default_qty_type = strategy.percent_of_equity), not fixed order quantity.
If you want to trade with 1:1 leverage (so no leverage) and enter a trade with all money in your trading account, then first line of your strategy script must include this parameter:
default_qty_value = 100 // which stands for 100%
Now, if you want to trade with 30:1 leverage, you need to multipy the quantity by 30x, so you'd get 30 x 100 = 3000:
default_qty_value = 3000 // which stands for 3000%
And you can play around with this value as you wish, so if you want to enter each trade with 10% equity on 15:1 leverage you'd get default_qty_value = 150.
That's easy. Of course you can modify this quantity value not only in the script, but also afterwards in Script Settings popup, "Properties" tab.
█ MARGIN
Second newly released feature is Margin calculation together with Margin Calls. If the market goes against your trades and your trading account cannot maintain mid-trade drawdown - those trades will be closed in full or partly. Also, if your trading account cannot afford to open more trades (pyramiding those trades), Margin mechanism will prevent them from being entered.
I will not go into details about how Margin calculation works, it was all explainged in above mentioned blogpost and documentation .
All you need to do is to add two parameters to the opening line of your script:
margin_long = 1./30*50, margin_short = 1./30*50
Whereas "30" is a leverage scale as in 30:1, and "50" stands for 50% of Margin required by your broker. Personally the Required Margin number I've met most often is 50%, so I'm using value 50 here, but there are literally 1000+ brokers in this world and this is individual decision by each of them, so you'd better ask yourself.
--------------------
Please note, that if you ever encounter a strategy which triggers Margin Call at least once, then it is probably a very bad strategy. Margin Call is a last resort, last security measure - all the risks should be calculated by the strategy algorithm before it is ever hit. So if you see a Margin Call being triggred, then something is wrong with risk management of the strategy. Therefore - don't use it!
Leverage Strategy and a few words on risk/opportunityHello traders,
I started this script as a joke for someone... finally appears it could be used for educational content
Let's talk about leverage and margin call
Margin Call
A margin call is the broker's demand that an investor deposit additional money or securities so that the account is brought up to the minimum value, known as the maintenance margin.
A margin call usually means that one or more of the securities held in the margin account has decreased in value below a certain point.
Leverage
A leverage is a system which allows the trader to open positions much larger than his own capital. ... “Leverage” usually refers to the ratio between the position value and the investment needed,
Strat
The strategy simulates long/short positions on a 4h high/low breakout based on the chart candle close.
The panel below shows the strategy equity curve. Activating the margin call option will show when the account would be margin called giving the settings
Casino
I'm not doing any financial recommendation here.
I made this strategy so that people include more risk management metrics into their strategy.
From the code, we see it's fairly easy to calculate a leveraged position size and a margin call flag - when that flag is hit, the system stops trading.
I simplified things to the extreme here but my point is that the leverage is a double-edge sword gift.
Assuming we always take the same position sizing, increasing the leverage speed up how fast a margin could be ..... called. (bad joke? feel free to tell me). Not saying it will, saying it introduces more risk by design.
Then one could say "I'll just turn off that stupid margin call option". And that's when someone starts backtesting with unrealistic market conditions.
Finally...
When I backtest I always assume the worst in every scenario possible (because I'm French), I always try to minimize the risk first (also because I'm French), keeping as close from 0 as possible (French again)
Then I add the "opportunity" component, looking to catch the maximum of opportunity while keeping the risk low.
It's like a Rubix cube puzzle - decreasing the risk is one side of the equation but whenever I try to catch more opportunity... my risks increases.
Then I update my risk... and now the opportunity decreases... (#wut #wen #simple)
Completely removing the risk from a trading strategy isn't something I wouldn't dare doing.
Trading involves risk. Being obsessed by decreasing the risk is what I do BEST :)
Dave
BTC strategy for margin tradingAlmost identical to the one I published before, but this one includes short orders as well.
I didn't spend much time backtesting, so there may be a different set of parameters that gives better results. Please let me know if you find something!
BFXLS100This is the popular Bitfinex margin Longs/Shorts overlay script made compatible with other exchanges. So you can for example use it with BitMEXT XBTUSD and it will still plot Bitfinex BTCUSD.
It always plots data for the same currency pair, so for ETHUSD of any exchange, it will always plot Bitfinex ETHUSD margin data.
Bitcoin Shorts and LongsThis indicator shows the volume of shorts and longs for margin trading in Bitfinex.
BTC Margin Sniper w/ AlertsMargin Sniper uses 2 levels for overbought and oversold to overlay possible trades on the chart. You can adjust its sensitivity by either increasing or decreasing the overbought and oversold threshold numbers. It must meet one of these levels and the short-term trend has to change direction for it to create the alert and entry on the overlay.
Increasing the overbought input makes the trigger more precise, but it may not trigger as often. Decreasing the oversold input will do the same for that trigger.
You can adjust the alerts and the overlaid position suggestions to match your preferred leverage amount.
To set an alert, click "add alert", then select this script. Choose one of the oversold or overbought alerts and enter your message.
I primarily use this on BitMEX with BTC, but you can use it with other exchanges and coins. You may have to adjust the inputs depending on the coin and the timeframe you use. Do not blindly follow this to make purchases. This is just an alert system to notify you of possible trades.
LTCUSD LONGS & SHORTS Bitfinex (margin traders)It is the interpretation of margin positions LTCUSD. Data — Bitfinex