Untitled

 avatar
EBTURK
plain_text
2 months ago
2.9 kB
8
Indexable
Never
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EBTurk https://twitter.com/ebturkfx
//@version=5

strategy('ICT London KZ Candle Strategy', overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// Define the EST timezone
timezone = 'US/Eastern'

// Get the close price of the 2AM EST candle
var float close_2am = na
if hour(time, timezone) == 2
    close_2am := close
    close_2am

// Define the take profit and stop loss levels using input variables
tp_long_percent = input.float(title='Take Profit (%)', defval=0.14, step=0.01)
sl_long_percent = input.float(title='Stop Loss (%)', defval=0.30, step=0.01)
tp_long_level = close_2am * (1 + tp_long_percent / 100)
sl_long_level = close_2am * (1 - sl_long_percent / 100)
// Define Short
tp_short_percent = input.float(title='Take Profit (%)', defval=-0.14, step=0.01)
sl_short_percent = input.float(title='Stop Loss (%)', defval=-0.30, step=0.01)
tp_short_level = close_2am * (1 + tp_short_percent / 100)
sl_short_level = close_2am * (1 - sl_short_percent / 100)

// Plot long or short label based on the 2AM EST candle color
if hour(time, timezone) == 2
    if close_2am < open
        strategy.entry('Long', strategy.long)
        strategy.exit('Long TP/SL', 'Long', limit=tp_long_level, stop=sl_long_level)
        label.new(bar_index, close_2am, 'Long', color=color.green, textcolor=color.white, style=label.style_label_up, yloc=yloc.price)
        // label.new(bar_index, tp_long_level, 'TP', color=color.green, textcolor=color.white, style=label.style_label_center, yloc=yloc.price)
        // label.new(bar_index, sl_long_level, 'X', color=color.red, textcolor=color.white, style=label.style_label_center, yloc=yloc.price)
		label.new(bar_index, low, "LONG: Price: " + str.tostring(close_2am, "#.######") + "\nTP: " + str.tostring(tp_long_level, "#.######") + "\nSL: " + str.tostring(sl_long_level, "#.######"), color=color.green, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar)

    else if close_2am > open
        strategy.entry('Short', strategy.short)
        strategy.exit('Short TP/SL', 'Short', limit=tp_short_level, stop=sl_short_level)
        label.new(bar_index, close_2am, 'Short', color=color.red, textcolor=color.white, style=label.style_label_down, yloc=yloc.price)
        // label.new(bar_index, tp_short_level, 'TP', color=color.red, textcolor=color.white, style=label.style_label_center, yloc=yloc.price)
        // label.new(bar_index, sl_short_level, 'X', color=color.green, textcolor=color.white, style=label.style_label_up, yloc=yloc.price)
		label.new(bar_index, low, "SHORT: Price: " + str.tostring(close_2am, "#.######") + "\nTP: " + str.tostring(tp_short_level, "#.######") + "\nSL: " + str.tostring(sl_short_level, "#.######"), color=color.green, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar)

Leave a Comment