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)
Create cloud to extend through following trading day based upon price data and 20 EMA
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
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!
Can you help answer these questions from other members on NexusFi?
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
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);
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!