PineConnectorLibrary "PineConnector"
This library is a comprehensive alert webhook text generator for PineConnector. It contains every possible alert syntax variation from the documentation, along with some debugging functions.
To use it, just import the library (eg. "import ZenAndTheArtOfTrading/PineConnector/1 as pc") and use pc.buy(licenseID) to send an alert off to PineConnector - assuming all your webhooks etc are set up correctly.
View the PineConnector documentation for more information on how to send the commands you're looking to send (all of this library's function names match the documentation).
all()
Usage: pc.buy(pc_id, freq=pc.all())
Returns: "all"
once_per_bar()
Usage: pc.buy(pc_id, freq=pc.once_per_bar())
Returns: "once_per_bar"
once_per_bar_close()
Usage: pc.buy(pc_id, freq=pc.once_per_bar_close())
Returns: "once_per_bar_close"
na0(value)
Checks if given value is either 'na' or 0. Useful for streamlining scripts with float user setting inputs which default values to 0 since na is unavailable as a user input default.
Parameters:
value (float) : The value to check
Returns: True if the given value is 0 or na
getDecimals()
Calculates how many decimals are on the quote price of the current market.
Returns: The current decimal places on the market quote price
truncate(number, decimals)
Truncates the given number. Required params: mumber.
Parameters:
number (float) : Number to truncate
decimals (int) : Decimal places to cut down to
Returns: The input number, but as a string truncated to X decimals
getPipSize(multiplier)
Calculates the pip size of the current market.
Parameters:
multiplier (int) : The mintick point multiplier (1 by default, 10 for FX/Crypto/CFD but can be used to override when certain markets require)
Returns: The pip size for the current market
toWhole(number)
Converts pips into whole numbers. Required params: number.
Parameters:
number (float) : The pip number to convert into a whole number
Returns: The converted number
toPips(number)
Converts whole numbers back into pips. Required params: number.
Parameters:
number (float) : The whole number to convert into pips
Returns: The converted number
debug(txt, tooltip, displayLabel)
Prints to console and generates a debug label with the given text. Required params: txt.
Parameters:
txt (string) : Text to display
tooltip (string) : Tooltip to display (optional)
displayLabel (bool) : Turns on/off chart label (default: off)
Returns: Nothing
order(licenseID, command, symbol, parameters, accfilter, comment, secret, freq, debug)
Generates an alert string. Required params: licenseID, command.
Parameters:
licenseID (string) : Your PC license ID
command (string) : Command to send
symbol (string) : The symbol to trigger this order on
parameters (string) : Other optional parameters to include
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: An alert string with valid PC syntax based on supplied parameters
market_order(licenseID, buy, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a market entry alert with relevant syntax commands. Required params: licenseID, buy, risk.
Parameters:
licenseID (string) : Your PC license ID
buy (bool) : true=buy/long, false=sell/short
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A market order alert string with valid PC syntax based on supplied parameters
buy(licenseID, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a market buy alert with relevant syntax commands. Required params: licenseID, risk.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A market order alert string with valid PC syntax based on supplied parameters
sell(licenseID, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a market sell alert with relevant syntax commands. Required params: licenseID, risk.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A market order alert string with valid PC syntax based on supplied parameters
closeall(licenseID, comment, secret, freq, debug)
Closes all open trades at market regardless of symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closealleaoff(licenseID, comment, secret, freq, debug)
Closes all open trades at market regardless of symbol, and turns the EA off. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closelong(licenseID, symbol, comment, secret, freq, debug)
Closes all long trades at market for the given symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closeshort(licenseID, symbol, comment, secret, freq, debug)
Closes all open short trades at market for the given symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closelongshort(licenseID, symbol, comment, secret, freq, debug)
Closes all open trades at market for the given symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closelongbuy(licenseID, risk, symbol, comment, secret, freq, debug)
Close all long positions and open a new long at market for the given symbol with given risk/contracts. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : Risk or contracts (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closeshortsell(licenseID, risk, symbol, comment, secret, freq, debug)
Close all short positions and open a new short at market for the given symbol with given risk/contracts. Required params: licenseID, risk.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : Risk or contracts (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
newsltplong(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any open long trades on the given symbol with the given values. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
newsltpshort(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any open short trades on the given symbol with the given values. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closelongpct(licenseID, symbol, comment, secret, freq, debug)
Close a percentage of open long positions (according to EA settings). Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closeshortpct(licenseID, symbol, comment, secret, freq, debug)
Close a percentage of open short positions (according to EA settings). Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closelongvol(licenseID, risk, symbol, comment, secret, freq, debug)
Close all open long contracts on the current symbol until the given risk value is remaining. Required params: licenseID, risk.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : The quantity to leave remaining
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
closeshortvol(licenseID, risk, symbol, comment, secret, freq, debug)
Close all open short contracts on the current symbol until the given risk value is remaining. Required params: licenseID, risk.
Parameters:
licenseID (string) : Your PC license ID
risk (float) : The quantity to leave remaining
symbol (string) : Symbol to act on (defaults to current symbol)
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
limit_order(licenseID, buy, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a limit order alert with relevant syntax commands. Required params: licenseID, buy, price, risk.
Parameters:
licenseID (string) : Your PC license ID
buy (bool) : true=buy/long, false=sell/short
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A limit order alert string with valid PC syntax based on supplied parameters
buylimit(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a buylimit order alert with relevant syntax commands. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A limit order alert string with valid PC syntax based on supplied parameters
selllimit(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a selllimit order alert with relevant syntax commands. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A limit order alert string with valid PC syntax based on supplied parameters
stop_order(licenseID, buy, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a stop order alert with relevant syntax commands. Required params: licenseID, buy, price, risk.
Parameters:
licenseID (string) : Your PC license ID
buy (bool) : true=buy/long, false=sell/short
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
buystop(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a buystop order alert with relevant syntax commands. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
sellstop(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Generates a sellstop order alert with relevant syntax commands. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancel_neworder(licenseID, order, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Cancel + place new order template function.
Parameters:
licenseID (string) : Your PC license ID
order (string) : Cancel order type
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancellongbuystop(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Cancels all long orders with the specified symbol and places a new buystop order. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancellongbuylimit(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Cancels all long orders with the specified symbol and places a new buylimit order. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancelshortsellstop(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Cancels all short orders with the specified symbol and places a sellstop order. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancelshortselllimit(licenseID, price, risk, sl, tp, betrigger, beoffset, spread, trailtrig, traildist, trailstep, atrtimeframe, atrperiod, atrmultiplier, atrshift, atrtrigger, symbol, accfilter, comment, secret, freq, debug)
Cancels all short orders with the specified symbol and places a selllimit order. Required params: licenseID, price, risk.
Parameters:
licenseID (string) : Your PC license ID
price (float) : Price or pips to set limit order (according to EA settings)
risk (float) : Risk quantity (according to EA settings)
sl (float) : Stop loss distance in pips or price
tp (float) : Take profit distance in pips or price
betrigger (float) : Breakeven will be activated after the position gains this number of pips
beoffset (float) : Offset from entry price. This is the amount of pips you'd like to protect
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips
trailtrig (float) : Trailing stop-loss will be activated after a trade gains this number of pips
traildist (float) : Distance of the trailing stop-loss from current price
trailstep (float) : Moves trailing stop-loss once price moves to favourable by a specified number of pips
atrtimeframe (int) : ATR Trailing Stop timeframe, only updates once per bar close. Options: 1, 5, 15, 30, 60, 240, 1440
atrperiod (int) : ATR averaging period
atrmultiplier (float) : Multiple of ATR to utilise in the new SL computation, default = 1
atrshift (int) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default = 0
atrtrigger (int) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default = 0 (instant)
symbol (string) : The symbol to trigger this order on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment (maximum 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A stop order alert string with valid PC syntax based on supplied parameters
cancellong(licenseID, symbol, accfilter, comment, secret, freq, debug)
Cancels all pending long orders with the specified symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A cancel long alert command
cancelshort(licenseID, symbol, accfilter, comment, secret, freq, debug)
Cancels all pending short orders with the specified symbol. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: A cancel short alert command
newsltpbuystop(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any pending buy stop orders on the given symbol. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
newsltpbuylimit(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any pending buy limit orders on the given symbol. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
newsltpsellstop(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any pending sell stop orders on the given symbol. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
newsltpselllimit(licenseID, sl, tp, symbol, accfilter, comment, secret, freq, debug)
Updates the stop loss and/or take profit of any pending sell limit orders on the given symbol. Required params: licenseID, sl and/or tp.
Parameters:
licenseID (string) : Your PC license ID
sl (float) : Stop loss pips or price (according to EA settings)
tp (float) : Take profit pips or price (according to EA settings)
symbol (string) : Symbol to act on (defaults to current symbol)
accfilter (float) : Optional minimum account balance filter
comment (string) : Optional comment to include (max 20 characters)
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
eaoff(licenseID, secret, freq, debug)
Turns the EA off. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
eaon(licenseID, secret, freq, debug)
Turns the EA on. Required params: licenseID.
Parameters:
licenseID (string) : Your PC license ID
secret (string) : Optional secret key (must be enabled in dashboard)
freq (string) : Alert frequency. Default = "all", options = "once_per_bar", "once_per_bar_close" and "none"
debug (bool) : Turns on/off debug label
Returns: The required alert syntax as a string
Tradingbot
Session Breakout Scalper Trading BotHi Traders !
Introduction:
I have recently been exploring the world of automated algorithmic trading (as I prefer more objective trading strategies over subjective technical analysis (TA)) and would like to share one of my automation compatible (PineConnecter compatible) scripts “Session Breakout Scalper”.
The strategy is really simple and is based on time conditional breakouts although has more ”relatively” advanced optional features such as the regime indicators (Regime Filters) that attempt to filter out noise by adding more confluence states and the ATR multiple SL that takes into account volatility to mitigate the down side risk of the trade.
What is Algorthmic Trading:
Firstly what is algorithmic trading? Algorithmic trading also known as algo-trading, is a method of using computer programs (in this case pine script) to execute trades based on predetermined rules and instructions (this trading strategy). It's like having a robot trader who follows a strict set of commands to buy and sell assets automatically, without any human intervention.
Important Note:
For Algorithmic trading the strategy will require you having an essential TV subscription at the minimum (so that you can set alerts) plus a PineConnecter subscription (scroll down to the .”How does the strategy send signals” headings to read more)
The Strategy Explained:
Is the Time input true ? (this can be changed by toggling times under the “TRADE MEDIAN TIMES” group for user inputs).
Given the above is true the strategy waits x bars after the session and then calculates the highest high (HH) to lowest low (LL) range. For this box to form, the user defined amount of bars must print after the session. The box is symmetrical meaning the HH and LL are calculated over a lookback that is equal to the sum of user defined bars before and after the session (+ 1).
The Strategy then simultaneously defines the HH as the buy level (green line) and the LL as the sell level (red line). note the strategy will set stop orders at these levels respectively.
Enter a buy if price action crosses above the HH, and then cancel the sell order type (The opposite is true for a stop order).
If the momentum based regime filters are true the strategy will check for the regime / regimes to be true, if the regime if false the strategy will exit the current trade, as the regime filter has predicted a slowing / reversal of momentum.
The image below shows the strategy executing these trading rules ( Regime filters, "Trades on chart", "Signal & Label" and "Quantity" have been omitted. "Strategy label plots" has been switched to true)
Other Strategy Rules:
If a new session (time session which is user defined) is true (blue vertical line) and the strategy is currently still in a trade it will exit that trade immediately.
It is possible to also set a range of percentage gain per day that the strategy will try to acquire, if at any point the strategy’s profit is within the percentage range then the position / trade will be exited immediately (This can be changed in the “PERCENT DAY GAIN” group for user inputs)
Stops and Targets:
The strategy has either static (fixed) or variable SL options. TP however is only static. The “STRAT TP & TP” group of user inputs is responsible for the SL and TP values (quoted in pips). Note once the ATR stop is set to true the SL values in the above group no longer have any affect on the SL as expected.
What are the Regime Filters:
The Larry Williams Large Trade Index (LWLTI): The Larry Williams Large Trade Index (LWTI) is a momentum-based technical indicator developed by iconic trader Larry Williams. It identifies potential entries and exits for trades by gauging market sentiment, particularly the buying and selling pressure from large market players. Here's a breakdown of the LWTI:
LWLTI components and their interpretation:
Oscillator: It oscillates between 0 and 100, with 50 acting as the neutral line.
Sentiment Meter: Values above 75 suggest a bearish market dominated by large selling, while readings below 25 indicate a bullish market with strong buying from large players.
Trend Confirmation: Crossing above 75 during an uptrend and below 25 during a downtrend confirms the trend's continuation.
The Andean Oscillator (AO) : The Andean Oscillator is a trend and momentum based indicator designed to measure the degree of variations within individual uptrends and downtrends in the prices.
Regime Filter States:
In trading, a regime filter is a tool used to identify the current state or "regime" of the market.
These Regime filters are integrated within the trading strategy to attempt to lower risk (equity volatility and/or draw down). The regime filters have different states for each market order type (buy and sell). When the regime filters are set to true, if these regime states fail to be true the trade is exited immediately.
For Buy Trades:
LWLTI positive momentum state: Quotient of the lagged trailing difference and the ATR > 50
AO positive momentum state: Bull line > Bear line (signal line is omitted)
For Sell Trades:
LWLTI negative momentum stat: Quotient of the lagged trailing difference and the ATR < 50
AO negative momentum state: Bull line < Bear line (signal line is omitted)
How does the Strategy Send Signals:
The strategy triggers a TV alert (you will neet to set a alert first), TV then sends a HTTP request to the automation software (PineConnecter) which receives the request and then communicates to an MT4/5 EA to automate the trading strategy.
For the strategy to send signals you must have the following
At least a TV essential subscription
This Script added to your chart
A PineConnecter account, which is paid and not free. This will provide you with the expert advisor that executes trades based on these strategies signals.
For more detailed information on the automation process I would recommend you read the PineConnecter documentation and FAQ page.
Dashboard:
This Dashboard (top right by defualt) lists some simple trading statistics and also shows when a trade is live.
Important Notice:
- USE THIS STRATEGY AT YOUR OWN RISK AND ALWAYS DO YOUR OWN RESEARCH & MANUAL BACKTESTING !
- THE STRATEGY WILL NOT EXHIBIT THE BACKTEST PERFORMANCE SEEN BELOW IN ALL MARKETS !
SuperTrend Multi Time Frame Long and Short Trading Strategy
Hello All
This is non-repainting Supertrend Multi Time Frame script, I got so many request on Supertrend with Multi Time Frame. This is for all of them ..I am making it open for all so you can change its coding according to your need.
How the Basic Indicator works
SuperTrend is one of the most common ATR based trailing stop indicators.
In this version you can change the ATR calculation method from the settings. Default method is RMA.
The indicator is easy to use and gives an accurate reading about an ongoing trend. It is constructed with two parameters, namely period and multiplier. The default values used while constructing a Supertrend indicator are 10 for average true range or trading period and three for its multiplier.
The average true range (ATR) plays an important role in 'Supertrend' as the indicator uses ATR to calculate its value. The ATR indicator signals the degree of price volatility .
The buy and sell signals are generated when the indicator starts plotting either on top of the closing price or below the closing price. A buy signal is generated when the ‘Supertrend’ closes above the price and a sell signal is generated when it closes below the closing price.
It also suggests that the trend is shifting from descending mode to ascending mode. Contrary to this, when a ‘Supertrend’ closes above the price, it generates a sell signal as the colour of the indicator changes into red.
A ‘Supertrend’ indicator can be used on spot, futures, options or forex, or even crypto markets and also on daily, weekly and hourly charts as well, but generally, it fails in a sideways-moving market.
How the Strategy works
This is developed based on SuperTrend.
Use two time frame for confirm all entry signals.
Two time frame SuperTrend works as Trailing stop for both long and short positions.
More securely execute orders, because it is wait until confine two time frames(example : daily and 30min)
Each time frame developed as customisable for user to any timeframe.
User can choose trading position side from Long, Short, and Both.
Custom Stop Loss level, user can enter Stop Loss percentage based on timeframe using.
Multiple Take Profit levels with customisable TP price percentage and position size.
Back-testing with custom time frame.
This strategy is develop for specially for automation purpose.
The strategy includes:
Entry for Long and Short.
Take Profit.
Stop Loss.
Trailing Stop Loss.
Position Size.
Exit Signal.
Risk Management Feature.
Backtesting.
Trading Alerts.
Use the strategy with alerts
This strategy is alert-ready. All you have to do is:
Go on a pair you would like to trade
Create an alert
Select the strategy as a Trigger
Wait for new orders to be sent to you
This is develop for specially for automating trading on any exchange, if you need to get that automating service for this strategy or any Tradingview strategy or indicator please contact me I am have 8 year experience on that field.
I hope you enjoy it!
Thanks,
Ranga
Gucci Sniper Trading Bot [Open]A simple Buy/Sell signal algo designed for a trading bot.
Uses ATR and EMA cross to get signals.
Keltner Channel - Trend Based StrategyThis strategy is based on 3 main indicators.
1st indicator is a trend indicator, which consists of SMA and EMA
2nd is Keltner Channel
3rd is DM indicator.
The conditions for the entry of this strategy are following:
First of all the assets need to be in an upward trend, this will occur when the EMA will cross SMA. The next condition for the entry is the opening and the closure of the candle. The open price of the candle should be in the upper part of the Keltner Channel and the close price should be above the Keltner channel. The third condition for the DM indicator is to be above a certain benchmakr. This benchmark can be set in the settings of the strategy.
The strategy has two potential Take Profit levels and single stop-loss levels. For the more efficient way you may try an use the trailing stop or extend the number of take-profit levels.
Ichimoku Cloud Strategy Long Only [Bitduke]Slightly modificated and optimized for Pine Script 4.0, Ichimoku Cloud Strategy which, suddenly, good suitable for the several crypto assets.
Details:
Enter position when conversion line crosses base line up, and close it when the opposite happens.
Additional condition for open / close the trade is lagging span, it should be higher than cloud to open position and below - to close it.
Backtesting:
Backtested on SOLUSDT ( FTX, Binance )
+150% for 2021 year, 8% dd
+191% for all time, 32% dd
Disadvantages:
- Small number of trades
- Need to vary parameters for different coins (not very robust)
Should be tested carefully for other coins / stock market. Different parameters could be needed or even algo modifications.
Strategy doesn't repaint.
Donchian Channel Strategy [for free bot]
I present to you a script for testing the Donchian channel breakout strategy for the Binance_exchange.
This strategy is trending, and is especially effective for trading cryptocurrency futures.
This strategy is very flexible, and you can configure virtually all possible parameters, moreover, separately for longs and separately for shorts.
In the script, you can configure the parameters of the channel for entry and exit, the exit method, enable or disable purchases / sales, specify take profit and stop loss, and more.
On the example of optimization, only 20% of the deposit is used. This is done for diversification, since there are 37 contracts on binance_futures (at the time of writing the script description). That is, by optimizing the parameters for different currencies, you can very well reduce risks.
Представляю Вам скрипт для тестирования стратегии пробоя канала Дончиана для биржи Бинанс.
Данная стратегия относится к трендовым, и особенно эффективная на торговли криптовалютных фьючерсов.
Данная стратегия очень гибкая, и можно настроить фактически все возможные параметры, при чем, отдельно для покупок и отдельно для продаж.
В скрипте можно настроить параметры канала на вход и на выход, метод выхода, разрешить или запретить покупки/проаджи, указать тейк-профит и стоп-лосс и другое.
На примере оптимизации используется всего 20% от депозита. Это сделано для диверсификации, так как на фьючерсах бинансе присутсвует 37 контрактов (на момент написания описания скрипта). Т.е., оптимизировав параметры под разные валюты, можно очень хорошо снизить риски.
HatiKO EnvelopesPublished source code is subject to the terms of the GNU Affero General Public License v3.0
This script describes and provides backtesting functionality to internal strategy of algorithmic crypto trading software "HatiKO bot".
Suitable for backtesting any Cryptocurrency Pair on any Exchange/Platform, any Timeframe.
Core Mechanics of this strategy are based on theory of price always returning to Moving Average + Envelopes indicator (Moving_average_envelope from Wiki)
Developement of this script and trading software is inspired by:
"Essential Technical Analysis: Tools and Techniques to Spot Market Trends" by Leigh Stevens (published on 12th of April 2002)
"Moving Average Envelopes" by ChartSchool, StockCharts platform (published on 13th of April 2015 or earlier)
"Коля Колеснік" from Crypto Times channel ("Метод сетка", published on 19th of August 2018)
"3 ways to use Moving Average Envelopes" by Rich Fitton, published on Trader's Nest (published on 28st of November 2018 or earlier)
noro's "Robot WhiteBox ShiftMA" strategy v1 script, published on TradingView platform (published on 29th of August 2018)
"Moving Average Envelopes: A Popular Trading Tool" Investopedia article (published 25th of June 2019)
and KROOL1980's blogpost on Argolabs ("Гридерство или Сетка как источник прибыли на форекс", published on 27th of February 2015)
Core Features:
1) Up to 4 Envelopes in each direction (Long/Short)
2) Use any of 6 different basis MAs, optionally use different MAs for Opening and Closure
3) Use different Timeframes for MA calculation, without any repainting and lookahead bias.
4) Fixed order size, not Martingale strategy
5) Close open position earlier by using Deviation parameter
6) PineScript v4 code
Options description:
Lot - % from your initial balance to use for order size calculation
Timeframe Short - Timeframe to use for Short Opening MA calculation, can be chosen from dropdown list, default is Current Graph Timeframe
MA Type Short - Type of MA to use for Short Opening MA calculation, can be chosen from dropdown list, default is SMA
Data Short - Source of Price for Short Opening MA calculation, can be chosen from dropdown list, default is OHLC4
MA Length Short - Period used for Short Opening MA calculation, should be >=1, default is 3
MA offset Short - Offset for MA value used for Short Envelopes calculation, should be >= 0, default is 0
Timeframe Long - Timeframe to use for Long Opening MA calculation, can be chosen from dropdown list, default is Current Graph Timeframe
MA Type Long - Type of MA to use for Long Opening MA calculation, can be chosen from dropdown list, default is SMA
Data Long - Source of Price for Long Opening MA calculation, can be chosen from dropdown list, default is OHLC4
MA Length Long - Period used for Long Opening MA calculation, should be >=1, default is 3
MA offset Long - Offset for MA value used for Long Envelopes calculation, should be >= 0, default is 0
Mode close MA Short - Enable different MA for Short position Closure, default is "false". If false, Closure MA = Opening MA
Timeframe Short Close - Timeframe to use for Short Position Closure MA calculation, can be chosen from dropdown list, default is Current Graph Timeframe
MA Type Close Short - Type of MA to use for Short Position Closure MA calculation, can be chosen from dropdown list, default is SMA
Data Short Close - Source of Price for Short Closure MA calculation, can be chosen from dropdown list, default is OHLC4
MA Length Short Close - Period used for Short Opening MA calculation, should be >=1, default is 3
Short Deviation - % to move from MA value, used to close position above or beyond MA, can be negative, default is 0
MA offset Short Close - Offset for MA value used for Short Position Closure calculation, should be >= 0, default is 0
Mode close MA Long - Enable different MA for Long position Closure, default is "false". If false, Closure MA = Opening MA
Timeframe Long Close - Timeframe to use for Long Position Closure MA calculation, can be chosen from dropdown list, default is Current Graph Timeframe
MA Type Close Long - Type of MA to use for Long Position Closure MA calculation, can be chosen from dropdown list, default is SMA
Data Long Close - Source of Price for Long Closure MA calculation, can be chosen from dropdown list, default is OHLC4
MA Length Long Close - Period used for Long Opening MA calculation, should be >=1, default is 3
Long Deviation - % to move from MA value, used to close position above or beyond MA, can be negative, default is 0
MA offset Long Close - Offset for MA value used for Long Position Closure calculation, should be >= 0, default is 0
Short Shift 1..4 - % from MA value to put Envelopes at, for Shorts numbers should be positive, the higher is number, the higher should be Shift position, example: "Shift 1 = 1, shift 2 = 2, etc."
Long Shift 1..4 - % from MA value to put Envelopes at, for Longs numbers should be negative, the lower is number, the lower should be Shift position, example: "Shift 1 = -1, shift 2 = -2, etc."
From Year 20XX - Backtesting Starting Year number, only 20xx supported as script is cryptocurrency-oriented.
To Year 20XX - Backtesting Final Year number, only 20xx supported as script is cryptocurrency-oriented.
From Month - Years starting Month, optional tweaking, changing not recommended
To Month - Years ending Month, optional tweaking, changing not recommended
From day - Months starting day, optional tweaking, changing not recommended
To day - Months ending day, optional tweaking, changing not recommended
Graph notes:
Green lines - Long Envelopes.
Red lines - Short Envelopes.
Orange line - MA for closing of Short positions.
Lime line - MA for closing of Long positions.
**************************************************************************************************************************************************************************************************************
Опубликованный исходный код регулируется Условиями Стандартной Общественной Лицензии GNU Affero v3.0
Этот скрипт описывает и предоставляет функции бектеста для внутренней стратегии алгоритмического программного обеспечения "HatiKO bot".
Подходит для тестирования любой криптовалютной пары на любой бирже/платформе, на любом таймфрейме.
Кор-механика этой стратегии основана на теории всегда возвращающейся к значению МА цены с использованием индикатора Envelopes (Moving_average_envelope from Wiki)
Разработка этого скрипта и программного обеспечения для торговли вдохновлена следующими источниками:
Книга "Essential Technical Analysis: Tools and Techniques to Spot Market Trends" Ли Стивенса (опубликовано 12 апреля 2002 года)
«Moving Average Envelopes» от ChartSchool, платформа StockCharts (опубликовано 13 апреля 2015 года или раньше)
«Коля Колеснік» с канала Crypto Times («Метод сетка», опубликовано 19 августа 2018 года)
«3 ways to use Moving Average Envelopes» Рича Фиттона, опубликованные в «Trader's Nest» (опубликовано 28 ноября 2018 года или раньше)
Скрипт стратегии noro "Robot WhiteBox ShiftMA" v1, опубликованный на платформе TradingView(опубликовано 29 августа 2018 года)
«Moving Average Envelopes: A Popular Trading Tool», статья Investopedia (опубликовано 25 июня 2019 года)
Блог KROOL1980 из Argolabs («Гридерство или Сетка как источник прибыли на форекс», опубликовано 27 февраля 2015 года)
Основные особенности:
1) До 4-х Ордеров в каждом из направлении (Лонг / Шорт)
2) Выбор из 6-ти разных базовых МА, опционально используйте разные МА для открытия и закрытия.
3) Используйте разные таймфреймы для расчета MA, без перерисовки и "эффекта стеклянного шара".
4) Фиксированный размер ордера, а не стратегия Мартингейла
5) Возможность закрытия открытой позиции заблаговременно, используя параметр Deviation
6) Код реализован на PineScript v4
Описание параметров:
Lot - % от вашего первоначального баланса, используется при расчете размера Ордера
Timeframe Short - таймфрейм, используемый для расчета МА Открытия Шорт позиций, может быть выбран из списка, по умолчанию - таймфрейм текущего графика
MA Type Short - тип MA, используемый для расчета МА Открытия Шорт позиций, может быть выбран из списка, по умолчанию SMA
Data Short - источник цены для расчета МА Открытия Шорт позиций, может быть выбран из списка, по умолчанию OHLC4
MA Length Short - период, используемый для расчета МА Открытия Шорт позиций, должен быть >= 1, по умолчанию 3
MA Offset Short - смещение значения MA, используемого для расчета Шорт Ордеров, должно быть >= 0, по умолчанию 0
Timeframe Long - таймфрейм, используемый для расчета МА Открытия Лонг позиций, может быть выбран из списка, по умолчанию - таймфрейм текущего графика
MA Type Long - тип MA, используемый для расчета МА Открытия Лонг позиций, может быть выбран из списка, по умолчанию SMA
Data Long - источник цены для расчета МА Открытия Лонг позиций, может быть выбран из списка, по умолчанию OHLC4
MA Length Long - период, используемый для расчета МА Открытия Лонг позиций, должен быть >= 1, по умолчанию 3
MA Offset Long - смещение значения MA, используемого для расчета Лонг Ордеров, должно быть >= 0, по умолчанию 0
Mode close MA Short - Включает отдельное MA для закрытия Шорт позиции, по умолчанию «false». Если false, MA Закрытия = MA Открытия
Timeframe Short Close - таймфрейм, используемый для расчета МА Закрытия Шорт позиций, может быть выбран из списка, по умолчанию - таймфрейм текущего графика
MA Type Close Short - тип MA, используемый при расчете МА Закрытия Шорт позиции. Mожно выбрать из списка, по умолчанию SMA
Data Short Close - источник цены для расчета МА Закрытия Шорт позиций, может быть выбран из списка, по умолчанию OHLC4
MA Length Short Close - период, используемый для расчета МА Закрытия Шорт позиции, должен быть >= 1, по умолчанию 3
Short Deviation - % отклонения от значения MA, используется для закрытия позиции выше или ниже рассчитанного значения MA, может быть отрицательным, по умолчанию 0
MA Offset Short Close - смещение значения MA, используемого для расчета закрытия Шорт позиции, должно быть >= 0, по умолчанию 0
Mode close MA Long - Включает разные MA для закрытия Лонг позиции, по умолчанию «false». Если false, MA Закрытия = MA Открытия
Timeframe Long Close - таймфрейм, используемый для расчета МА Закрытия Лонг позиций, может быть выбран из списка, по умолчанию - таймфрейм текущего графика
MA Type Close Long - тип MA, используемый при расчете МА Закрытия Лонг позиции. Mожно выбрать из списка, по умолчанию SMA
Data Long Close - источник цены для расчета МА Закрытия Лонг позиций, может быть выбран из списка, по умолчанию OHLC4
MA Length Long Close - период, используемый для расчета МА Закрытия Лонг позиции, должен быть >= 1, по умолчанию 3
Long Deviation -% для перехода от значения MA, используется для закрытия позиции выше или ниже рассчитанного значения MA, может быть отрицательным, по умолчанию 0
MA Offset Long Close - смещение значения MA, используемого для расчета закрытия Лонг позиции, должно быть >= 0, по умолчанию 0
Short Shift 1..4 - % от значения MA для размещения Ордеров, для Шорт Ордеров должен быть положительным, чем выше номер, тем выше должна располагаться позиция Shift, например: «Shift 1 = 1, Shift 2 = 2 и т.д. "
Long Shift 1..4 - % от значения MA для размещения Ордеров, для Лонг Ордеров должно быть отрицательным, чем ниже число, тем ниже должна располагаться позиция Shift, например: «Shift 1 = -1, Shift 2 = -2, и т.д."
From Year 20XX - Год начала тестирования, из-за ориентированности на криптовалюты поддерживаются только значения формата 20хх.
To Year 20XX - Год окончания тестирования, из-за ориентированности на криптовалюты поддерживаются только значения формата 20хх.
From Month - Начальный месяц, опционально, менять не рекомендуется
To Month - Конечный месяц, опционально, менять не рекомендуется
From day - Начальный день месяца, опционально, менять не рекомендуется
To day - Конечный день месяца, опционально, менять не рекомендуется
Пояснения к графику:
Зеленые линии - Лонг Ордера.
Красные линии - Шорт Ордера.
Оранжевая линия - MA Закрытия Шорт позиций.
Лаймовая линия - MA Закрытия Лонг позиций.
Detect Sequential Trading - Bot DetectorDetect Sequential Trading - Bot Detector.
This tool requires access to volume data .
There are many trading bots out there, that trade 24/7 .
The detector can be used to understand how the bots are configured - to push the market up or down .
Alerts can be set to fire whenever a bot pattern is detected .
They must be configured to run Once per Bar .
It works well with range charts (1R) .
It would work best on 1 second charts or tick charts (currently, TradingView's alert system doesn't work with second charts).
The alternative would be 1 minute charts .
It can be used on higher timeframes but may be less effective.
TradersAI_UTBotCREDITS to @HPotter for the orginal code.
CREDITS to @Yo_adriiiiaan for recently publishing the UT Bot study based on the original code -
I just added some simple code to turn it into a strategy. Now, anyone can simply add the strategy to their chart to see the backtesting results!
While @Yo_adriiiiaan mentions it works best on a 4-hour timeframe or above, I am happy to share that this seems to be working on a 15-minute chart on e-mini S&P 500 Index (using the KeyValue setting at 10)! You can play around with the different settings, and may be you might discover even better settings.
Hope this helps. Btw, if any of you play with different settings and discover great settings for a specific instrument, please share them with the community here - it will be rewarded back multiple times!