NexusFi: Find Your Edge


Home Menu

 





Create cloud to extend through following trading day based upon price data and 20 EMA


Discussion in ThinkOrSwim

Updated
    1. trending_up 767 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 3 attachments




 
Search this Thread

Create cloud to extend through following trading day based upon price data and 20 EMA

  #1 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0

Create cloud to extend through following trading day based upon price data and 20 EMA from 1515 - 1600 (3:15 PM EST - 4:00 PM EST)

I figured out how to make this cloud extend the high and the low through the following day. This works okay, but I really only want the data from 1515-1600, and it doesn't include the 20 EMA


Def high_yest = high("period" = AggregationPeriod.DAY) from 1 bars ago;
Def low_yest = low("period" = AggregationPeriod.DAY) from 1 bars ago;
AddCloud(high_yest, low_yest, Color.GREEN, Color.RED);


I found the code below and modified it to only look at the time from 1515 through 1600. It does not include the moving average as part of the high / low for the box. This box is drawing the high / low correctly (missing the 20 ema), but it does not extend through the next trading day.

input opentime = 1515;
input ORend = 1600;
input opacity = .7;
def na = Double.NaN;
#
# Check if the opening range time is now
#
def ORActive = if GetLastDay() == GetDay() and SecondsFromTime(opentime) >= 0 and SecondsFromTime(ORend) <
0 then 1 else 0;
#
# Track the OR high and low
#
def ORHigh = if ORActive then high else na;
def ORLow = if ORActive then low else na;
#
# Plot the OR high and low
#
plot ORAH = if GetLastDay() != GetDay() or !ORActive then na else HighestAll(ORHigh);
plot ORAL = if GetLastDay() != GetDay() or !ORActive then na else LowestAll(ORLow);
plot ORH = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else HighestAll(ORHigh);
plot ORL = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else LowestAll(ORLow);
#
# Formatting
#
ORAH.SetStyle(Curve.SHORT_DASH);
ORAL.SetStyle(Curve.SHORT_DASH);
ORAH.SetDefaultColor(Color.GREEN);
ORAL.SetDefaultColor(Color.RED);
ORH.SetStyle(Curve.SHORT_DASH);
ORL.SetStyle(Curve.SHORT_DASH);
ORH.SetDefaultColor(Color.GREEN);
ORL.SetDefaultColor(Color.RED);
#
# Add Cloud creates the shading
#
AddCloud(ORH, ORL);
AddCloud(ORAL, ORAH);
#
# Alerts:
#
def alerttrigger = if (high >= ORH and low <= ORH) or (high >= ORL and low <= ORL) then 1 else 0; #replace the 1 with your definition
# BLOCK CODE BELOW
input alerttext = "OR Breakout!";
input UseAlerts = {false, default true};
input AlertType = {default "BAR", "ONCE", "TICK"};
def at = AlertType;
input AlertSound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
Alert(alerttrigger and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR,
AlertSound);


Can you help me extend a cloud extension based upon the data that occurs from 1515-1600? I want to draw a cloud based upon the highest point caused by either the price or the 20 EMA high and the lowest point of either price or the 20 EMA. The cloud will extend to 1515 of the next business day or 1600 if that is easier.

I attached a couple of pictures that I manually created to show how the cloud would appear on my chart.

Thank you!

Attached Thumbnails
Click image for larger version

Name:	hahn-tech cloud 20 ema.png
Views:	72
Size:	169.5 KB
ID:	329992   Click image for larger version

Name:	hahn-tech cloud.png
Views:	62
Size:	125.1 KB
ID:	329993  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
badiboy
BIRMINGHAM
 
Posts: 7 since Oct 2020
Thanks Given: 4
Thanks Received: 2

Please see if this helps.
Would be interested, in knowing how you use this? Guess this is like closing range/opening range for next day.
There is a debug flag to see the lines used in calculations etc, disabled by default.
Looks like I don't have enough posts, so it is not letting me images or links as reference to this post.

# source futures.io link here
# 02/26/2023 Raj B, initial version of closing range clouds

declare upper;


input sampleStartTime = 1515;
input sampleEndTime = 1600;
input debug = no;

def isSampleTime = if SecondsFromTime(sampleStartTime) >= 0 and SecondsTillTime(sampleEndTime) >= 0 then yes else no;
def emaLength = 20;

def ema = MovingAverage(AverageType.EXPONENTIAL, close, emaLength);

# mark higher of high or ema
plot highPlot = if isSampleTime then Max(high, ema) else Double.NaN;
# mark lower of low or ema
plot lowPlot = if isSampleTime then Min(low, ema) else Double.NaN;


#calculate values for after 1600/sampleEndTime

def closingHigh = if isSampleTime and !isSampleTime[1]
then highPlot
else Max(highPlot, closingHigh[1]);

def closingLow = if isSampleTime and !isSampleTime[1]
then lowPlot
else Min(lowPlot, closingLow[1]);


def yDayClosingHigh = if isSampleTime[1] and !isSampleTime then closingHigh[1]
else if isSampleTime then Double.NaN
else yDayClosingHigh[1];
plot yDayClosingHighPlot = yDayClosingHigh;

def yDayClosingLow = if isSampleTime[1] and !isSampleTime then closingLow[1]
else if isSampleTime then Double.NaN
else yDayClosingLow[1];
plot yDayClosingLowPlot = yDayClosingLow;

#hidelines, disable them to debug
highPlot.setHiding(!debug);
lowPlot.setHiding(!debug);
yDayClosingHighPlot.SetHiding(!debug);
yDayClosingLowPlot.SetHiding(!debug);

AddCloud(yDayClosingLowPlot, yDayClosingHighPlot, Color.GRAY, Color.GRAY);

Attached Thumbnails
Click image for larger version

Name:	image_226.png
Views:	64
Size:	104.7 KB
ID:	330010  
Reply With Quote
Thanked by:
  #3 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0


Thank you. This was exactly what I was looking for. The concept for this is that when the price opens above the range go long. When the price opens below the range, go short. Thanks again!

Reply With Quote
  #4 (permalink)
badiboy
BIRMINGHAM
 
Posts: 7 since Oct 2020
Thanks Given: 4
Thanks Received: 2

Sounds good. Thank you for the explanation.

Reply With Quote




Last Updated on February 27, 2023


© 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