Skip to content

Instantly share code, notes, and snippets.

@tinwritescode
Last active April 19, 2022 13:35
Show Gist options
  • Save tinwritescode/d5c8563f4bd5c57b2dc5f503584dff69 to your computer and use it in GitHub Desktop.
Save tinwritescode/d5c8563f4bd5c57b2dc5f503584dff69 to your computer and use it in GitHub Desktop.
//@version=5
strategy("My Strategy", overlay=true)
source = close
var float[] arr = array.from(1.0, -2.0, 3.0, -4.0, 3.0)
// get new price equal to the old price
var float newPrice = source
// for each next 5 candles, get the new price equal old price plus each element of the array
for i = 0 to 4
if (i % 2 == 0)
newPrice := newPrice + array.get(arr, i)
else
newPrice := newPrice - array.get(arr, i)
// if the lower price of the candle next to source is greater than the new price, mark it as a buy signal
if (ta.lowest(source + i, 1) < newPrice)
strategy.entry("Dính giao dịch", strategy.long, stop=source + i, oca_name="This is OCA name", oca_type=strategy.oca.cancel, comment="This is comment")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment