♥ 0 |
I’m setting up a script that displays a buy when the heikin ashi candle is green if the previous is red. And then to sell at the first red candle. However, at the beginning of let’s say a 1 year daily chart that starts with a green candle, I will get a sell when it turns red, but I had no associated buy (because it would have triggered before the 1 year chart started). I’m doing some further counting and PL forecasts with the buy and sell. I can’t figure out how to set up a variable that says I’m in a Buy and I would use that on my sell statement as “AND inBuy” or “AND isLong” Here are the two statements that initiate the buy and sell. I was trying to use switch and set the state as long but I cannot figure it out. def buy = haOpen[0] < haClose[0] and haOpen[1] > haClose[1] ; then I post a bubble on the daily chart to show the buy and the closing price for that day and then the sale bubble on the sell day. There are some other calcs in between where I need to know when I’m in the “buy/long state” AddChartBubble(buy, low, Concat(“B:”, close), Color.GREEN, no); Many thanks, Joe
Marked as spam
|
Please log in to post questions.
Hi Pete
Thank you for taking the time to respond.
I did try this as a strategy but the Buys would occur on the next (candle) day and the sells the next day as well. I could not figure out how to get them to occur at the close of the day, on the day that the signal is set.
There are also some other items I am calculating such as average days in the buy, PL between the buy and sell, etc. All of it works except when i get a sale before the buy.
Take some time to review the answer to this post.
https://www.hahn-tech.com/ans/parablic-sar-signal-not-firing-in-tos-strategy/
The point you want to grasp from this is how to ensure your buys and sells are aligned on the correct bar. Also take note of the importance that entry and exit prices occur within the traded range of the bar (below the high and above the low). This is a bit tricky and you have understand the offset that the strategy employs behind the scenes. This post should give you the tools to be able to run your own experiments and learn how strategies work.
As to the rest of it. Pretty sure you can compute what you need by exporting the Strategy report to an Excel spreadsheet, where you can compute most anything you want. Since you are trying to do this manually, using the code, I assume you have not viewed our video series on Strategies.
https://www.hahn-tech.com/thinkorswim-strategy-guide/
https://www.hahn-tech.com/tos-strategy-analysis/
https://www.hahn-tech.com/thinkorswim-strategy-analysis/
If you should ever require our professional services you can get all the details here: https://www.hahn-tech.com/about/