0% found this document useful (0 votes)
52 views3 pages

GPTUSDT 1MIN v2

Uploaded by

tieuly.coc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views3 pages

GPTUSDT 1MIN v2

Uploaded by

tieuly.coc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//@version=5

strategy('GPTUSDT 1MIN', overlay=true, initial_capital = 950,


default_qty_type=strategy.percent_of_equity, default_qty_value=100,
commission_type=strategy.commission.percent, commission_value=0.06)

////////////
// Inputs //

// Pivot points inputs


leftBars = input(2, group = "Pivot Points")
rightBars = input(1, group = "Pivot Points")

// Styling inputs
prec = input(1, title='Return Precision', group =
"Weekly Table")
from_date = input.time(timestamp("01 Jan 2000 00:00 +0000"), "From Date", group =
"Weekly Table")
i_endTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End
Time', group='Weekly Table')
prof_color = input.color(color.green, title = "Gradient Colors", group = "Weeky
Table", inline = "colors")
loss_color = input.color(color.red, title = "", group = "Weeky
Table", inline = "colors")

// Benchmark inputs
use_cur = input.bool(true, title = "Use current Symbol for Benchmark",
group = "Benchmark")
symb_bench = input.symbol('BTCUSDT', title = "Benchmark",
group = "Benchmark")
disp_bench = input.bool(false, title = "Display Benchmark?",
group = "Benchmark")
disp_alpha = input.bool(false, title = "Display Alpha?",
group = "Benchmark")

// Strategy code begins here


import TradingView/Strategy/2 as css

// Pivot Points Strategy


swh = ta.pivothigh(leftBars, rightBars)
swl = ta.pivotlow (leftBars, rightBars)

hprice = 0.0
hprice := not na(swh) ? swh : hprice[1]

lprice = 0.0
lprice := not na(swl) ? swl : lprice[1]

le = false
le := not na(swh) ? true : le[1] and close > hprice ? false : le[1]

se = false
se := not na(swl) ? true : se[1] and close < lprice ? false : se[1]

// RSI, EMA and MACD Inputs


rsi_length = input(9, title="RSI Length", group="RSI EMA MACD")
ema_length = input(10, title="EMA Length", group="RSI EMA MACD")
macd_fast_length = input(12, title="MACD Fast Length", group="RSI EMA MACD")
macd_slow_length = input(49, title="MACD Slow Length", group="RSI EMA MACD")
macd_signal_length = input(5, title="MACD Signal Length", group="RSI EMA MACD")
// RSI, EMA and MACD calculations
rsi_value = ta.rsi(close, rsi_length)
ema_value = ta.ema(close, ema_length)
[macd_line, signal_line, _] = ta.macd(close, macd_fast_length, macd_slow_length,
macd_signal_length)

// Long and Short Entry Conditions


rsi_cond = rsi_value > 50
ema_cond = close > ema_value
macd_cond = macd_line > signal_line

long_entry = rsi_cond and ema_cond and macd_cond


short_entry = not long_entry

// Using the input stop/ limit percent, we can convert to ticks and use the ticks
to level functions.
// This can be used to calculate the take profit and stop levels.

float percentStop = input.float(1.0, "Stop %", minval = 0.0, step = 0.01,


inline='percent')
float percentTP = input.float(2.185, "Limit %", minval = 0.0, step = 0.01,
inline='percent')

bool long = strategy.position_size > 0


bool short = strategy.position_size < 0

//ALERTS {
i_alert_txt_entry_long = input.text_area(defval = "", title = "Long Entry Message",
group = "Alerts")
i_alert_txt_entry_short = input.text_area(defval = "", title = "Short Entry
Message", group = "Alerts")
i_alert_txt_exit_long = input.text_area(defval = "", title = "Long Exit Message",
group = "Alerts")
i_alert_txt_exit_short = input.text_area(defval = "", title = "Short Exit Message",
group = "Alerts")

if long
css.exitPercent("exit long", percentStop, percentTP, alertMessage =
i_alert_txt_exit_long)

if short
css.exitPercent("exit short", percentStop, percentTP, alertMessage =
i_alert_txt_exit_short)

inDateRange = time >= from_date and time <= i_endTime

if le and inDateRange and long_entry


strategy.entry('long', strategy.long, stop=hprice + syminfo.mintick,
alert_message = i_alert_txt_entry_long )

if se and inDateRange and short_entry


strategy.entry('short', strategy.short, stop=lprice - syminfo.mintick,
alert_message = i_alert_txt_entry_short)

plot(hprice, color=color.new(color.green, 0), linewidth=2)


plot(lprice, color=color.new(color.red, 0), linewidth=2)
//}

You might also like