TradeWiseWithEase

BE_CustomFx_Library

Library "BE_CustomFx_Library"
A handful collection of regular functions, Custom Tools & Utility Functions could be used in regular Scripts. hope these functions can be understood by a non programmer like me too.

G_TextValOfNumber(ValueToConvert, RequiredDecimalPlaces, BeginingChar, EndChar) Function to return the String Value of Number with decimal precision with the prefix and suffix characters provided
  Parameters:
    ValueToConvert: = Number to Convert
    RequiredDecimalPlaces: = No of Decimal values Required. supports to a max of 5 decimals else defaults to 2
    BeginingChar: = Prefix character which is needed.
    EndChar: = Suffix character which is needed.
  Returns: Returns Out put with formated value of Given Number for the specified deicimal values with Prefix and suffix string

G_TradableValue(ValueToConvert, NeedCustomization, RequiredDecimalPlaces) Function to return the Tradable Value of Number
  Parameters:
    ValueToConvert: = Number to Convert
    NeedCustomization: = set to 1 if you want to customize the decimal percision values. default is No customization needed, which provides output equalent to round_to_mintick
    RequiredDecimalPlaces: = if NeedCustomization is set to 1 mention the decimal percision value required. max supported decimal is 5 else defaults to 2
  Returns: Returns Out put with formated value of Given Number

G_TxtSizeForLables(SizeValue) Function to Get size Value for text values used in Lables
  Parameters:
    SizeValue: = auto, tiny, small, normal, large, huge. specify either of these values or default value Normal will be displayed as output
  Returns: Returns Respective Text size

G_Reg_LineType(LineType) Function to Get Line Style Value for text values used in Lines
  Parameters:
    LineType: = 'solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)' or default line style 'dotted (┈)' will be the output
  Returns: Returns Respective Line style

G_ShapeTypeForLables(ShapeType) Function to Get Shape Style Value for text values used in plot shapes
  Parameters:
    ShapeType: = 'XCross', 'Cross', 'Triangle Up', 'Triangle Down', 'Flag', 'Circle','Arrow Up', 'Arrow Down','Lable Up', 'Lable Down' or default shpae style Triangle Up will be the output
  Returns: Returns Respective Shape style

G_Indicator_Val(string, float, int, int) Gets Output of the technical analyis indicator which has length Parameter. RSI , ATR, EMA , SMA , HMA , WMA , VWMA , 'CMO', 'MOM', 'ROC','VWAP'
  Parameters:
    string: IndicatorName to be specified
    float: SrcVal for the TA indicator default is close
    int: Length for the TA indicator
    int: DecimalValue optional to specify if required formatted output with decimal percision
  Returns: Value with the given parameters

G_CandleInfo(string, bool, float, bool) function to get Candle Informarion such as both wicksize, top wick size , bottom wick size, full candle size and body size in default points
  Parameters:
    string: WhatCandleInfo, string input with either of these options "Wick" , "TWick" , "BWick" , "Candle", "Body" , "BearfbVal", "BullfbVal" , "CandleOpen" ,"CandleClose", "CandleHigh" , "CandleLow", "BodyPct"
    bool: RepaintingVersion, set to true if required data on the realtime bar else default is set to false
    float: FibValueOfCandle, set the fibo value to extract fibvalue of the candle else default is set to 38.2%
    bool: AccountforGaps, set to true if required data on considering the gap between previous and current bar else default is set to false
  Returns: Returns Respective values for the candles

G_BullBearBarCount(int, int) Counts how many green & red bars have printed recently ( ie . pullback count)
  Parameters:
    int: HowManyCandlesToCheck The lookback period to look back over
    int: BullBear The color of the bar to count (1 = Bull, -1 = Bear), Open = close candles are ignored
  Returns: The bar count of how many candles have retraced over the given lookback with specific candles

BarToStartYourCalculation(Int) function to get candle co-ordinate in order to use it further for calculating your analysis work . "Heart full Thanks to 3 Pine motivators (LonesomeTheBlue, Myank & Sriki) who helped me cracking this logic"
  Parameters:
    Int: SelectedCandleNumber (default=450) How many candles you would need to anlysie in your script from the right.
  Returns: A boolean - output is returned to say the starting point and continue to diplay true for the future candles

isHammer(float, bool, bool) Checks if the current bar is a hammer candle based on the given parameters
  Parameters:
    float: fib (default=0.382) The fib to base candle body on
    bool: colorMatch (default=false) Does the candle need to be green? (true/false)
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a hammer candle

isStar(float, bool, bool) Checks if the current bar is a shooting star candle based on the given parameters
  Parameters:
    float: fib (default=0.382) The fib to base candle body on
    bool: colorMatch (default=false) Does the candle need to be red? (true/false)
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a shooting star candle

isDoji(float, float, bool) Checks if the current bar is a doji candle based on the given parameters
  Parameters:
    float: _wickSize (default=1.5 times) The maximum allowed times can be top wick size compared to the bottom (and vice versa)
    float: _bodySize (default= 5 percent to be mentioned as 0.05) The maximum body size as a percentage compared to the entire candle size
    bool: NeedRepainting (default=false) Specify true if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a doji candle

isBullishEC(float, float, bool, bool) Checks if the current bar is a bullish engulfing candle
  Parameters:
    float: _allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: _rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: _engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle

isBearishEC(float, float, bool, bool) Checks if the current bar is a bearish engulfing candle
  Parameters:
    float: _allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: _rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: _engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle

Plot_TrendLineAtDegree(float, float, int, string, bool) helps you to plot the Trendlines based on the specified angle at the defined price to bar ratio
  Parameters:
    float: Degree (default=14) angle at which Trendline to be plot
    float: price2bar_ratio (default=1e-10) The maximum rejection wick size compared to the body as a percentage
    int: Bars2Plot (default=6) Does the engulfing candle require the wick to be engulfed as well?
    string: LineStyle = 'solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)' or default line style 'dotted (┈)' will be the output
    bool: PlotOnOpen_Close (default=false) Specify True if you need them to calculate on the Open\Close Values
  Returns: plot the Trendlines based on the specified angle at the defined price to bar ratio
Release Notes: v2

Added:
G_Pct_Chng(float, float, int) Gets the percentage change between 2 float values over a given lookback period
  Parameters:
    float: value1 The first value to reference
    float: value2 The second value to reference
    int: lookback The lookback period to analyze

G_ITM(string, bool, int, bool, int) to calculate the ITM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
  Returns: the strike price for the options speficied

G_OTM(string, bool, int, bool, int) to calculate the OTM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
  Returns: the strike price for the options speficied

G_ATM(string, bool, int) to calculate the ATM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
  Returns: the strike price for the options speficied

Chk_TradingTime(string) Determines if the bar's time falls within time filter range
  Parameters:
    string: SessionPeriod (default = "GMT+5:30")Opening Market peak time
  Returns: A boolean - true if the current bar falls within the given time

Updated:
isDoji(float, float, bool) Checks if the current bar is a doji candle based on the given parameters
  Parameters:
    float: wickSize (default=1.5 times) The maximum allowed times can be top wick size compared to the bottom (and vice versa)
    float: bodySize (default= 5 percent to be mentioned as 0.05) The maximum body size as a percentage compared to the entire candle size
    bool: NeedRepainting (default=false) Specify true if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a doji candle

isBullishEC(float, float, bool, bool) Checks if the current bar is a bullish engulfing candle
  Parameters:
    float: allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle

isBearishEC(float, float, bool, bool) Checks if the current bar is a bearish engulfing candle
  Parameters:
    float: allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
    bool: NeedRepainting (default=false) Specify True if you need them to calculate on the realtime bars
  Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle
Release Notes: v3

Added:
OperatorChk(flot, string, CompareVal1, CompareVal2) to compare the value against and provide the boolean output
  Parameters:
    flot: val2chk = Number to check
    string: OperatorTxt = Set to E for ==, NE for !=, G for >, GE for >=, L for <, LE for <= , BE for <= and >= (Between with Equal) and ather string for >< (Between with greater Lesser)
    CompareVal1: = single input to compare against Val2Chk
    CompareVal2: = incase of between scenarios thsi will be used
  Returns: Returns bool Output if compared value found to be true

Plot_TLWithZones(int, int, float, float, int, int, LineType) which plots the lines from point A to B whith specified inputs and returns the expected string Outputs
  Parameters:
    int: FrmCan - FromCandle barindex of the left point of the line
    int: ToCan - ToCandle barindex of the right point of the line
    float: FrmVal - FromValue value of the left point of trendline
    float: ToVal - ToValue value of the right point of trendline
    int: Ext - Extend (default = 1) 1 = extend right, 2 = extend both , 3 = extend none
    int: wdt - width (default = 1) line width
    LineType: = 'solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)' or default line style 'dotted (┈)' will be the output
  Returns: Tuples with usefull informations of the trend Lines

G_HighFreqValue(bool, int, float, float, string, minTouch, ErrorRateTicks, bool, bool, bool, bool) to retrieve the highest frequency value for the given lookback period
  Parameters:
    bool: NeedMaxTouch default is true to identift the highest touched value above the filter value
    int: LookBackPeriod - default is 50
    float: FilterVal1 - default is 0 (include All)
    float: FilterVal2 - default is 0 (will be used only in between scenario)
    string: FilterValOperator - Set to E for ==, NE for !=, G for >, GE for >=, L for <, LE for <= , BE for <= and >= (Between with Equal) and ather string for >< (Between with greater Lesser)
    minTouch: = Minimum Touches to be tested (default is 3)
    ErrorRateTicks: = if in case of exact touch is not happened how much error rate can be included (default is 10 minticks)
    bool: IncludeOpen - default is true
    bool: IncludeHigh - default is true
    bool: IncludeLow - default is true
    bool: IncludeClose - default is true
  Returns: highest frequency value in tuples form

Updated:
G_CandleInfo(string, bool, float, bool, float) function to get Candle Informarion such as both wicksize, top wick size , bottom wick size, full candle size and body size in default points
  Parameters:
    string: WhatCandleInfo, string input with either of these options "Wick" , "TWick" , "BWick" , "Candle", "Body" , "BearfbVal", "BullfbVal" , "CandleOpen" ,"CandleClose", "CandleHigh" , "CandleLow", "BodyPct","ExtractVal"
    bool: RepaintingVersion, set to true if required data on the realtime bar else default is set to false
    float: FibValueOfCandle, set the fibo value to extract fibvalue of the candle else default is set to 38.2%
    bool: AccountforGaps, set to true if required data on considering the gap between previous and current bar else default is set to false
    float: MidVal, set the % value in order to extract the value for the candle
  Returns: Returns Respective values for the candles

BarToStartYourCalculation(Int) function to get candle co-ordinate in order to use it further for calculating your analysis work . "Heart full Thanks to 3 Pine motivators (LonesomeTheBlue, Myank & Sriki) who helped me cracking this logic"
  Parameters:
    Int: SelectedCandleNumber (default=450) How many candles you would need to anlysie in your script from the right.
  Returns: A boolean - output is returned to say the starting point and continue to diplay true for the future candles
Release Notes: v4

Added:
G_Pivots(int, float, string, int, int, tuples) to retrieve the Pivot High and Low points (Highest Point and the latest PH and similarly Lowest Point and the latest PL)
  Parameters:
    int: StartScanFrom default is 150
    float: Source - default is close, will be used if the source is an external indicator
    string: PlotOnType - default is "HL" (possible use cases can be either "HL", "OC" or any any other string character so that it uses Source param to calculate the Pivot points)
    int: LBC - default is 4 Look Back period for Pivot points
    int: LBF - default is 2 Look forwar period for confirming the Pivot points
    tuples: with useful information regarding pivot points

Updated:
G_BullBearBarCount(int, int) Counts how many green & red bars have printed recently (ie. pullback count)
  Parameters:
    int: HowManyCandlesToCheck The lookback period to look back over
    int: BullBear The color of the bar to count (1 = Bull, -1 = Bear), Open = close candles are ignored
  Returns: The bar count of how many candles have retraced over the given lookback with specific candles

Plot_TLWithZones(int, int, float, float, int, int, LineType, bool, simple) which plots the lines from point A to B whith specified inputs and returns the expected string Outputs
  Parameters:
    int: FrmCan - FromCandle barindex of the left point of the line
    int: ToCan - ToCandle barindex of the right point of the line
    float: FrmVal - FromValue value of the left point of trendline
    float: ToVal - ToValue value of the right point of trendline
    int: Ext - Extend (default = 1) 1 = extend right, 2 = extend both , 3 = extend none
    int: wdt - width (default = 1) line width
    LineType: = 'solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)' or default line style 'dotted (┈)' will be the output
    bool: Restructure = default (true) , while plotting TrendLine, if there are any breaks already happend then it reassigns the trendline to the correct points
    simple: string RestructureOn = "HL", possible output can be "HL" or "OC"
  Returns: Tuples with usefull informations of the trend Lines
Release Notes: v5 removed some small bugs
Release Notes: v6

Added:
G_Delta(int, int, simple, bool) Gets Delta Output of the technical analyis indicator
  Parameters:
    int: ShortLength to be specified default is 3
    int: LongLength to be specified default is 8
    simple: string MAType for the TA indicator supported are EMA, SMA, HMA
    bool: RepaintingVersion calculate on realtime bar? default is true.
  Returns: Value with the given parameters
Release Notes: v7
minor Tweak to TLWithZones and Added MorePivots to GetPivot Function
Release Notes: v8 Minor fix on Pivot Output was referring to incorrect Values.
Release Notes: v9
1. Enabled Trailing Pivot for further Usage.
2. Pivot Algorithm Changed a Bit to be more constant.
3. Bug fixed for Max Bars Back Error when applied.
Release Notes: v10
Minor Changes to Pivot to remove unused Pivots to speed up some calculations.
Release Notes: v11

Added:
Get_TradeManagementInfo(Specify) to retrieve the Trade related informations
  Parameters:
    Specify: the ArraysOf related parameters
  Returns: tuples with useful information regarding Trades taken
Release Notes: v12
Minor Bugs fixed
Release Notes: v13

Updated: Included Qty Traded in Output
Get_TradeManagementInfo(Specify) to retrieve the Trade related informations
  Parameters:
    Specify: the ArraysOf related parameters
  Returns: tuples with useful information regarding Trades taken
Release Notes: v14 minor bug fixed
Release Notes: v15
Alogrithm changed for TradeManagementInfo
Release Notes: v16
Minor Bug fixed and added Net final Position for the TradeManagement Info
Release Notes: v17
Simplified OperatorCheck
Release Notes: v18

Added:
TrackTradeHappening(Specify) to plot Long/Short Trade Boxes which help saving time in plotting them on chart
  Parameters:
    Specify: the values against related parameters
Release Notes: v19

Updated:
TrackTradeHappening(Specify) to plot Long/Short Trade Boxes which help saving time in plotting them on chart
  Parameters:
    Specify: the values against related parameters
Release Notes: v20
Minro Bug Fixed
Updated:
TrackTradeHappening(Specify) to plot Long/Short Trade Boxes which help saving time in plotting them on chart
  Parameters:
    Specify: the values against related parameters
Release Notes: v21
Minor Bugs Fixed for Pivots Points
Release Notes: v22
Minor Bug Fixed for PNL Values Calculation
Release Notes: v23

Updated:
G_HighFreqValue(int, float, float, string, minTouch, ErrorRateTicks, bool, bool, bool, bool) to retrieve the highest frequency value for the given lookback period
  Parameters:
    int: LookBackPeriod - default is 50
    float: FilterVal1 - default is 0 (include All)
    float: FilterVal2 - default is 0 (will be used only in between scenario)
    string: FilterValOperator - Set to E for ==, NE for !=, G for >, GE for >=, L for <, LE for <= , BE for <= and >= (Between with Equal) and ather string for >< (Between with greater Lesser)
    minTouch: = Minimum Touches to be tested (default is 3)
    ErrorRateTicks: = if in case of exact touch is not happened how much error rate can be included (default is 10 minticks)
    bool: IncludeOpen - default is true
    bool: IncludeHigh - default is true
    bool: IncludeLow - default is true
    bool: IncludeClose - default is true
  Returns: tuples with MaxTouchValue and HighestRange and LowestRange
Release Notes: v24

Updated:
G_TextValOfNumber(float, int, string, string) Function to return the String Value of Number with decimal precision with the prefix and suffix characters provided
  Parameters:
    float: ValueToConvert = Number to Convert
    int: RequiredDecimalPlaces = No of Decimal values Required. supports to a max of 5 decimals else defaults to 2
    string: BeginingChar = Prefix character which is needed.
    string: EndChar = Suffix character which is needed.
  Returns: Returns Out put with formated value of Given Number for the specified deicimal values with Prefix and suffix string
Release Notes: v25
Minor Bug Fixed with HighFrequency Value
Release Notes: v26

Minor Update for SpeedImprovement for HighFrequency
Release Notes: v27

bug Fixing
Release Notes: v28

Added:
IsPoweredPushBuy() To Check if the candle is a powered Push or Not

IsPoweredPushSell() To Check if the candle is a powered Push or Not
Release Notes: v29
Cosmetic changes (Formattef code) done. New algorithm to publish for few function. Removed few defaults for better readability.
Release Notes: v30

Added: Created CustomFx for DhanHQ Api JSON
CreateJSON()
Release Notes: v31
Minor Bug Fix for JSON for DHAN_HQ
Release Notes: v32

Added:
G_TablePositon()
Release Notes: v33

Added:
GetTicker()

G_RespectingLineIndex()
Release Notes: v34

Updated:
G_RespectingLineIndex()
Release Notes: v35

Updated:
CreateJSON()
Release Notes: v36

Added:
GetTickerPrfx()
Release Notes: v37
Minor Bug Fix for TradeManagment.
Release Notes: v38
Minor Bug Fixed
Release Notes: v39

Updated:
G_ITM()

G_OTM()

G_ATM()
Release Notes: v40

Updated:
G_ITM(string, bool, int, bool, int)
  to calculate the ITM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
  Returns: the strike price for the options speficied

G_OTM(string, bool, int, bool, int)
  to calculate the OTM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
  Returns: the strike price for the options speficied

G_ATM(string, bool, int)
  to calculate the ATM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
  Returns: the strike price for the options speficied
Release Notes: v41

Updated:
G_ITM(string, bool, int, bool, int, float, float)
  to calculate the ITM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
    float: SVal (default=0) Specify the source value.
    float: CalibaratePct (default=0, min = 0 and max = 1) Specify the percentage value. eg if calibarion is set for 50% on the banknifty close price with 30030.5 ITM CE 1 deep will show 29900 how ever if close price is 30070.5 ITM CE with 1 deep will show 30000
  Returns: the strike price for the options speficied

G_OTM(string, bool, int, bool, int, float, float)
  to calculate the OTM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    bool: ForCE (default=true) Specify false if you need them to calculate for PE option
    int: HowDeep (default=1) Specify the level.
    float: SVal (default=0) Specify the source value.
    float: CalibaratePct (default=0, min = 0 and max = 1) Specify the percentage value. eg if calibarion is set for 50% on the banknifty close price with 30030.5 ITM CE 1 deep will show 29900 how ever if close price is 30070.5 ITM CE with 1 deep will show 30000
  Returns: the strike price for the options speficied

G_ATM(string, bool, int, float, float)
  to calculate the ATM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    float: SVal (default=0) Specify the source value.
    float: CalibaratePct (default=0, min = 0 and max = 1) Specify the percentage value. eg if calibarion is set for 50% on the banknifty close price with 30030.5 ITM CE 1 deep will show 29900 how ever if close price is 30070.5 ITM CE with 1 deep will show 30000
  Returns: the strike price for the options speficied
Release Notes: v42

Added:
ScriptConvertor(ExpectedOutput)
  Parameters:
    ExpectedOutput: AcceptableValue = "Name", "Type", "Exp"

DiscordBasicJSON()

DiscordTradingJSON(TradeType, BuyOrSell, EqOrFutOrOp, TradeQty, ScriptName, OrderType, OrderType, OrderType, HowDeep, CEorPE, Expiry, BO_Tgt, BO_SL, CO_SL)
  Parameters:
    TradeType: acceptable Inputs are I (for MIS / Intraday), CO (for Cover Order), BO (for Bracket Order)
    BuyOrSell: acceptable Inputs are B or S
    EqOrFutOrOp: acceptable Inputs are E (for Equity), F (for Futures), O (for Options)
    TradeQty: string format (default = 25 Qty)
    ScriptName: string format
    OrderType: acceptable Inputs are "" (for Market), "XXX.XX" (143.05 to place Limit Orders at 143.05), Continued Below 2 other acceptable inputs...
    OrderType: "X.X%" (1.25% to place Limit orders at specified percentage Below Market price for BUY, and Above Market price for SELL)
    OrderType: "A X.X%" or "B X.X%" or "A 154.0" or "B 125.0" (A 0.75% to place BUY SL-Limit orders at specified percentage Above Market price for BUY, B 1.05% to place SELL SL-Limit orders at specified percentage Below Market price for SELL)
    HowDeep: acceptable Inputs are "0" (for ATM option), "1" (Positive Numbers for ITM), "-1" (Negative Numbers for OTM) or "" (for Non Expiry Orders)
    CEorPE: acceptable Inputs are CE, PE or "" (for Non Option Orders)
    Expiry: acceptable Inputs are C (for Current Expiry), N (for Next Expiry) or "" (for Non Expiry Orders)
    BO_Tgt: acceptable Inputs are "X" (5 for Rs.5 Target Point), "X.X%" (1.2% for capturing specified percentage rise in price as Target Points for BUY) or "" (for Non BO Orders)
    BO_SL: acceptable Inputs are "X" (3 for Rs.3 SL Point), "X.X%" (0.75% for specified percentage fall in price as SL Points for BUY) or "" (for Non BO Orders)
    CO_SL: acceptable Inputs are "+X" (+3 for Rs.3 above current price for Sell Trade), "-X" (-5 for Rs.5 below current price for Buy Trade), "XXX.X" (125.5 will be applied as SL Value for CO Order) or "" (for Non Expiry Orders)
Release Notes: v43

Updated:
G_ATM(string, bool, int, float, float)
  to calculate the ATM stike for the defined strike change
  Parameters:
    string: source (default='c') specify either of the source value Note: Be mindful as it may be repainted and calulation to be called on every bar
    bool: NeedRepainting (default=true) Specify false if you need them to calculate on the completed bars
    int: StrikeDiff (default=100) Specify the strike difference value. eg = Nifty = 50 and BNF = 100
    float: SVal (default=0) Specify the source value.
    float: CalibaratePct (default=0, min = 0 and max = 1) Specify the percentage value. eg if calibarion is set for 50% on the banknifty close price with 30030.5 ITM CE 1 deep will show 29900 how ever if close price is 30070.5 ITM CE with 1 deep will show 30000
  Returns: the strike price for the options speficied
Release Notes: v44
Minor Bug Fixed
Release Notes: v45

Added:
TriggerAfter(_cond, _resetCond)
  Parameters:
    _cond: acceptable Inputs are seconds to wait and then trigger the output as NA
    _resetCond: acceptable Inputs are true or false
Release Notes: v46
Minor bug fix

TRADING MADE SIMPLE
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.

Frånsägelse av ansvar

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.