Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm trying to create a dynamic cloud in thinkorswim. The following is an illustration of what i'm trying to do. Think of aLine, bLine1, bLine2 and bLine3 as different moving averages. When aLine Crosses above one of the bLines, create a cloud between aLine and that bLine and same when aLine Crosses below one of the bLines. The Grey is the desired cloud.
I used typical crossover code to try to accomplish this (as follows):
The script doesn't give errors but it doesn't create a cloud. I did an Arrow paintingstrategy for aLinePlot and bLinePlot to see if the script is recognizing the crossovers and crossunders and thinkorswim is recognizing the crossover locations but why isn't the cloud being created?
Can you help answer these questions from other members on NexusFi?
For starters, you have no precedent def for "bLine" or explanation in your post for what "bLine" is, though it appears several times in your code. You only tell us what bLine1, bLine2, and bLine3 should represent. Could you maybe give us the whole code, including needed defs?
Is this close to what you want? Your conditional arguments were pretty lengthy and made my head spin a bit so I just went with what you said in the opening text of your post. Hope I understood it right. Not sure what you wanted the code to do but this code suggests that once price breaks above the cloud it keeps going up for several periods, vice versa when breaks below the cloud.
input alineavg = 9;
input bline1avg = 5;
input bline2avg = 5;
input bline3avg = 5;
def aline = average(close,alineavg);
def bline1 = average(high,5);
def bline2 = average(low,5);
def bline3 = average(close,5);
def bline = bline1 or bline2 or bline3;;
plot P = aline;
plot Q = bline1;
plot R = bline2;
plot S = bline3;
addcloud(aLine,bLine1, createcolor(153,153,153), createcolor(102,102,102));
AddCloud(aLine,bLine2,color.red,color.red);
addcloud(aLine,bLine3,color.plum,color.plum);
EDIT: Ah, the "def bline" part is non-operative here, just a suggestion for how to handle the issue for your original code.
For starters, you have no precedent def for "bLine" or explanation in your post for what "bLine" is, though it appears several times in your code. You only tell us what bLine1, bLine2, and bLine3 should represent. Could you maybe give us the whole code, including needed defs?
Thank you for responding!
For the sake of this example, i just want to assume aline, bline1, bline2, and bline3 are simple moving averages just to keep the example simple but for my actual code, aline, bline represent daily and weekly VWAP lines and the VWAP Standard Deviation lines so that's more complicated than I need to explain for what I'm trying to accomplish.
The idea is that as the aLine (a 25period simple moving average) is moving across longer period moving averages (100, 200, 800), it'll create a new cloud each time it crosses meaning the old cloud goes away.
The cloud becomes a moving, more accurate BIAS indicator. On days when Aline crosses over any Blines, there will be a new cloud between aline and bline... (addcloud, aline, bline, color.xxx, color.xxx).
But when the ALine crosses under any Blines, there will be a new cloud between bline and aline... meaning the cloud will be inverted (addcloud, bline, aline, color.xxx, color.xxx).
We can't use the addcloud function with Conditional if, then, else statements. Thinkscript doesn't like it. So the only other solution is to have only ONE addcloud function and have the two cloud variables change depending on the condition.
If anybody would like, i can send them the script... it might make more sense if you see it on a chart.
Here's some screenshots with my messy paint drawings to better describe what i'm looking for.
Is this close to what you want? Your conditional arguments were pretty lengthy and made my head spin a bit so I just went with what you said in the opening text of your post. Hope I understood it right. Not sure what you wanted the code to do but this code suggests that once price breaks above the cloud it keeps going up for several periods, vice versa when breaks below the cloud.
input alineavg = 9;
input bline1avg = 5;
input bline2avg = 5;
input bline3avg = 5;
def aline = average(close,alineavg);
def bline1 = average(high,5);
def bline2 = average(low,5);
def bline3 = average(close,5);
def bline = bline1 or bline2 or bline3;;
plot P = aline;
plot Q = bline1;
plot R = bline2;
plot S = bline3;
addcloud(aLine,bLine1, createcolor(153,153,153), createcolor(102,102,102));
AddCloud(aLine,bLine2,color.red,color.red);
addcloud(aLine,bLine3,color.plum,color.plum);
EDIT: Ah, the "def bline" part is non-operative here, just a suggestion for how to handle the issue for your original code.
Hi, Thank you for responding!
Your code is close! What we would get with the 3 addcloud functions you use would look a little like this:
Your code is close! What we would get with the 3 addcloud functions you use would look a little like this:
...
Yes, it does. And I think what you're saying is that you want a single, discontinuous cloud? So, for example, the cloud from a cross of aline/bline1 disappears when cross of aline/bline2 occurs. Hmm, seems to me that could be written into the plots of PQRS. That way, you avoid the problem of TOS not liking conditionals in Cloud string per se. Would that work?
Yes, it does. And I think what you're saying is that you want a single, discontinuous cloud? So, for example, the cloud from a cross of aline/bline1 disappears when cross of aline/bline2 occurs. Hmm, seems to me that could be written into the plots of PQRS. That way, you avoid the problem of TOS not liking conditionals in Cloud string per se. Would that work?
Yes, I was trying to write them into the plots with those 2 big define statements. I was using crossover and crossunder logic... a.k.a if aline > bline and aline[1] <= bline[1] then aline else... but that only seems to pinpoints the exact area of the occurring crossover.
"We can't use the addcloud function with Conditional if, then, else statements. Thinkscript doesn't like it. So the only other solution is to have only ONE addcloud function and have the two cloud variables change depending on the condition.
If anybody would like, i can send them the script... it might make more sense if you see it on a chart."
do you still have this by any chance? trying to say, if condition A, then cloud, else, no cloud