♥ 0 |
Hi, I am trying to add a custom strategy using the following thinkscript. Buy when the C Wave turns Cyan (expansion) above zero and sell when you get a blue (contraction) C Wave bar. Can you tell me what code needs to be added so that it only exectes order when the Wave is above zero, I am missing that part. thanks!
def cWaveUpper = TTM_Wave().Wave2High; AddOrder(OrderType.BUY_AUTO, changesToCyan, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = “WaveCyanLE”);
Marked as spam
|
Private answer
The TTM_Wave C has two components, as you have implied with your example code. When you say "Wave C above zero", which of the two components are you talking about? The best solution I have for you is the previous post for a scan based on TTM_Wave C crossing the zero line: https://www.hahn-tech.com/ans/scan-and-alert-when-ttm-wave-c-crosses-zero/
Let's see if I can help you understand what you wrote, so you can see the code is doing exactly what you have written. From this, I hope to you assist you in seeing the solution. Let's take a look at two lines of code from the example you provided in the comment section of your question:
Each of those two lines result in a boolean output, true or false. If the Wave2High is above zero the return value for the variable named aboveZeroUpper is 1 (true). if the Wave2High is below zero, the return value for the variable named aboveZeroUpper is 0 (false). Likewise for the Wave2Low and the aboveZeroLower. Those two variables are used in the next line of code from your example:
So you are subtracting the boolean output of one variable from the boolean output of the other. Basically what you have there is one of the following combinations:
So you take the variable named cWaveDiff and try to use that in the following lines of code (which you then use to generate your orders):
Let's just take the first one, changesToCyan, and see how things play out given the inputs coming from the previous lines:
.... there are more combinations here but by now I hope you get the idea. There is absolutely nothing in the chain of variables that has even the slightest thing to do with either plot from the Wave2 crossing zero. So what do we have from the previous post I linked above? What does it look like when we test for both plots of the Wave2 crossing zero? I'll just copy and paste that here:
Now, how do we trigger an order when both plots of the Wave2 have first crossed above zero?
So by now you should know exactly where you went wrong. But you should also understand that the solution I linked in my original response was the actual solution. You only needed to copy and paste that code and use the scan signal as the condition of your entry order. In order to include the exit for when the Wave2 histogram turns blue, you will be using some of the code you originally provided in your question. Marked as spam
|
Please log in to post questions.