UTSStrategyHelper

TODO: add library description here
stopLossPrice(sig, atr, factor, isLong)
Calculates the stop loss price using a distance determined by ATR multiplied by a factor. Example for Long trade SL: PRICE - (ATR * factor).
Parameters:
sig (float)
atr (float): (float): The value of the atr.
factor (float)
isLong (bool): (bool): The current trade direction.
Returns: (bool): A boolean value.
takeProfitPrice(sig, atr, factor, isLong)
Calculates the take profit price using a distance determined by ATR multiplied by a factor. Example for Long trade TP: PRICE + (ATR * factor). When take profit price is reached usually 50 % of the position is closed and the other 50 % get a trailing stop assigned.
Parameters:
sig (float)
atr (float): (float): The value of the atr.
factor (float)
isLong (bool): (bool): The current trade direction.
Returns: (bool): A boolean value.
trailingStopPrice(initialStopPrice, atr, factor, priceSource, isLong)
Calculates a trailing stop price using a distance determined by ATR multiplied by a factor. It takes an initial price and follows the price closely if it changes in a favourable way.
Parameters:
initialStopPrice (float): (float): The initial stop price which, for consistency also should be ATR * factor behind price: e.g. Long trade: PRICE - (ATR * factor)
atr (float): (float): The value of the atr. Ideally the ATR value at trade open is taken and used for subsequent calculations.
factor (float)
priceSource (float): (float): The current price.
isLong (bool): (bool): The current trade direction.
Returns: (bool): A boolean value.
hasGreaterPositionSize(positionSize)
Determines if the strategy's position size has grown since the last bar.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
hasSmallerPositionSize(positionSize)
Determines if the strategy's position size has decreased since the last bar.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
hasUnchangedPositionSize(positionSize)
Determines if the strategy's position size has changed since the last bar.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
exporthasLongPosition(positionSize)
Determines if the strategy has an open long position.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
hasShortPosition(positionSize)
Determines if the strategy has an open short position.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
hasAnyPosition(positionSize)
Determines if the strategy has any open position, regardless of short or long.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
hasSignal(value)
Determines if the given argument contains a valid value (means not 'na').
Parameters:
value (float): (float): The actual value.
Returns: (bool): A boolean value.
Added:
hasLongPosition(positionSize)
Determines if the strategy has an open long position.
Parameters:
positionSize (float): (float): The size of the position.
Returns: (bool): A boolean value.
Removed:
exporthasLongPosition(positionSize)
Determines if the strategy has an open long position.
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.
Declinazione di responsabilità
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.