♥ 0 |
I want to only trade during the hours of 10am to 1pm. I have attempted to modify the code in a simple moving average strategy to try and get the report results to limit backtesting results to the hours of 10-1pm. Is that possible? I’ve tried a few different commands like “input opentime = 1000; input durationhours = 3;” and “MarketopenTime = 1000; MarketcloseTime = 1300 “but I honestly don’t know the proper syntax. I’m fresh on my journey to learning Thinkscript. 🙂
Marked as spam
|
Private answer
You can use the code provided in the following post in the Stock Scanners topic: https://www.hahn-tech.com/ans/scan-within-a-specific-hour-time-range/ The solution in that post provides a true/false variable that can be used to filter all manner of items on the chart. The last line of the code produces a variable named "scanPeriod". Depending on how you configure the last line of code (read the instructions provided in that post), you can set the start and end times so that the "scanPeriod" variable is true only within the start and end times selected in the user inputs. You didn't provide your fully functioning code for the chart strategy, so I can not give you an exact example of how to implement this in your own code. Its up to you to figure out how to implement this in your own code. Marked as spam
|
Please log in to post questions.