♥ 0 |
I have two criteria that are part of the same strategy. They are similar but different enough that I have defined two separate ‘def’ in my strategy code. One entry is often “better” than the other (‘A’ is better than ‘B’), but in the right circumstances, it’s the other way around. EXAMPLE: def EntryA = a + b + c…; def EntryB = x + y + z…;
My question is then broken into two parts: 1. Can I customize the AddOrder code to look for EntryA first and then only enter EntryB as a secondary criteria (i.e. when EntryA criteria is not met)? Not sure if the standard ‘If’ statement does this prioritization by default, based on the order it is written.
2. Can I customize the text shown on the chart when the order is opened (to call out EntryA or EntryB? I want to distinguish which entry “fired” so I can make a decision.
As always – thank you!
Marked as spam
|
Private answer
You did not provide a fully functional section of code so I had to build one of my own. Which means I had to make several assumptions as to what you are trying to accomplish. The following is a section of code that fully functions as a chart strategy. There are two conditions that can generate an entry. Each one is assigned to it's own AddOrder() statement. Each AddOrder() statement is set to display the name of the condition that generated the entry on the chart. The exit is 2% below the entry price. Which means this chart strategy can only loose money, it is useless for trading but it demonstrates one method you might employ to accomplish your stated goals.
I have included a screenshot below showing how this looks on the chart.
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder Marked as spam
|
Please log in to post questions.