0

sorry my english. Im not native speaker.

Hi all, i have a dude about stops in Pine-script.

I'm tring to make a specific trail stop in my strategy script.

I want to make a for loop to evaluate all candless from open strategy date until today.

Has pine-script any variable which contains open position date or number of days or similar thing ?

thank you very much.

2 Answers2

0

There is no variable that I know of that records the date of entries, but since it's your strategy, you should know when it's entering/exiting trades, so you should be able to save the time when those events occur.

Also, rather than waiting for a number of bars to elapse and go back over them with a for loop, it will be much more efficient for you to start tracking whatever info you need from the moment your condition triggers. For most needs, this should allow you to forego using a for loop.

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
0

I was just reading this thread: Strategy with sample code

And noticed that it has some work with trailing stop in it. Basically, you should be able to find some pine scripts that work with trailing stops and tailor it to your needs.