Created
April 18, 2021 14:14
-
-
Save cedricfarinazzo/d90aca5a8678e15ed5de3ae5200f366d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// © Sed | |
//@version=4 | |
strategy("POC 1.1", overlay=true) | |
// INPUT | |
draw_only_input = input(title="Draw only", type=input.bool, defval=false) | |
sar_acc_input = input(title="Sar - Acceleration", type=input.float, defval=0.02, minval=0.01, maxval=0.1, step=0.01) | |
sar_color_input = input(title="Sar - Color", type=input.color, defval=color.blue) | |
bb_period_input = input(title="Bollinger Bands - Period", type=input.integer, defval=20, minval=2, maxval=100, step=1) | |
bb_st_input = input(title="Bollinger Bands - Standard Deviation", type=input.float, defval=2, minval=0.1, maxval=10, step=0.01) | |
bb_color_input = input(title="Bollinger Bands - Color", type=input.color, defval=color.aqua) | |
ema1_period_input = input(title="Exponential Moving Average 1 - Period", type=input.integer, defval=7, minval=2, maxval=100, step=1) | |
ema1_color_input = input(title="Exponential Moving Average 1 - Color", type=input.color, defval=color.blue) | |
ema2_period_input = input(title="Exponential Moving Average 2 - Period", type=input.integer, defval=25, minval=2, maxval=100, step=1) | |
ema2_color_input = input(title="Exponential Moving Average 2 - Color", type=input.color, defval=color.fuchsia) | |
ema3_period_input = input(title="Exponential Moving Average 3 - Period", type=input.integer, defval=75, minval=2, maxval=100, step=1) | |
ema3_color_input = input(title="Exponential Moving Average 3 - Color", type=input.color, defval=color.yellow) | |
// DATA | |
sar_data = sar(sar_acc_input, sar_acc_input, .2) | |
[bb_middle, bb_upper, bb_lower] = bb(close, bb_period_input, bb_st_input) | |
ema1_data = ema(close, ema1_period_input) | |
ema2_data = ema(close, ema2_period_input) | |
ema3_data = ema(close, ema3_period_input) | |
// COMPUTE | |
hasEntryLongConditional() => crossover(close, bb_lower) and volume > 0 | |
hasCloseLongConditional() => crossunder(close, bb_upper) and volume > 0 | |
// FUNCTION | |
hasOpenTrade() => strategy.opentrades != 0 | |
notHasOpenTrade() => strategy.opentrades == 0 | |
// ACT | |
if (draw_only_input == false) | |
if (notHasOpenTrade()) | |
strategy.entry("LONG", strategy.long, when=hasEntryLongConditional()) | |
else | |
strategy.close("LONG", when=hasCloseLongConditional()) | |
// PLOTING | |
plot(sar_data, style=plot.style_circles, linewidth=1, color=sar_color_input) | |
bb_upper_plot = plot(bb_upper, color=bb_color_input) | |
bb_lower_plot = plot(bb_lower, color=bb_color_input) | |
fill(bb_lower_plot, bb_upper_plot, color=bb_color_input) | |
plot(ema1_data, color=ema1_color_input) | |
plot(ema2_data, color=ema2_color_input) | |
plot(ema3_data, color=ema3_color_input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment