merhaba tradingwiewda bulunan bu indikatörü matriks veri terminali indikatör ve sistem tester  için dönüştürebilirmisiniz şimdiden teşekkür eder iyi çalışmalar dilerim

 

//@version=4
//

strategy(title="Open Close Cross Strategy NoRepaint Version by JustUncleL", shorttitle="OCC Strategy NRP", overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=10, calc_on_every_tick=false)

//
// Revision:        NRP
// Original Author: @JayRogers
// Revision Author: JustUncleL revisions 3, 4, 5, NRP
//
// Description:
// ============
//  Strategy based around Open-Close Crossovers. NRP is the Non repaint version.
//  *** USE AT YOUR OWN RISK ***
//
// Modifications:
// ==============
// NRP No Repaint Version changes by JustUncleL 2-Oct-2019
//  - Removed Delay option, not required in this version.
//  - Added date range to becktest against.
//  - Removed "LSMA", "ALMA" MA options to simplify selections.
//
// R5.1 Changes by JustUncleL
//  - Upgraded to Version 3 Pinescript.
//  - Added option to select Trade type (Long, Short, Both or None)
//  - Added bar colouring work around patch.
//  - Small code changes to improve efficiency.
//  - NOTE: To enable non-Repainting mode set "Delay Open/Close MA" to 1 or more.
//  9-Aug-2017
//  - Correction on SuperSmooth MA calculation.
//
// R5 Changes by JustUncleL
//  - Corrected cross over calculations, sometimes gave false signals.
//  - Corrected Alternate Time calculation to allow for Daily,Weekly and Monthly charts.
//  - Open Public release.
// R4 Changes By JustUncleL
//  - Change the way the Alternate resolution in selected, use a Multiplier of the base Time Frame instead,
//    this makes it easy to switch between base time frames.
//  - Added TMA and SSMA moving average options. But DEMA is still giving the best results.
//  - Using "calc_on_every_tick=false" ensures results between backtesting and real time are similar.
//  - Added Option to Disable the coloring of the bars.
//  - Updated default settings.
//
// R3 Changes by JustUncleL:
//  - Returned a simplified version of the open/close channel, it shows strength of current trend.
//  - Added Target Profit Option.
//  - Added option to reduce the number of historical bars, overcomes the too many trades limit error.
//  - Simplified the strategy code.
//  - Removed Trailing Stop option, not required and in my opion does not work well in Trading View,
//    it also gives false and unrealistic performance results in backtesting.
//
// R2 Changes:
//  - Simplified and cleaned up plotting, now just shows a Moving Average derived from the average of open/close.
//  - Tried very hard to alleviate painting issues caused by referencing alternate resolution..
//
// Setup:
//  - I have generally found that setting the strategy resolution to 3-4x that of the chart you are viewing
//    tends to yield the best results, regardless of which MA option you may choose (if any) BUT can cause
//    a lot of false positives - be aware of this
//  - Don't aim for perfection. Just aim to get a reasonably snug fit with the O-C band, with good runs of
//    green and red.
//  - Option to either use basic open and close series data, or pick your poison with a wide array of MA types.
//  - Optional trailing stop for damage mitigation if desired (can be toggled on/off)
//  - Positions get taken automagically following a crossover - which is why it's better to set the resolution
//    of the script greater than that of your chart, so that the trades get taken sooner rather than later.
//  - If you make use of the stops, be sure to take your time tweaking the values. Cutting it too fine
//    will cost you profits but keep you safer, while letting them loose could lead to more drawdown than you
//    can handle.
//  - To enable non-Repainting mode set "Delay Open/Close MA" to 1 or more.
//
// -----------------------------------------------------------------------------
// Copyright 2015 JayRogers
// Copyright 2017,2018,2019 JustUncleL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// The GNU General Public License can be found here
// <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------------------
//

// === INPUTS ===
useRes = input(defval=true, title="Use Alternate Resolution?")
intRs_ = input(defval=6, title="Multiplier for Alernate Resolution")
intRes = useRes ? intRs_ : 1
basisType = input(defval="ZEMA", title="MA Type: ", options=["SMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMMA", "HullMA", "ZEMA", "SSMA", "TMA"])
basisLen = input(defval=8, title="MA Period", minval=1)
scolor = input(false, title="Show coloured Bars to indicate Trend?")
tradeType = input("BOTH", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH", "NONE"])
// === /INPUTS ===

// Constants colours that include fully non-transparent option.
green100 = #008000FF
lime100 = #00FF00FF
red100 = #FF0000FF
blue100 = #0000FFFF
aqua100 = #00FFFFFF
darkred100 = #8B0000FF
gray100 = #808080FF

// - variant(type, src, len)
// Returns MA input selection variant, default to SMA if blank or typo.

// SuperSmoother filter
// © 2013  John F. Ehlers
variant_supersmoother(src, len) =>
    a1 = exp(-1.414 * 3.14159 / len)
    b1 = 2 * a1 * cos(1.414 * 3.14159 / len)
    c2 = b1
    c3 = -a1 * a1
    c1 = 1 - c2 - c3
    v9 = 0.0
    v9 := c1 * (src + nz(src[1])) / 2 + c2 * nz(v9[1]) + c3 * nz(v9[2])
    v9

variant_smoothed(src, len) =>
    v5 = 0.0
    sma_1 = sma(src, len)
    v5 := na(v5[1]) ? sma_1 : (v5[1] * (len - 1) + src) / len
    v5

variant_zerolagema(src, len) =>
    lag = (len - 1) / 2
    emaSrc = src + src - src[lag]
    v10 = ema(emaSrc, len)
    v10

variant_doubleema(src, len) =>
    v2 = ema(src, len)
    v6 = 2 * v2 - ema(v2, len)
    v6

variant_tripleema(src, len) =>
    v2 = ema(src, len)
    v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len)  // Triple Exponential
    v7

//calc Laguerre
variant_lag(p, g) =>
    L0 = 0.0
    L1 = 0.0
    L2 = 0.0
    L3 = 0.0
    L0 := (1 - g) * p + g * nz(L0[1])
    L1 := -g * L0 + nz(L0[1]) + g * nz(L1[1])
    L2 := -g * L1 + nz(L1[1]) + g * nz(L2[1])
    L3 := -g * L2 + nz(L2[1]) + g * nz(L3[1])
    f = (L0 + 2 * L1 + 2 * L2 + L3) / 6
    f

// return variant, defaults to SMA
variant(type, src, len) =>
    ema_1 = ema(src, len)
    wma_1 = wma(src, len)
    vwma_1 = vwma(src, len)
    variant_smoothed__1 = variant_smoothed(src, len)
    variant_doubleema__1 = variant_doubleema(src, len)
    variant_tripleema__1 = variant_tripleema(src, len)
    wma_2 = wma(src, len / 2)
    wma_3 = wma(src, len)
    wma_4 = wma(2 * wma_2 - wma_3, round(sqrt(len)))
    variant_supersmoother__1 = variant_supersmoother(src, len)
    variant_zerolagema__1 = variant_zerolagema(src, len)
    sma_1 = sma(src, len)
    sma_2 = sma(sma_1, len)
    sma_3 = sma(src, len)
    type == "EMA" ? ema_1 : type == "WMA" ? wma_1 :
       type == "VWMA" ? vwma_1 : type == "SMMA" ? variant_smoothed__1 :
       type == "DEMA" ? variant_doubleema__1 : type == "TEMA" ? variant_tripleema__1 :
       type == "HullMA" ? wma_4 : type == "SSMA" ? variant_supersmoother__1 :
       type == "ZEMA" ? variant_zerolagema__1 : type == "TMA" ? sma_2 : sma_3

// - /variant

// - /FUNCTIONS

// === SERIES SETUP ===

closeSeries = variant(basisType, close, basisLen)
openSeries = variant(basisType, open, basisLen)
// Simulate Alternate resolution Series by increasing MA period.
closeSeriesAlt = variant(basisType, close, basisLen * intRes)
openSeriesAlt = variant(basisType, open, basisLen * intRes)

// === /SERIES ===

// === PLOTTING ===

//
trendColour = closeSeriesAlt > openSeriesAlt ? color.green : color.red
bcolour = closeSeries > openSeriesAlt ? lime100 : red100
barcolor(scolor ? bcolour : na, title="Bar Colours")
closeP = plot(closeSeriesAlt, title="Close Series", color=trendColour, linewidth=2, style=plot.style_line, transp=20)
openP = plot(openSeriesAlt, title="Open Series", color=trendColour, linewidth=2, style=plot.style_line, transp=20)
fill(closeP, openP, color=trendColour, transp=80)

// === /PLOTTING ===
//

//
// === ALERT conditions
xlong = crossover(closeSeriesAlt, openSeriesAlt)
xshort = crossunder(closeSeriesAlt, openSeriesAlt)
longCond = xlong  // alternative: longCond[1]? false : (xlong or xlong[1]) and close>closeSeriesAlt and close>=open
shortCond = xshort  // alternative: shortCond[1]? false : (xshort or xshort[1]) and close<closeSeriesAlt and close<=open
// === /ALERT conditions.

// === STRATEGY ===
// stop loss
slPoints = input(defval=0, title="Initial Stop Loss Points (zero to disable)", minval=0)
tpPoints = input(defval=0, title="Initial Target Profit Points (zero for disable)", minval=0)

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>//

testStartYear = input(2018, "Backtest Start Year", minval=1980)
testStartMonth = input(1, "Backtest Start Month", minval=1, maxval=12)
testStartDay = input(1, "Backtest Start Day", minval=1, maxval=31)
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)

testStopYear = input(9999, "Backtest Stop Year", minval=1980)
testStopMonth = input(12, "Backtest Stop Month", minval=1, maxval=12)
testStopDay = input(31, "Backtest Stop Day", minval=1, maxval=31)
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

//
//set up exit parameters
TP = tpPoints > 0 ? tpPoints : na
SL = slPoints > 0 ? slPoints : na

// Make sure we are within the bar range, Set up entries and exit conditions
if testPeriod() and tradeType != "NONE"
    strategy.entry("long", strategy.long, when=longCond == true and tradeType != "SHORT")
    strategy.entry("short", strategy.short, when=shortCond == true and tradeType != "LONG")
    strategy.close("long", when=shortCond == true and tradeType == "LONG")
    strategy.close("short", when=longCond == true and tradeType == "SHORT")
    strategy.exit("XL", from_entry="long", profit=TP, loss=SL)
    strategy.exit("XS", from_entry="short", profit=TP, loss=SL)

// === /STRATEGY ===
// eof