Message
Message
Message
0 at
https://mozilla.org/MPL/2.0/
// © lovealgotrading
//@version=5
strategy(
title = 'AUTOMATIC GRID BOT STRATEGY [lovealgotrading]',
overlay = true,
commission_type = strategy.commission.percent,
commission_value = 0.075,
pyramiding = 20,
default_qty_type = strategy.percent_of_equity,
close_entries_rule = 'ANY',
initial_capital = 1000
)
high_price = input.price(
defval = 0.00,
title = 'Range High price: ',
group = " ############## ➡️ HIGH GRID PRICE ⬅️ ############ ",
confirm = true,
tooltip = "Top grid price."
)
low_price = input.price(
defval = 0.00,
title = 'Range Low price: ',
group = " ############## ➡️ LOW GRID PRICE ⬅️ ############# ",
confirm = true,
tooltip = "Bottom grid price."
)
//
###################################################################################
########
//
###################################################################################
########
stop_close_all = ""
high_price_stop = input.price(
defval = 99999,
title = 'High STOP Price: ',
group = " ############# Strategy STOP Settings ############ ",
confirm = false,
tooltip = "Top STOP price."
)
low_price_stop = input.price(
defval = 0.00,
title = 'Low STOP Price: ',
group = " ############# Strategy STOP Settings ############ ",
confirm = false,
tooltip = "Bottom STOP price."
)
if use_stop_default
high_price_stop := high_price
low_price_stop := low_price
//
###################################################################################
########
dolar = input.int(defval = 100, title = "$ Per Position", group = " ############# 🤖
ALGO TRADE ALERTS 🤖 ############ ")
//
###################################################################################
########
//
###################################################################################
########
//
###################################################################################
########
ten_grid = input.bool(
defval = false,
title = "10 grid levels",
group = " ############ GRID CONFIGURATION ############ ",
tooltip = "10 grid levels",
confirm = true
)
tewnty_grid = input.bool(
defval = true,
title = "20 grid levels",
group = " ############ GRID CONFIGURATION ############ ",
tooltip = "20 grid levels",
confirm = true
)
//
###################################################################################
########
//
###################################################################################
########
long_1 = false
long_2 = false
long_3 = false
long_4 = false
long_5 = false
long_6 = false
long_7 = false
long_8 = false
long_9 = false
long_10 = false
short_1 = false
short_2 = false
short_3 = false
short_4 = false
short_5 = false
short_6 = false
short_7 = false
short_8 = false
short_9 = false
short_10 = false
if ten_grid == true
factor := grid_range / 9
grid_1 := (high_price)
grid_2 := (high_price - (factor * 1))
grid_3 := (high_price - (factor * 2))
grid_4 := (high_price - (factor * 3))
grid_5 := (high_price - (factor * 4))
grid_6 := (high_price - (factor * 5))
grid_7 := (high_price - (factor * 6))
grid_8 := (high_price - (factor * 7))
grid_9 := (high_price - (factor * 8))
grid_10 := (low_price)
if tewnty_grid == true
factor := grid_range / 19
grid_1 := (high_price)
grid_2 := (high_price - (factor * 1))
grid_3 := (high_price - (factor * 2))
grid_4 := (high_price - (factor * 3))
grid_5 := (high_price - (factor * 4))
grid_6 := (high_price - (factor * 5))
grid_7 := (high_price - (factor * 6))
grid_8 := (high_price - (factor * 7))
grid_9 := (high_price - (factor * 8))
grid_10 := (high_price - (factor * 9))
grid_11 := (high_price - (factor * 10))
grid_12 := (high_price - (factor * 11))
grid_13 := (high_price - (factor * 12))
grid_14 := (high_price - (factor * 13))
grid_15 := (high_price - (factor * 14))
grid_16 := (high_price - (factor * 15))
grid_17 := (high_price - (factor * 16))
grid_18 := (high_price - (factor * 17))
grid_19 := (high_price - (factor * 18))
grid_20 := (low_price)
//
###################################################################################
########
//
###################################################################################
########
if strategy.opentrades == 1
strategy.exit(id = "E_1",from_entry = "L_1", qty_percent =
100,alert_message =Long_Exit_message,stop = 0, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 2
strategy.exit(id = "E_2",from_entry = "L_2", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 3
strategy.exit(id = "E_3",from_entry = "L_3", qty_percent =
100,alert_message =Long_Exit_message,limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 5
strategy.exit(id = "E_5",from_entry = "L_5", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
//
###################################################################################
########
if strategy.opentrades == 1
strategy.exit(id = "ES_1",from_entry = "S_1", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 2
strategy.exit(id = "ES_2",from_entry = "S_2", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 3
strategy.exit(id = "ES_3",from_entry = "S_3", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if short_4 and strategy.opentrades == 3 and inDateRange and stop_close_all
== ""
strategy.entry(id = "S_4", direction = strategy.short,alert_message =
Short_message, qty = qty_new )
if strategy.opentrades == 4
strategy.exit(id = "ES_4",from_entry = "S_4", qty_percent =
100,alert_message =Short_Exit_message,limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 5
strategy.exit(id = "ES_5",from_entry = "S_5", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
//
###################################################################################
########
//
###################################################################################
########
long_exit_price = str.tostring(math.round_to_mintick(close*(1+percent_change)))
short_exit_price = str.tostring(math.round_to_mintick(close*(1-percent_change)))
if strategy.opentrades == 1
strategy.exit(id = "E_1",from_entry = "L_1", qty_percent =
100,alert_message = Long_Exit_message,stop = 0, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 2
strategy.exit(id = "E_2",from_entry = "L_2", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 3
strategy.exit(id = "E_3",from_entry = "L_3", qty_percent =
100,alert_message =Long_Exit_message,limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 4
strategy.exit(id = "E_4",from_entry = "L_4", qty_percent =
100,alert_message =Long_Exit_message,limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 5
strategy.exit(id = "E_5",from_entry = "L_5", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 6
strategy.exit(id = "E_6",from_entry = "L_6", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 8
strategy.exit(id = "E_8",from_entry = "L_8", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 9
strategy.exit(id = "E_9",from_entry = "L_9", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
if strategy.opentrades == 10
strategy.exit(id = "E_10",from_entry = "L_10", qty_percent =
100,alert_message =Long_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))
//
###################################################################################
########
if strategy.opentrades == 2
strategy.exit(id = "ES_2",from_entry = "S_2", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 3
strategy.exit(id = "ES_3",from_entry = "S_3", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 4
strategy.exit(id = "ES_4",from_entry = "S_4", qty_percent =
100,alert_message =Short_Exit_message,limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 5
strategy.exit(id = "ES_5",from_entry = "S_5", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 6
strategy.exit(id = "ES_6",from_entry = "S_6", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 7
strategy.exit(id = "ES_7",from_entry = "S_7", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 8
strategy.exit(id = "ES_8",from_entry = "S_8", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 9
strategy.exit(id = "ES_9",from_entry = "S_9", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
if strategy.opentrades == 10
strategy.exit(id = "ES_10",from_entry = "S_10", qty_percent =
100,alert_message =Short_Exit_message, limit =
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))
//
###################################################################################
########
//// ########################################################################
// Plot Functions
plot(strategy.position_size < 0 ?
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change) : na ,
color= color.rgb(247, 85, 85), linewidth= 1, style=plot.style_cross)
plot(strategy.position_size > 0 ?
strategy.opentrades.entry_price(strategy.opentrades - 1)*(1+percent_change) : na ,
color= color.rgb(136, 247, 85), linewidth= 1, style=plot.style_cross)
//
###################################################################################
########
new_ten_grid_1 := grid_1
new_ten_grid_2 := grid_2
new_ten_grid_3 := grid_3
new_ten_grid_4 := grid_4
new_ten_grid_5 := grid_5
new_ten_grid_6 := grid_6
new_ten_grid_7 := grid_7
new_ten_grid_8 := grid_8
new_ten_grid_9 := grid_9
new_ten_grid_10 := grid_10
new_ten_grid_1 := na
new_ten_grid_2 := na
new_ten_grid_3 := na
new_ten_grid_4 := na
new_ten_grid_5 := na
new_ten_grid_6 := na
new_ten_grid_7 := na
new_ten_grid_8 := na
new_ten_grid_9 := na
new_ten_grid_10 := na
// //
###################################################################################
########
new_twenty_grid_1 := grid_1
new_twenty_grid_2 := grid_2
new_twenty_grid_3 := grid_3
new_twenty_grid_4 := grid_4
new_twenty_grid_5 := grid_5
new_twenty_grid_6 := grid_6
new_twenty_grid_7 := grid_7
new_twenty_grid_8 := grid_8
new_twenty_grid_9 := grid_9
new_twenty_grid_10 := grid_10
new_twenty_grid_11 := grid_11
new_twenty_grid_12 := grid_12
new_twenty_grid_13 := grid_13
new_twenty_grid_14 := grid_14
new_twenty_grid_15 := grid_15
new_twenty_grid_16 := grid_16
new_twenty_grid_17 := grid_17
new_twenty_grid_18 := grid_18
new_twenty_grid_19 := grid_19
new_twenty_grid_20 := grid_20
new_twenty_grid_1 := na
new_twenty_grid_2 := na
new_twenty_grid_3 := na
new_twenty_grid_4 := na
new_twenty_grid_5 := na
new_twenty_grid_6 := na
new_twenty_grid_7 := na
new_twenty_grid_8 := na
new_twenty_grid_9 := na
new_twenty_grid_10 := na
new_twenty_grid_11 := na
new_twenty_grid_12 := na
new_twenty_grid_13 := na
new_twenty_grid_14 := na
new_twenty_grid_15 := na
new_twenty_grid_16 := na
new_twenty_grid_17 := na
new_twenty_grid_18 := na
new_twenty_grid_19 := na
new_twenty_grid_20 := na
// //
###################################################################################
########
//
###################################################################################
############
//------------------------------Table
//
###################################################################################
############
showDashboard = input.bool(true, "Show Table", group=" ############# 🔳 TABLE
Settings 🔳 ############ ")
locationDashboard = input.string("Top Right", "Table Location", ["Top Right",
"Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center",
"Top Left", "Middle Left", "Bottom Left"], group=" ############# 🔳 TABLE Settings 🔳
############ ")
sizeDashboard = input.string("Normal", "Table Size", ["Large", "Normal",
"Small", "Tiny"], group=" ############# 🔳 TABLE Settings 🔳 ############ ")
if showDashboard
var myTable = table.new(position = dashboard_loc, columns = 5, rows =
2,bgcolor = color.white, border_width = 1, frame_color = color.rgb(25, 150, 25),
frame_width = 3, border_color = color.rgb(25, 150, 25))