SHOW:
|
|
- or go back to the newest paste.
1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
2 | // © NKactive | |
3 | // Original code from Specialist | |
4 | //Timeframe added | |
5 | //@version=5 | |
6 | - | strategy("Specialist TRIX ETH", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1) |
6 | + | |
7 | strategy("Specialist TRIX BTC", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1) | |
8 | ||
9 | import EliCobra/CobraMetrics/4 as cobra | |
10 | //// PLOT DATA | |
11 | 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍") | |
12 | 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍") | |
13 | type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍") | |
14 | plot(cobra.curve(disp_ind)) | |
15 | cobra.cobraTable(type_table, pos_table) | |
16 | // | |
17 | // **************************************************************************************************************************************************************** | |
18 | //TRIX | |
19 | // **************************************************************************************************************************************************************** | |
20 | - | length = input.int(18, minval=1, group="TRIX") |
20 | + | |
21 | - | out = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(close), length), length), length)) |
21 | + | // Inputs |
22 | timeframe=input.timeframe(defval ='1D', group = "Trix", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe | |
23 | length = input.int(49, minval=1, group="Trix") | |
24 | ||
25 | // Get high and low from selected timeframe instead of the one on the chart | |
26 | - | plot(out, color=color.blue) |
26 | + | TFclose=request.security(syminfo.tickerid,timeframe, close) |
27 | ||
28 | //Calculation | |
29 | out = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(TFclose), length), length), length)) | |
30 | trixLong = out > out[1] | |
31 | trixShort = out < out[1] | |
32 | ||
33 | //PLOT | |
34 | plot(out, color=color.blue) // blue on top is buy | |
35 | plot(out[1], color=color.gray) // gray on top is sell | |
36 | ||
37 | // **************************************************************************************************************************************************************** | |
38 | // Call combine signals and execute buy/sell positions within timeframe | |
39 | //.**************************************************************************************************************************************************************** | |
40 | // Date Range To Include | |
41 | startDate = timestamp("2018-01-01T00:00") | |
42 | - | // Buy Signals on overbought and oversold |
42 | + | |
43 | // Check if the current timestamp is within the restricted range | |
44 | inRestrictedRange = time >= startDate and time <= endDate | |
45 | // | |
46 | // Buy Signals | |
47 | // | |
48 | if inRestrictedRange and trixLong// ADD OTHER BUY SIGNAL BOOLS | |
49 | strategy.entry("My Long Entry Id", strategy.long, 100) | |
50 | if inRestrictedRange and trixShort // ADD OTHER BUY SIGNAL BOOLS | |
51 | strategy.entry("My Short Entry Id", strategy.short, 100) | |
52 | ||
53 | ||
54 | ||
55 |