Time In Force Order: How to Keep Order active between 0000 and 1459 everyday?

gchan1582

New member
I back tested my strategy, and found that it is more effective between 0000 and 1459 everyday on the forex market.

I used this video:


Using the SecondsFromTime() and SecondsTillTime() functions, I was able to test my strategy.

However, when I go to the Order thinkScript Editor, I do not know how to do this.

I am using the MovAvgTwoLinesStrategy for backtesting.

I am using the MovAvgTwoLines Study for the Order.

I think the study and the strategy are related, as they are named similarly, but they are coded a bit differently.

I am also familiar with the Condition Wizard, but again, I'm not sure how to implement this.

I have done some coding classes, and can copy code, and modify some numbers, move some things around, but as for writing new constructive code, that becomes a challenge for me.

I have been able to piece together different snippets of code to test RSI, bollinger bands, TTM Squeeze in some combinations. But, that is the extent of my abilities at this time.

I think this would be useful for those trying to trade the stock market, and control their orders between premarket and postmarket hours, or between market hours, as well.

thank you all for your help and feedback.
 
This might help get you started. It's what I use for my study P/L script

C#:
input tradeDaytimeOnly = no; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
input OpenTime = 0930; #hint OpenTime: Opening time of market
input CloseTime = 1600; #hint CloseTime: Closing time of market


def Begin = secondsfromTime(OpenTime);
def End = secondsTillTime(closetime);
# Only use market hours when using intraday timeframe
def isIntraDay = if getaggregationperiod() > 14400000 then 0 else 1;
def MarketOpen = if tradeDaytimeOnly AND isIntraDay then ((Begin > 0) and (End > 0)) else 1;

You can then check if the market is "open" before making a trade or close a position when the market ends for your day.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
322 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top