Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © NKactive and JACKOMATE
- // Original source from LeafAlgo
- //@version=5
- strategy("Jackomate Gussian MA BTC", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
- import EliCobra/CobraMetrics/4 as cobra
- //// PLOT DATA
- disp_ind = input.string ("None" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- pos_table = input.string("Middle Left", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- plot(cobra.curve(disp_ind))
- cobra.cobraTable(type_table, pos_table)
- //
- //**
- // JACKOMATE GUASSIAN MOVING AVERAGE
- //
- //inputs
- length = input.int(14, minval=1, title="Length",group="Gaussian")
- adaptive = input.bool(true, title="Adaptive Parameters",group="Gaussian")
- volatilityPeriod = input.int(20, minval=1, title="Volatility Period",group="Gaussian")
- timeframe=input.timeframe(defval ='1D', group = "Gaussian", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- // Calculate Gaussian Moving Average
- gma = 0.0
- sumOfWeights = 0.0
- sigma = adaptive ? ta.stdev(close, volatilityPeriod) : input.float(1.0, minval=0.1, title="Standard Deviation")
- for i = 0 to length - 1
- weight = math.exp(-math.pow(((i - (length - 1)) / (2 * sigma)), 2) / 2)
- value = ta.highest(close, i + 1) + ta.lowest(close, i + 1)
- gma := gma + (value * weight)
- sumOfWeights := sumOfWeights + weight
- gma := (gma / sumOfWeights) / 2
- // Plots
- gmaColor = close >= gma ? color.lime : color.fuchsia
- plot(gma, color=gmaColor, linewidth=2, title="Gaussian Moving Average")
- barcolor(gmaColor)
- // explaination of buy/sell calculation
- // if close >=gms
- // then gausBuy is true
- // else gausBuy is false
- gausBuy = close >=gma ? true : false
- gausSell = close < gma ? true : false
- // Call combine signals and execute buy/sell positions within timeframe
- //.****************************************************************************************************************************************************************
- // Date Range To Include
- startDate = timestamp("2018-01-01T00:00")
- endDate = time
- // Check if the current timestamp is within the restricted range
- inRestrictedRange = time >= startDate and time <= endDate
- //
- // Buy Signals on overbought and oversold
- //
- if inRestrictedRange and gausBuy // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and gausSell // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement