LevelsManagerLibrary "LevelsManager"
TODO: Track up to 6 TakeProfits and 1 StopLoss achievement for one or many of your buy/sell conditions.
manageTrade(bool, bool, bool, string, string, float, float, bool, bool, bool, bool, bool, bool, float, float, float, float, float, float, float)
Track TakeProfits and StopLoss achievement for one or many of your buy/sell conditions. CHECK the commented section: "Function @manageTrade" for Description
Parameters:
bool : useSignal.
bool : b_gameOVer.
bool : b_gameOVer.
string : bName.
string : sName.
float : buyEntrySource.
float : sellEntrySource.
bool : useTp1.
bool : useTp2.
bool : useTp3.
bool : useTp4.
bool : useTp5.
bool : useTp6.
float : tp1x.
float : tp2x.
float : tp3x.
float : tp4x.
float : tp5x.
float : tp6x.
float : slx.
Returns: check commented section: "Function @manageTrade".
showOnlyFirstOccurence(booleanInput)
Single out the occurence of a bool series between to 2 bool series.
Parameters:
booleanInput : to activate or deactivate occurences filtering.
Returns: filterred or not bool series.
Alerts
CalculatePercentageSlTpLibrary "CalculatePercentageSlTp"
This Library calculate the sl and tp amount in percentage
sl_percentage(entry_price, sl_price)
this function calculates the sl value in percentage
Parameters:
entry_price : indicates the entry level
sl_price : indicates the stop loss level
Returns: stop loss in percentage
tp_percentage(entry_price, tp_price)
this function calculates the tp value in percentage
Parameters:
entry_price : indicates the entry level
tp_price : indicates the take profit level
Returns: take profit in percentage
sl_level(entry_price, sl_percentage)
this function calculates the sl level price
Parameters:
entry_price : indicates the entry level
sl_percentage : indicates the stop loss percentage
Returns: stop loss price in $
tp_level(entry_price, tp_percentage)
this function calculates the tp level price
Parameters:
entry_price : indicates the entry level
tp_percentage : indicates the take profit percentage
Returns: take profit price in $
RouterOrdersIronLibrary "RouterOrdersIron"
Library for routing orders to the Binance exchange.
MsgDoLongMKT(id, symbol, balance)
Returns json for Iron to buy a symbol for the amount of the balance with market order.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoShortMKT(id, symbol, balance)
Returns json for Iron to sell a symbol for the amount of the balance with market order.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoLongLR(id, symbol, balance)
Returns json for Iron to buy a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoShortLR(id, symbol, balance)
Returns json for Iron to sell a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoLongMKT(id, symbol, balance)
Buy a symbol for the amount of the balance. It is send market order to Iron.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoShortMKT(id, symbol, balance)
Sell a symbol for the amount of the balance. It is send market order to Iron.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoLongLR(id, symbol, balance)
Buy a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoShortLR(id, symbol, balance)
Sell a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
GetQty(price, balance)
Get Qty for strategy on balance
Parameters:
price : Order price
balance : The amount for which to carry out the transaction.
Returns: Qty for strategy order TV
RecursiveAlertsLibrary "RecursiveAlerts"
The library provides options to run alert() calls in loop without worrying about limitations of frequency options.
When an alert statement is called within a loop,
it will fire just once per bar irrespective of how many iterations allowed when fequency is set to alert.freq_once_per_bar or alert.freq_once_per_bar_close
it will fire continuously till it breaks when frequency is set to alert.freq_all
The function helps overcome this issue by using varip key array which resets on every bar
rAlert(message, key) Enhanced alert which can be used in loops
Parameters:
message : Alert message to be fired
key : Key to be checked to avoid repetitive alerts
Returns: array containing id of already fired alerts
Thanks to @theheirophant, @JohnBaron and @LucF for discussions and suggestion which eventually lead to this solution :)
TradingHookLibrary "TradingHook"
This library is a client script for making a webhook signal formatted string to TradingHook webhook server.
buy_message(password, amount, order_name) Make a buy Message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
amount : (float) amount. If not set, your strategy qty will be sent.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
sell_message(password, percent, order_name) Make a sell message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
percent : (string) what percentage of your quantity you want to sell.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
You can use TradingHook WebServer open source code in github(github.com)
PlurexSignalIntegrationLibrary "PlurexSignalIntegration"
Provides tools for integrating Strategies and Alerts into plurex.io signals.
plurexMarket() Build a Plurex market from a base and quote asset symbol.
Returns: A market string that can be used in Plurex Signal messages.
tickerToPlurexMarket() Builds simple Plurex market string from the syminfo
Returns: A market string that can be used in Plurex Signal messages.
simpleMessage(secret, action, marketOverride) Builds simple Plurex Signal Messages
Parameters:
secret : The secret for your Signal on plurex
action : The action of the message. One of .
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
Returns: A json string message that can be used in alerts to send messages to Plurex.
executeStrategy(secret, openLong, openShort, closeLongs, closeShorts, marketOverride) Executes strategy actions with Plurex Signal messages
Parameters:
secret : The secret for your Signal on plurex
openLong : Strategy should open long if true, aggregated with other boolean values
openShort : Strategy should open short if true, aggregated with other boolean values
closeLongs : Strategy should close longs if true, aggregated with other boolean values
closeShorts : Strategy should close shorts if true, aggregated with other boolean values
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
AllTimeHighLowLibrary "AllTimeHighLow"
Provides functions calculating the all-time high/low of values.
hi(val) Calculates the all-time high of a series.
Parameters:
val : Series to use (`high` is used if no argument is supplied).
Returns: The all-time high for the series.
lo(val) Calculates the all-time low of a series.
Parameters:
val : Series to use (`low` is used if no argument is supplied).
Returns: The all-time low for the series.
Timed_exit_alert_for_webhookLibrary "Timed_exit_alert_for_webhook"
TODO: add library description here
fun(x) TODO: add function description here
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns
for exiting FCM like Tradovate and AMP using API and python MT5 and Webhooks
the writer take no responsibility for trades made using this script its written for informational purposes only
MakeLoveNotWarLibrary "MakeLoveNotWar"
Make Love Not War, place a flag of support on your chart!
flag(pos, text_size) Make Love Not War function.
Parameters:
pos : string, position.
text_size : string, text size.
Returns: table.
bytimeLibrary "bytime"
TODO: to do something at the specified time.
////Return =>> ht = hour , mt = minute , st = second ,Dt = Day, Mt = month, Yt = year , dateTime = full time format./////////////
Note : Remember to always add import when you call our library and change Gtime() to Timeset.Gtime() is used to access internal data.
import hapharmonic/bytime/1 as Timeset
=Timeset.Gtime()
/////////////Set a time to trigger an alert./////////////
ck = false
///hour : minute : second
if ht == TH and mt == TM and st == TS
//some action
//...
//.
ck := true
Gtime()
LukashereLibrary "Lukashere"
TODO: add library description here
fun(x) TODO: add function description here
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns
Percentual2nu()
getMA()
SymbolsTopMarketcap()
OteHmacSha256Library "OteHmacSha256"
Library to use HMAC SHA-256 by OgahTerkenal
hmac_sha256(string) HMAC SHA-256
Parameters:
string : msg String to be hashed
Returns: Return a hashed string in hex format and an array of 8 32 bits integer
Library to use HMAC SHA-256 for authenticating alert message going out from TradingView.
It has limitation on allowed characters (because PineScript cannot access the underlying bits of each ASCII) from ASCII 32 to 126 only.
Usage Example section at the end of the source code pretty much tell everything about this library.
General example as how to import to your PineScript code is not included (please refer to the PineScript manual).
StocksDeveloper_AutoTraderWebLibrary "StocksDeveloper_AutoTraderWeb"
AutoTrader Web trading API functions implementation for Trading View.
preparePlaceOrderJson(account, symbol, group, variety) Prepare a place order json
Parameters:
account : Pseudo or group account number
symbol : AutoTrader Web's stock/derivative symbol
group : Set it to true to use group account (Default: false)
variety : Variety (Default: REGULAR)
Returns: A json message for the given order data
preparePlaceOrderAlertUsingOrderJson(orderJsonArray) Prepare a place order alert message using order json array
Parameters:
orderJsonArray : Order json can contain one or more orders
Returns: A complete alert message to place orders
preparePlaceOrderAlertMessage(account, symbol, group, variety, validity) Prepare a place order alert json message
Parameters:
account : Pseudo or group account number
symbol : AutoTrader Web's stock/derivative symbol
group : Set it to true to use group account (Default: false)
variety : Variety (Default: REGULAR)
validity : Validity (Default: DAY)
Returns: A complete alert message to place orders
The Divergent LibraryLibrary "TheDivergentLibrary"
The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator . This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.
Usage instructions:
1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent
---
isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Oscillator" or "Price".
getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Bodies" or "Wicks".
isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating the link status to The Divergent indicator.
init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
Parameters:
firstBarSignal : The signal from The Divergent indicator on the first bar.
displayLinkStatus : A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
debug : A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
Returns: A bool array containing the context of The Divergent Library.
processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
Parameters:
signal : The signal from The Divergent indicator.
Returns: A 5-tuple with the following values: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].
options_expiration_and_strike_price_calculatorLibrary "options_expiration_and_strike_price_calculator"
TODO: add library description here
fun()
this is a library to help calculate options strike price and expiration that you can add to a script i use it mainly for symbol calulation to place orders to buy options on TD ameritrade so it will be set up to order options on TD ameritrade using json order placer and webhook it fills in the area in the json under symbol i suggest manually adding the year it should look like this is an example of an order to buy 10 call options using json through td ameritrade api
"complexOrderStrategyType": "NONE",
"orderType": "LIMIT",
"session": "NORMAL",
"price": "6.45",
"duration": "DAY",
"orderStrategyType": "SINGLE",
"orderLegCollection":
}
DiscordWebhookFunctionLibrary "DiscordWebhookFunction"
discordMarkdown(_str, _italic, _bold, _code, _strike, _under) Convert string to markdown formatting User can combine any function at the same time.
Parameters:
_str : String input
_italic : Italic
_bold : Bold
_code : Code markdown
_strike : Strikethrough
_under : Underline
Returns: string Markdown formatted string.
discordWebhookJSON(_username, _avatarImgUrl, _contentText, _bodyTitle, _descText, _bodyUrl, _embedCol, _timestamp, _authorName, _authorUrl, _authorIconUrl, _footerText, _footerIconUrl, _thumbImgUrl, _imageUrl) Convert data to JSON format for Discord Webhook Integration.
Parameters:
_username : Override bot (webhook) username string / name,
_avatarImgUrl : Override bot (webhook) avatar by image URL,
_contentText : Main content page message,
_bodyTitle : Custom Webhook's embed message body title,
_descText : Webhook's embed message body description,
_bodyUrl : Webhook's embed body direct link URL,
_embedCol : Webhook's embed color,
_timestamp : Timestamp,
_authorName : Webhook's embed author name / title,
_authorUrl : Webhook's embed author direct link URL,
_authorIconUrl : Webhook's embed author icon by image URL,
_footerText : Webhook's embed footer text / title,
_footerIconUrl : Webhook's embed footer icon by image URL,
_thumbImgUrl : Webhook's embed thumbnail image URL,
_imageUrl : Webhook's embed body image URL.
Returns: string Single-line JSON format
Algomojo V1.0Library "Algomojo"
This library brings faster access to Automate trades. It simplifies the execution rules and helps
traders to implement faster algo trading strategies.
algomodule()
Smoothed Wave ScalperThis one is a little different.
Instead of layering lots of indicators to filter noise, I'm instead using two different kinds of price averaging to smooth the candles and better define the direction. Just select a smoothing value that fits your chart and timeframe. In theory, this should remove a fair bit of noise (although nothing's perfect)
I've managed to determine when the candles change colour, signifying a potential new trend. When the candle colours do change, an alert is fired. It's as simple as that! Wyckoff wave volume analysis is then applied to each alert to validate the move. Further filtering can be achieved using heikin ashi candles if this is your preference.
Alerts are built in for both the candle colour change and the wave filtered signals (long/short). Use long/short for entries and the colour changes for exits.
I'm currently trading with linear regression to help indentify obvious channels and areas of support/resistance. The candles bouncing down off of the upper band can confirm a downward trend, and bouncing off of the lower band can signify an up trend. It's much easier to see with smoothed candles like these and can give you confidence when trading manually. These bands are rendered automatically, but aren't essential to taking a trade.
TTP MC signalThis signal is based on Market Cipher.
It triggers a 1 for a buy the divergence signal which is less frequent and more conservative.
It triggers a 1.5 for the normal signal which is more frequent and more risky.
It triggers a 2 for a sell signal which is also using a divergence.
You can use this values to backtest.
It contains alerts for each of the separated signals.
TWP Chart Period Breaks█ OVERVIEW
This script plots historical and one future vertical line at the higher timeframe.period time mark of your choosing along with the ability to create alerts that ping on the opening of the new bar on the timeframe and during the market session that you have selected. This script adds body to the default "session breaks" that Tradingview provides within the chart settings. It can be a hassle visually keeping track of time when trading but particularly when day trading. Timing is so important and I needed some visual assistance aka some guard rails for my mind to operate in, in order to better execute my trades. I hope this helps you too.
█ CONCEPTS
The script takes some simple steps to plot vertical lines onto your chart with some extra goodies to go the extra yard.
█ FEATURES
1 — Resolution
• Auto / Manual selection
• There is tooltip explains how the automatic time selection operates (see below)
AUTO_TIMEFRAME_TOOLTIP = "When the Auto option is selected, the timeframe of the indicator is chosen automatically based on the chart timeframe. The Timeframe dropdown is ignored. The automated timeframes are:
'10 minutes' for any chart timeframes below '1 minute'
'1 hour' for any chart timeframes starting from '1 minute' up to '5 minutes'
'4 hours' for any chart timeframes starting from '5 minutes' up to '60 minutes'
'1 day' for any chart timeframes starting from '1 hour' up to '4 hours'
'1 week' for any chart timeframes starting from '4 hours' up to '1 day'
'1 month' for any chart timeframes starting from '1 day' up to '1 week'
'3 months' for any chart timeframes starting from '1 week' up to '1 month'
'12 months' for any chart timeframes above '1 month'"
2 — Show Future Period Line
3 — Number of Historical Lines Back
4 — Line Style
• Line color selection
• Line width selection
5 — Alerts
• Market session selection
█ HOW TO USE
• Add it to your chart, select your timeframe, change up your colors, add your alerts (if necessary) and enjoy yourself!
Drawdown strategy indicatorThis indicator uses drawdown and max drawdown to determine good areas to enter or exit the market.
It uses the ratio between those values and two thresholds provided by the user: top and bottom.
These two values will be used to highlight the areas that match the users strategy criteria.
I normally use this indicator on the 4h or higher timeframes.
On BTC using the default parameters it predicts the tops pretty nicely. The areas of accumulation or buy zones are consistent with the ones that follow each halving.
The chart shows:
- Drawdown
- max drawdown
- drawdown average
- drawdown ratio
- buy and sell zones
The study includes alerts for both buy and sell zones.
MTF - Options Strike Price - Screener & AlertsHi fellow traders ,
Pleased to share an MTF – Option Strike Price Screener.
It Screens 15 tickers for your set Strike Prices in the input column or you can also set the Stop Loss/target prices for your portfolio watch list in a single input window.
All you need to do is attach to any chart and set the periodicity of the to your desired alert() frequency requirement.
Now go to the input settings icon of the script and set your tickers, timeframe and option strike prices or if you would like to track your individual ticker stop loss or target prices!
Set the alert from the menu as usual click - Any alert() function call and bingo you are done!!
In all of 2-3 minutes you can set your Option Strike Alerts or TP’s or SL’s for 15 stocks of your portfolio..
Only a single alert() will track 15 tickers across multiple time frames..
Once your Alert is hit you may need to change the input settings and save as default and again set an alert() and delete the last alert()..
No more opening multiple charts and setting individual time consuming alerts().
Happy trading with TV..