TradeLibrary "Trade"
A Trade Tracking Library
Monitor conditions with less code by using Arrays. When your conditions are met in chronologically, a signal is returned and the scanning starts again.
Create trades automatically with Stop Loss, Take Profit and Entry. The trades will automatically track based on the market movement and update when the targets are hit.
Sample Usage
Enter a buy trade when RSI crosses below 70 then crosses above 80 before it crosses 40.
Note: If RSI crosses 40 before 80, No trade will be entered.
rsi = ta.rsi(close, 21)
buyConditions = array.new_bool()
buyConditions.push(ta.crossunder(rsi, 70))
buyConditions.push(ta.crossover(rsi, 80))
buy = Trade.signal(buyConditions, ta.crossunder(rsi, 40))
trade = Trade.new(close-(100*syminfo.mintick), close +(200*syminfo.mintick), condition=buy)
plot(trade.takeprofit, "TP", style=plot.style_circles, linewidth=4, color=color.lime)
alertcondition(trade.tp_hit, "TP Hit")
method signal(conditions, reset)
Signal Conditions
Namespace types: bool
Parameters:
conditions (bool )
reset (bool)
Returns: Boolean: True when all the conditions have occured
method update(this, stoploss, takeprofit, entry)
Update Trade Parameters
Namespace types: Trade
Parameters:
this (Trade)
stoploss (float)
takeprofit (float)
entry (float)
Returns: nothing
method clear(this)
Clear Trade Parameters
Namespace types: Trade
Parameters:
this (Trade)
Returns: nothing
method track(this, _high, _low)
Track Trade Parameters
Namespace types: Trade
Parameters:
this (Trade)
_high (float)
_low (float)
Returns: nothing
new(stoploss, takeprofit, entry, _high, _low, condition, update)
New Trade with tracking
Parameters:
stoploss (float)
takeprofit (float)
entry (float)
_high (float)
_low (float)
condition (bool)
update (bool)
Returns: a Trade with targets and updates if stoploss or takeprofit is hit
new()
New Empty Trade
Returns: an empty trade
Trade
Fields:
stoploss (series__float)
takeprofit (series__float)
entry (series__float)
sl_hit (series__bool)
tp_hit (series__bool)
open (series__integer)
Strategy
Strategy PnL LibraryLibrary "Strategy_PnL_Library"
TODO: This is a library that helps you learn current pnl of open position and use it to create your own dynamic take profit or stop loss rules based on current level of your profit. It should only be used with strategies.
inTrade()
inTrade: Checks if a position is currently open.
Returns: bool: true for yes, false for no.
notInTrade()
inTrade: Checks if a position is currently open. Interchangeable with inTrade but just here for simple semantics.
Returns: bool: true for yes, false for no.
pnl()
pnl: Calculates current profit or loss of position after the commission. If the strategy is not in trade it will always return na.
Returns: float: Current Profit or Loss of position, positive values for profit, negative values for loss.
entryBars()
entryBars: Checks how many bars it's been since the entry of the position.
Returns: int: Returns a int of strategy entry bars back. Minimum value is always corrected to 1 to avoid lookback errors.
pnlvelocity()
pnlvelocity: Calculates the velocity of pnl by following the change in open profit compared to previous bar. If the strategy is not in trade it will always return na.
Returns: float: Returns a float value of pnl velocity.
pnlacc()
pnlacc: Calculates the acceleration of pnl by following the change in profit velocity compared to previous bar. If the strategy is not in trade it will always return na.
Returns: float: Returns a float value of pnl acceleration.
pnljerk()
pnljerk: Calculates the jerk of pnl by following the change in profit acceleration compared to previous bar. If the strategy is not in trade it will always return na.
Returns: float: Returns a float value of pnl jerk.
pnlhigh()
pnlhigh: Calculates the highest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float highest value the pnl has reached.
pnllow()
pnllow: Calculates the lowest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float lowest value the pnl has reached.
pnldev()
pnldev: Calculates the deviance of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float deviance value of the pnl.
pnlvar()
pnlvar: Calculates the variance value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float variance value of the pnl.
pnlstdev()
pnlstdev: Calculates the stdev value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float stdev value of the pnl.
pnlmedian()
pnlmedian: Calculates the median value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
Returns: float: Returns a float median value of the pnl.
Strategy Table LibraryLibrary "table_library"
TODO: With this library, you can add tables to your strategies.
strategy_table()
Returns: Strategy Profit Table
Adds a table to the graph of the strategy for which you are calling the function. You can see data such as net profit in this table.
No parameters. Just call the function inside the strategy.
Example Code :
import only_fibonacci/table_lib/1 as st
st.strategy_table()
BjCandlePatternsLibrary "BjCandlePatterns"
Patterns is a Japanese candlestick pattern recognition Library for developers. Functions here within detect viable setups in a variety of popular patterns. Please note some patterns are without filters such as comparisons to average candle sizing, or trend detection to allow the author more freedom.
doji(dojiSize, dojiWickSize) Detects "Doji" candle patterns
Parameters:
dojiSize : (float) The relationship of body to candle size (ie. body is 5% of total candle size). Default is 5.0 (5%)
dojiWickSize : (float) Maximum wick size comparative to the opposite wick. (eg. 2 = bottom wick must be less than or equal to 2x the top wick). Default is 2
Returns: (series bool) True when pattern detected
dLab(showLabel, labelColor, textColor) Produces "Doji" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
bullEngulf(maxRejectWick, mustEngulfWick) Detects "Bullish Engulfing" candle patterns
Parameters:
maxRejectWick : (float) Maximum rejection wick size.
The maximum wick size as a percentge of body size allowable for a top wick on the resolution candle of the pattern. 0.0 disables the filter.
eg. 50 allows a top wick half the size of the body. Default is 0% (Disables wick detection).
mustEngulfWick : (bool) input to only detect setups that close above the high prior effectively engulfing the candle in its entirety. Default is false
Returns: (series bool) True when pattern detected
bewLab(showLabel, labelColor, textColor) Produces "Bullish Engulfing" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
bearEngulf(maxRejectWick, mustEngulfWick) Detects "Bearish Engulfing" candle patterns
Parameters:
maxRejectWick : (float) Maximum rejection wick size.
The maximum wick size as a percentge of body size allowable for a bottom wick on the resolution candle of the pattern. 0.0 disables the filter.
eg. 50 allows a botom wick half the size of the body. Default is 0% (Disables wick detection).
mustEngulfWick : (bool) Input to only detect setups that close below the low prior effectively engulfing the candle in its entirety. Default is false
Returns: (series bool) True when pattern detected
bebLab(showLabel, labelColor, textColor) Produces "Bearish Engulfing" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
hammer(ratio, shadowPercent) Detects "Hammer" candle patterns
Parameters:
ratio : (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%.
shadowPercent : (float) The maximum allowable top wick size as a percentage of body size. Default is 5%.
Returns: (series bool) True when pattern detected
hLab(showLabel, labelColor, textColor) Produces "Hammer" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
star(ratio, shadowPercent) Detects "Star" candle patterns
Parameters:
ratio : (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%.
shadowPercent : (float) The maximum allowable bottom wick size as a percentage of body size. Default is 5%.
Returns: (series bool) True when pattern detected
ssLab(showLabel, labelColor, textColor) Produces "Star" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
dragonflyDoji() Detects "Dragonfly Doji" candle patterns
Returns: (series bool) True when pattern detected
ddLab(showLabel, labelColor) Produces "Dragonfly Doji" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
Returns: (series label) A label visible at the chart level intended for the title pattern
gravestoneDoji() Detects "Gravestone Doji" candle patterns
Returns: (series bool) True when pattern detected
gdLab(showLabel, labelColor, textColor) Produces "Gravestone Doji" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
tweezerBottom(closeUpperHalf) Detects "Tweezer Bottom" candle patterns
Parameters:
closeUpperHalf : (bool) input to only detect setups that close above the mid-point of the candle prior increasing its bullish tendancy. Default is false
Returns: (series bool) True when pattern detected
tbLab(showLabel, labelColor, textColor) Produces "Tweezer Bottom" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
tweezerTop(closeLowerHalf) Detects "TweezerTop" candle patterns
Parameters:
closeLowerHalf : (bool) input to only detect setups that close below the mid-point of the candle prior increasing its bearish tendancy. Default is false
Returns: (series bool) True when pattern detected
ttLab(showLabel, labelColor, textColor) Produces "TweezerTop" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTopBull(wickSize) Detects "Bullish Spinning Top" candle patterns
Parameters:
wickSize : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stwLab(showLabel, labelColor, textColor) Produces "Bullish Spinning Top" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTopBear(wickSize) Detects "Bearish Spinning Top" candle patterns
Parameters:
wickSize : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stbLab(showLabel, labelColor, textColor) Produces "Bearish Spinning Top" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTop(wickSize) Detects "Spinning Top" candle patterns
Parameters:
wickSize : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stLab(showLabel, labelColor, textColor) Produces "Spinning Top" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
morningStar() Detects "Bullish Morning Star" candle patterns
Returns: (series bool) True when pattern detected
msLab(showLabel, labelColor, textColor) Produces "Bullish Morning Star" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
eveningStar() Detects "Bearish Evening Star" candle patterns
Returns: (series bool) True when pattern detected
esLab(showLabel, labelColor, textColor) Produces "Bearish Evening Star" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
haramiBull() Detects "Bullish Harami" candle patterns
Returns: (series bool) True when pattern detected
hwLab(showLabel, labelColor, textColor) Produces "Bullish Harami" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
haramiBear() Detects "Bearish Harami" candle patterns
Returns: (series bool) True when pattern detected
hbLab(showLabel, labelColor, textColor) Produces "Bearish Harami" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
haramiBullCross() Detects "Bullish Harami Cross" candle patterns
Returns: (series bool) True when pattern detected
hcwLab(showLabel, labelColor, textColor) Produces "Bullish Harami Cross" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
haramiBearCross() Detects "Bearish Harami Cross" candle patterns
Returns: (series bool) True when pattern detected
hcbLab(showLabel, labelColor) Produces "Bearish Harami Cross" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
Returns: (series label) A label visible at the chart level intended for the title pattern
marubullzu() Detects "Bullish Marubozu" candle patterns
Returns: (series bool) True when pattern detected
mwLab(showLabel, labelColor, textColor) Produces "Bullish Marubozu" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
marubearzu() Detects "Bearish Marubozu" candle patterns
Returns: (series bool) True when pattern detected
mbLab(showLabel, labelColor, textColor) Produces "Bearish Marubozu" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
abandonedBull() Detects "Bullish Abandoned Baby" candle patterns
Returns: (series bool) True when pattern detected
abwLab(showLabel, labelColor, textColor) Produces "Bullish Abandoned Baby" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
abandonedBear() Detects "Bearish Abandoned Baby" candle patterns
Returns: (series bool) True when pattern detected
abbLab(showLabel, labelColor, textColor) Produces "Bearish Abandoned Baby" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
piercing() Detects "Piercing" candle patterns
Returns: (series bool) True when pattern detected
pLab(showLabel, labelColor, textColor) Produces "Piercing" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
darkCloudCover() Detects "Dark Cloud Cover" candle patterns
Returns: (series bool) True when pattern detected
dccLab(showLabel, labelColor, textColor) Produces "Dark Cloud Cover" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
tasukiBull() Detects "Upside Tasuki Gap" candle patterns
Returns: (series bool) True when pattern detected
utgLab(showLabel, labelColor, textColor) Produces "Upside Tasuki Gap" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
tasukiBear() Detects "Downside Tasuki Gap" candle patterns
Returns: (series bool) True when pattern detected
dtgLab(showLabel, labelColor, textColor) Produces "Downside Tasuki Gap" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
risingThree() Detects "Rising Three Methods" candle patterns
Returns: (series bool) True when pattern detected
rtmLab(showLabel, labelColor, textColor) Produces "Rising Three Methods" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
fallingThree() Detects "Falling Three Methods" candle patterns
Returns: (series bool) True when pattern detected
ftmLab(showLabel, labelColor, textColor) Produces "Falling Three Methods" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
risingWindow() Detects "Rising Window" candle patterns
Returns: (series bool) True when pattern detected
rwLab(showLabel, labelColor, textColor) Produces "Rising Window" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
fallingWindow() Detects "Falling Window" candle patterns
Returns: (series bool) True when pattern detected
fwLab(showLabel, labelColor, textColor) Produces "Falling Window" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
kickingBull() Detects "Bullish Kicking" candle patterns
Returns: (series bool) True when pattern detected
kwLab(showLabel, labelColor, textColor) Produces "Bullish Kicking" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
kickingBear() Detects "Bearish Kicking" candle patterns
Returns: (series bool) True when pattern detected
kbLab(showLabel, labelColor, textColor) Produces "Bearish Kicking" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
lls(ratio) Detects "Long Lower Shadow" candle patterns
Parameters:
ratio : (float) A relationship of the lower wick to the overall candle size expressed as a percent. Default is 75%
Returns: (series bool) True when pattern detected
llsLab(showLabel, labelColor, textColor) Produces "Long Lower Shadow" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
lus(ratio) Detects "Long Upper Shadow" candle patterns
Parameters:
ratio : (float) A relationship of the upper wick to the overall candle size expressed as a percent. Default is 75%
Returns: (series bool) True when pattern detected
lusLab(showLabel, labelColor, textColor) Produces "Long Upper Shadow" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
bullNeck() Detects "Bullish On Neck" candle patterns
Returns: (series bool) True when pattern detected
nwLab(showLabel, labelColor, textColor) Produces "Bullish On Neck" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
bearNeck() Detects "Bearish On Neck" candle patterns
Returns: (series bool) True when pattern detected
nbLab(showLabel, labelColor, textColor) Produces "Bearish On Neck" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
soldiers(wickSize) Detects "Three White Soldiers" candle patterns
Parameters:
wickSize : (float) Maximum allowable top wick size throughout pattern expressed as a percent of total candle height. Default is 5%
Returns: (series bool) True when pattern detected
wsLab(showLabel, labelColor, textColor) Produces "Three White Soldiers" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
crows(wickSize) Detects "Three Black Crows" candle patterns
Parameters:
wickSize : (float) Maximum allowable bottom wick size throughout pattern expressed as a percent of total candle height. Default is 5%
Returns: (series bool) True when pattern detected
bcLab(showLabel, labelColor, textColor) Produces "Three Black Crows" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
triStarBull() Detects "Bullish Tri-Star" candle patterns
Returns: (series bool) True when pattern detected
tswLab(showLabel, labelColor, textColor) Produces "Bullish Tri-Star" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
triStarBear() Detects "Bearish Tri-Star" candle patterns
Returns: (series bool) True when pattern detected
tsbLab(showLabel, labelColor, textColor) Produces "Bearish Tri-Star" identifier label
Parameters:
showLabel : (bool) Shows label when input is true. Default is false
labelColor : (series color) Color of the label border and arrow
textColor : (series color) Text color
Returns: (series label) A label visible at the chart level intended for the title pattern
wrap(cond, barsBack, borderColor, bgcolor) Produces a box wrapping the highs and lows over the look back.
Parameters:
cond : (series bool) Condition under which to draw the box.
barsBack : (series int) the number of bars back to begin drawing the box.
borderColor : (series color) Color of the four borders. Optional. The default is color.gray.
bgcolor : (series color) Background color of the box. Optional. The default is color.gray.
Returns: (series box) A box who's top and bottom are above and below the highest and lowest points over the lookback
topWick() returns the top wick size of the current candle
Returns: (series float) A value equivelent to the distance from the top of the candle body to its high
bottomWick() returns the bottom wick size of the current candle
Returns: (series float) A value equivelent to the distance from the bottom of the candle body to its low
body() returns the body size of the current candle
Returns: (series float) A value equivelent to the distance between the top and the bottom of the candle body
highestBody() returns the highest body of the current candle
Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
lowestBody() returns the lowest body of the current candle
Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
barRange() returns the height of the current candle
Returns: (series float) A value equivelent to the distance between the high and the low of the candle
bodyPct() returns the body size as a percent
Returns: (series float) A value equivelent to the percentage of body size to the overall candle size
midBody() returns the price of the mid-point of the candle body
Returns: (series float) A value equivelent to the center point of the distance bewteen the body low and the body high
bodyupGap() returns true if there is a gap up between the real body of the current candle in relation to the candle prior
Returns: (series bool) true if there is a gap up and no overlap in the real bodies of the current candle and the preceding candle
bodydwnGap() returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapUp() returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapDwn() returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
dojiBody() returns true if the candle body is a doji
Returns: (series bool) true if the candle body is a doji. Defined by a body that is 5% of total candle size
GenericTradingLibrary "GenericTrading"
This library aims to collect rare but useful operations for
get_most_recent_long_or_short_position_closed_index() : returns most recent long/short closed bar index.
get_most_recent_long_or_short_position_open_index() : returns most recent long/short closed bar index.
These two functions designed to help to speed up the coding for strategies that contains "re-enter" logic.
These two functions also could applies in the situations where time-count is needed in your condition.