♥ 0 |
Pete Would you write the code that, using the AUTO BUY function in TOS Backtester, that buys (near the close) 7 days (calendar) and AUTO SELL 1 day before earnings. I have tried multiple times but been unsuccessful. Thanks much
Marked as spam
|
Private answer
Ok let's begin by correcting some of the terms you used. Need to make sure we don't start people off on the wrong foot by using terms that don't really exist. "AUTO BUY Function":There is no such thing. There is something called an AddOrder() statement in the Thinkscript language. And this statement is actually a method. It takes several parameters, one of which is the order type. You can get full details here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder.html The AddOrder() statement is applied to a chart analysis tool that Thinkorswim refers to as a Strategy. In most cases we use the order types of "OrderType.BUY_TO_OPEN" for an entry order. Then we use the order type "OrderType.SELL_TO_CLOSE" for the exit order. The only time you would use the other order types is if you are building a type of strategy that is always in a position. These are called "Stop-and-Reverse" strategies. For these, you would use the following order types: "OrderType.BUY_AUTO" and "OrderType.SELL_AUTO" "TOS Backtester":Once again, there is no such thing. As mentioned above, Thinkorswim refers to this as a Chart Strategy. The Chart Strategies simply plot theoretical buys and sells on the chart. Then it makes available a report you can export for further evaluation. It is this report, once exported, that forms the basis for backtesting the strategy. The Code:Now that we have these little items cleared up for our viewers, let's got on with the solution to your request. Here it is, just two lines of code:
Screenshot below shows the results. Marked as spam
|
Please log in to post questions.