♥ 0 |
Hi Pete, I am new to programming. How can I write a simple code- close is greater than high from 15 bars ago. If I write it like that -the program just looks at the close of the bar -15 bars ago. I want it to look at the last 15 bars. close is greater than high from 1-15 bars ago. but this don’t work either. Any ideas or examples? thanks
Marked as spam
|
Please log in to post questions.
thanks it works by itself, But. what if I want to combine it with another command. Example-close is greater than a certain price (and the the current high is greater than the highest high of the last 15 bars.)-already got this part from your answer above.
I tried these 2-but no luck? thanks
def signal = high > Highest(high[1], 15);
close is greater than 100 and close is greater than signal;
close is greater than 100 and close is greater then def signal = high > Highest(high[1], 15);
“signal” is a true/false result. It is either true or it is false. So you cannot use it in a comparison against price. So “close is greater than signal” is meaningless. Because “signal” is either true or 0 false. Can the close every be greater than true? Or greater than false? No, makes no sense whatsoever.
Here is how we accomplish this:
def signal = high > Highest(high[1], 15);
def otherSignal = close > 100;
plot scan = signal and otherSignal;
Everything here is converted to true/false statements. Because the scan only understands true or false. The scan returns a result ONLY when signal equals true AND otherSignal equals true.
Seeing where you are at, I highly recommend you stop what you are working on and work through the entire Thinkscript tutorial, published by TD Ameritrade.
Basic: http://toslc.thinkorswim.com/center/howToTos/tutorials/Basic.html
Advanced: http://toslc.thinkorswim.com/center/howToTos/tutorials/Advanced.html
Thanks for your help Pete, What a great website. keep up the good work. Have a great New Years!!!