Created
March 6, 2022 23:05
-
-
Save smyth64/13d103cf05ad612920ce9a4acdceb5ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// enter_short and enter_long are the conditions that you use to enter a trade. they need to be defined by you | |
// They look something like this: | |
// enter_long = window() and entryConfirmed | |
// strategy.entry(id='Long', long = true, when=enter_long) | |
// | |
bgcolor = close > strategy.position_avg_price[1] ? color.new(#168978, 80) : color.new(#f05350, 80) | |
border_color = close > strategy.position_avg_price[1] ? color.new(color.green, 20) : color.new(color.red, 20) | |
barsSinceLong = barssince(enter_long and strategy.position_size <= 0) | |
if (strategy.position_size <= 0 and strategy.position_size[1] > 0) | |
box.new(left=bar_index[barsSinceLong], top=close[barsSinceLong], right=bar_index, bottom=close, border_color=border_color, bgcolor=bgcolor) | |
bgcolor := close < strategy.position_avg_price[1] ? color.new(#168978, 80) : color.new(#f05350, 80) | |
border_color := close < strategy.position_avg_price[1] ? color.new(color.green, 20) : color.new(color.red, 20) | |
barsSinceShort = barssince(enter_short and strategy.position_size >= 0) | |
if (strategy.position_size >= 0 and strategy.position_size[1] < 0) | |
box.new(left=bar_index[barsSinceShort], top=close[barsSinceShort], right=bar_index, bottom=close, border_color=border_color, bgcolor=bgcolor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment