Help needed to add cloud

Abutterfly

New member
VIP
This is more difficult than I thought. DanL in Futures channel shared a book "The SImple Strategy" by Markus Heitkoetter and Mark Hodge. Spent a few hours putting the codes together to do what the book asks. However, I could not get the cloud (my own idea) to show a straight line like ORB. Wanted to show a cloud or a Plot or a horizontal line for a trade triggered and two more lines. One for stop loss and One for target profit. Seen this in another indicator. But could not get it into this indicator, this code. Can someone help ?











#~~~~~~~~~~~~~~~~~~~~~~~DanL in Futures shared the book
#~~~~~~~~~~~ by Markus Heitkoetter and Mark Hodge



#`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~ ADR = Average Daily Range 7 days average
#~~~~~~~~~~~~~~~~~~~~~ High less Low of each day for 7 prior days
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def highDaysAgo1 = high(period = AggregationPeriod.DAY)[1];
def lowDaysAgo1 = low(period = AggregationPeriod.DAY)[1];

def highDaysAgo2 = high(period = AggregationPeriod.DAY)[2];
def lowDaysAgo2 = low(period = AggregationPeriod.DAY)[2];

def highDaysAgo3 = high(period = AggregationPeriod.DAY)[3];
def lowDaysAgo3 = low(period = AggregationPeriod.DAY)[3];

def highDaysAgo4 = high(period = AggregationPeriod.DAY)[4];
def lowDaysAgo4 = low(period = AggregationPeriod.DAY)[4];

def highDaysAgo5 = high(period = AggregationPeriod.DAY)[5];
def lowDaysAgo5 = low(period = AggregationPeriod.DAY)[5];

def highDaysAgo6 = high(period = AggregationPeriod.DAY)[6];
def lowDaysAgo6 = low(period = AggregationPeriod.DAY)[6];

def highDaysAgo7 = high(period = AggregationPeriod.DAY)[7];
def lowDaysAgo7 = low(period = AggregationPeriod.DAY)[7];

Def SumOfDifference = ((highDaysAgo1 - lowDaysAgo1)+
(highDaysAgo2 - lowDaysAgo2)+
(highDaysAgo3 - lowDaysAgo3)+
(highDaysAgo4 - lowDaysAgo4)+
(highDaysAgo5 - lowDaysAgo5)+
(highDaysAgo6 - lowDaysAgo6)+
(highDaysAgo7 - lowDaysAgo7));

Def ADR = round(SumOfDifference / 7, 1);





#~~~~~~~~~~~~~~~~~~~~~~~ Bollinger Bands
Code:
~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




input length = 20;
input num_devs = 2.0;
input bollinger_price = close;
input Upper_band_price = close;
input Lower_band_price = close;


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~ BOLLINGER BANDS and first condition
Code:
~~~~~~~~~~~~~~~~~~~
def BBUPPer = Average(bollinger_price, length) + num_devs * stdev(bollinger_price, length);

def BBconditionUP_1 = Upper_band_price   crosses above BBUPPer[1]
; 
# and high[-1] >= BBUPPer;

def BBconditionUP_2 = Upper_band_price   equals  BBUPPer[1]
; 
#and high[-1] >= BBUPPer;


def BBLower = Average(bollinger_price, length) - num_devs * stdev(bollinger_price, length);

def BBconditionDOWN_1 = Lower_band_price crosses below BBLower[1]
;
# and  low[-1] <= BBLower;

def BBconditionDOWN_2  = Lower_band_price equals BBLower[1]
; 
#and  low[-1] <= BBLower;

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~MACD ABOVE ZERO and below

input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;

def MACDdiff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff;
plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;

def ADR_LONG= MACDdiff > 0 and MACDdiff > Avg and (BBconditionUP_1 or BBconditionUP_2 ) ;

def ADR_SHORT= MACDdiff < 0 and MACDdiff < Avg and (BBconditionDOWN_1 or BBconditionDOWN_2 ) ;


#~~~~~~~~~~~~~~~~~~~~~~~~ Define Stop Loss and Profit Targets
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Def LongStopLoss = close - ADR*.1;
Def LongProfit = close + ADR *.2;

Def ShortStopLoss = close + ADR*.1;
Def ShortProfit = close - ADR *.2;

#~~~~~~~~~~~~~~~~~~~~ show bubble at trade trigger location
AddChartBubble(ADR_LONG, high, "SS+", Color.dark_Green, yes);
AddChartBubble(ADR_SHORT, high, "SS-", Color.light_RED, yes);



#AddCloud(ADR_LONG, LongStopLoss, Color.LIGHT_RED, Color.LIGHT_RED);
#AddCloud(close, ShortStopLoss, Color.yellow, Color.yellow);
def nan = Double.NaN;


#~~~~~~~~~~~~~~~ failed attempt to plot stop loss
plot LongStopLoss1 = if ADR_LONG then close - ADR*.1 else nan;
plot ShortStopLoss1 = if ADR_SHORT then close + ADR*.1 else nan;



AddLabel(1, " ", Color.Blue);
#show Average Daily Range amount at 10%
AddLabel(1, "ADR 10%= " + ADR/10, Color.yellow);


#show info when trade is triggered Long or Short
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AddLabel(1, if ADR_LONG then "In "+close + " SL= " + LongStopLoss + "/ T= "+ LongProfit else if ADR_SHORT then "In "+ADR_SHORT + " SL= " + ShortStopLoss + "/ T= "+ ShortProfit else "No SS Trade", if ADR_LONG then Color.green else if ADR_SHORT then Color.light_red else Color.gray );




AddLabel(1, " ", Color.Blue);
 

Attachments

  • SimpleStrategy2025 code by AButterfly.txt
    4.5 KB · Views: 22
  • I'm watching this!
Reactions: sum

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
368 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top