NexusFi: Find Your Edge


Home Menu

 





Dynamic Cloud


Discussion in ThinkOrSwim

Updated
    1. trending_up 5,362 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Dynamic Cloud

  #1 (permalink)
 
TraderEnlight's Avatar
 TraderEnlight 
Los Angeles, CA/USA
 
Experience: Beginner
Platform: thinkorswim
Trading: Futures
Posts: 12 since Aug 2014
Thanks Given: 3
Thanks Received: 1

Hi All,

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):
 
Code
def aLineplot = if aLine > bLine1 and aLine[1] <= bLine1[1] then bLine1 else if aLine > bLine2 and aLine[1] <= bLine[2] then bLine2 else if aLine > bLine3 and aLine[1] <= bLine3[1] then bLine3 else if aLine < bLine3 and aLine[1] >= bLine3[1] then aLine else if aLine < bLine2 and aLine[1] >= bLine2[1] then aLine else if aLine < bLine1 and aLine[1] >= bLine1[1] then aLine else 0;

def bLineplot =  if aLine > bLine1 and aLine[1] <= bLine1[1] then aLine else if aLine > bLine2 and aLine[1] <= bLine[2] then aLine else if aLine > bLine3 and aLine[1] <= bLine3[1] then aLine else if aLine < bLine3 and aLine[1] >= bLine3[1] then bLine3 else if aLine < bLine2 and aLine[1] >= bLine2[1] then bLIne2 else if aLine < bLine1 and aLine[1] >= bLine1[1] then bLine1 else 0;

addcloud(aLineplot,bLineplot, createcolor(153,153,153), createcolor(102,102,102));
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?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
15 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
My NQ Trading Journal
11 thanks
  #2 (permalink)
tangerine
albuquerque nm/usa
 
Posts: 29 since Aug 2015
Thanks Given: 3
Thanks Received: 9


TraderEnlight View Post
Hi All,

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):
 
Code
def aLineplot = if aLine > bLine1 and aLine[1] <= bLine1[1] then bLine1 else if aLine > bLine2 and aLine[1] <= bLine[2] then bLine2 else if aLine > bLine3 and aLine[1] <= bLine3[1] then bLine3 else if aLine < bLine3 and aLine[1] >= bLine3[1] then aLine else if aLine < bLine2 and aLine[1] >= bLine2[1] then aLine else if aLine < bLine1 and aLine[1] >= bLine1[1] then aLine else 0;

def bLineplot =  if aLine > bLine1 and aLine[1] <= bLine1[1] then aLine else if aLine > bLine2 and aLine[1] <= bLine[2] then aLine else if aLine > bLine3 and aLine[1] <= bLine3[1] then aLine else if aLine < bLine3 and aLine[1] >= bLine3[1] then bLine3 else if aLine < bLine2 and aLine[1] >= bLine2[1] then bLIne2 else if aLine < bLine1 and aLine[1] >= bLine1[1] then bLine1 else 0;

addcloud(aLineplot,bLineplot, createcolor(153,153,153), createcolor(102,102,102));
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?

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?

Reply With Quote
  #3 (permalink)
tangerine
albuquerque nm/usa
 
Posts: 29 since Aug 2015
Thanks Given: 3
Thanks Received: 9


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.

Reply With Quote
  #4 (permalink)
 
TraderEnlight's Avatar
 TraderEnlight 
Los Angeles, CA/USA
 
Experience: Beginner
Platform: thinkorswim
Trading: Futures
Posts: 12 since Aug 2014
Thanks Given: 3
Thanks Received: 1


tangerine View Post
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.




Started this thread Reply With Quote
  #5 (permalink)
 
TraderEnlight's Avatar
 TraderEnlight 
Los Angeles, CA/USA
 
Experience: Beginner
Platform: thinkorswim
Trading: Futures
Posts: 12 since Aug 2014
Thanks Given: 3
Thanks Received: 1


tangerine View Post
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:


Started this thread Reply With Quote
  #6 (permalink)
tangerine
albuquerque nm/usa
 
Posts: 29 since Aug 2015
Thanks Given: 3
Thanks Received: 9


TraderEnlight View Post
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:

...

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?

Reply With Quote
  #7 (permalink)
 
TraderEnlight's Avatar
 TraderEnlight 
Los Angeles, CA/USA
 
Experience: Beginner
Platform: thinkorswim
Trading: Futures
Posts: 12 since Aug 2014
Thanks Given: 3
Thanks Received: 1


tangerine View Post
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.

There has to be a way to do this...

Started this thread Reply With Quote
  #8 (permalink)
bsauce
Northlake, Texas
 
Posts: 1 since Jan 2019
Thanks Given: 0
Thanks Received: 0

"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

Reply With Quote




Last Updated on January 7, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts