Hi,
I spent a long time trying to figure this out with no success. I'll start off by saying what I'm trying to achieve:
I enter positions manually, and I am trying to set up a conditional order as a stop.
This conditional order should be based on:
To set this up I created a conditional order template and used the wizard to easily add the rules that I mentioned above
This is the code I used to calculate and plot the minutes left for each trading day:
After reading about the different functions in the ThinkScript Learning Center I realized that most of these time functions will not give me the correct time when I am using a daily aggregation period.
Does anyone know a way around this issue so I can get the correct time left before the end of the trading day?
If that's not possible then do you know of any other way I can get achieve my goal using a conditional order?
Thanks!
I spent a long time trying to figure this out with no success. I'll start off by saying what I'm trying to achieve:
I enter positions manually, and I am trying to set up a conditional order as a stop.
This conditional order should be based on:
- If last price is under the 10 day simple moving average (on the daily chart)
- Since I would like to execute the order within standard trading hours (not aftermarket), I'd like the stop to trigger is the price drops below the 10 day moving average within the last 15 minutes of the trading day.
To set this up I created a conditional order template and used the wizard to easily add the rules that I mentioned above
This is the code I used to calculate and plot the minutes left for each trading day:
Code:
def EndTime = RegularTradingEnd(GetYYYYMMDD());
def GetTime = GetTime();
def SecondsRemained = RoundUp((EndTime - GetTime) / 1000);
def MinutesRemained = SecondsRemained / 60;
plot MinutesLeft = MinutesRemained;
After reading about the different functions in the ThinkScript Learning Center I realized that most of these time functions will not give me the correct time when I am using a daily aggregation period.
Does anyone know a way around this issue so I can get the correct time left before the end of the trading day?
If that's not possible then do you know of any other way I can get achieve my goal using a conditional order?
Thanks!