chat gpt professional edition.. i have not verified this code m
//@version=5
indicator("GBPUSD Orders", overlay = true)
// Define session start time (12:00 AM GMT)
sessionStartHour = input(0, title = "Session Start Hour (GMT)")
sessionStartMinute = input(0, title = "Session Start Minute (GMT)")
// Define ATR length
atrLength = input(14, title = "ATR Length")
// Calculate ATR value
atrValue = ta.atr(atrLength)
// Calculate entry prices for buy and sell orders
buyStopPrice = atrValue + ta.open
buyLimitPrice = (-atrValue / 3) + ta.open
sellStopPrice = (-atrValue) + ta.open
sellLimitPrice = (atrValue / 3) + ta.open
// Calculate session time
sessionTime = ta.hour * 60 + ta.minute
// Initialize order variables
var order1 = na
var order2 = na
var order3 = na
var order4 = na
// Condition to check if it's a working day and the session time is 12:00 AM GMT
if ta.dayofweek >= 1 and ta.dayofweek <= 5 and sessionTime == sessionStartHour * 60 + sessionStartMinute
// Check if order 1 is not active and order 2 is not active
if na(order1) and na(order2)
// Place buy stop order
order1 := ta.buy_stop("Buy Stop", stop = buyStopPrice, qty = 1)
// Check if order 3 is not active and order 4 is not active
if na(order3) and na(order4)
// Place sell stop order
order3 := ta.sell_stop("Sell Stop", stop = sellStopPrice, qty = 1)
// Check for trade activations and deletions
if not na(order1) and ta.crossover(ta.close, buyLimitPrice)
// Delete order 2 if it's active
if not na(order2)
ta.cancel(order2)
// Delete order 3 if it's active
if not na(order3)
ta.cancel(order3)
// Delete order 4 if it's active
if not na(order4)
ta.cancel(order4)
if not na(order3) and ta.crossunder(ta.close, sellLimitPrice)
// Delete order 1 if it's active
if not na(order1)
ta.cancel(order1)
// Delete order 2 if it's active
if not na(order2)
ta.cancel(order2)
// Delete order 4 if it's active
if not na(order4)
ta.cancel(order4)
// Plot entry prices on the chart
plotshape(series = buyStopPrice, title = "Buy Stop", location = location.belowbar, color = color.green, style = shape.triangleup, size = size.small)
plotshape(series = buyLimitPrice, title = "Buy Limit", location = location.belowbar, color = color.green, style = shape.triangleup, size = size.small)
plotshape(series = sellStopPrice, title = "Sell Stop", location = location.abovebar, color = color.red, style = shape.triangledown, size = size.small)
plotshape(series = sellLimitPrice, title = "Sell Limit", location = location.abovebar, color = color.red, style = shape.triangledown, size = size.small)