Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Need help to get strategy.entry date to be set to the date that signal occurs on.

Why my strategy gives a signal to enter, I would like the entry date to be the same as the date that the signal occurs on.

Below is a simple strategy for demonstration purposes. I have applied the strategy to SPY (daily). The first entry date is 2015-05-19 but the date that my signal occurs (close greater than 213) is 2015-05-18. So, in this case, I would like the entry date to be 2015-05-18 rather than 2015-05-19.

What do I need to do so that the entry date is the close of the date that my signal occurs on rather than the open of the next day?
Thanks for any help!!!

//@version=2
strategy("Test Strategy", overlay=true)
if (close > 213)
strategy.entry("test", strategy.long, 1)
strategy.close("test")
4 people have
this question
+1
Reply
  • I've tried:
    // get value at a certain time
    plot(valuewhen(timestamp("GMT-5", 2018, 06, 05, 15, 59), hl2, 0))

    In an attempt to workaround the issue by getting some semblance of Price, just before the market close in my TimeZone, etc. It plots before the condition is reached so it is not working as expected.

    Other than that, when your strategy keys off the Close as you have shown, then it will move to the next available tick (the Open of the next day) to pull the Price. I argue that Post and Pre Market trading is very much a widespread thing now, but I get it, but for the sake of a Strategy it really seems to logically make sense that we grab the pricing at the times that the triggers are made. I get it though.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • I think it boils down to, I'd really like the ability to load Strategy.Entry with a Price at a specific Time, at least the previous Close.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited