Login Page - Create Account

Support Board


Date/Time: Tue, 23 Apr 2024 11:51:37 +0000



[Programming help] How to exit any position after 20 bars since it's opened using ASCII?

View Count: 210

[2023-03-10 12:07:57]
User395175 - Posts: 67
Hi, i want my programme exit the position after a fixed number of bars (like 20), how can i do it?

I will have multiple positions open at the same time, for each, i want it to be closed after 20 bars since it opened. I saw there is a sc function called sc.GetBarsSinceLastTradeOrderEntry(), but it only consider the last trade. i don't think i can use it in my case.

Please help me, thank you.
[2023-03-10 14:14:18]
User268846 - Posts: 17
you can store the order id and entry bar index for each order and then check if they are expired or not each bar
[2023-03-10 14:17:03]
User268846 - Posts: 17
... assumed you use market orders for entry ...

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account