Plot 15 minute Candlestick Signal on 30 minute chart

J

JJSPX

New member
I have this simple Candlestick indicator... Basically just plots an arrow once the conditions are met. I can't seem to have any success in getting the code right in order to plot these simple arrow signals from a 15min chart, but on a 30min chart. I've tried a few different aggregation.period ways and can't get it to stick. Ultimately, I just want to see these arrows on a 30min chart, but off of 15min data.

Any thoughts?

Thanks so much.

Jon

------------------------------------------------------------------------------
Code:
def total = high - low;
def upper_candle = high - Max(open, close);
def lower_candle = Min(open, close) - low;
def trend_mult = if close >= open then 1 else -1;

def Upper_Sentiment = if total != 0 then 100 - ((upper_candle / total) * 100) else 0;
def Lower_Sentiment = if total != 0 then -100 + (( lower_candle / total) * 100) else 0;

plot UpperWickReversal = if Upper_Sentiment <= 33 and Upper_Sentiment != 0 then Upper_Sentiment else Double.NaN;
UpperWickReversal.SetPaintingStrategy(PaintingStrategy.aRROW_DOWN);
UpperWickReversal.SetLineWeight(4);
UpperWickReversal.AssignValueColor(Color.RED);

plot LowerWickReversal = if Lower_Sentiment >= -33 and Lower_Sentiment != 0 then Lower_Sentiment else Double.NaN;
LowerWickReversal.SetPaintingStrategy(PaintingStrategy.arrow_up);
LowerWickReversal.SetLineWeight(4);
LowerWickReversal.AssignValueColor(Color.Green);
 
Last edited by a moderator:
P

Parker427

New member
If you could get this right, this would save us the hassle of flipping back and forth between charts. Could you make something similar like if im looking at the 1m chart, I get a notification that price has broken above the 20ma on the 5m,15m,30m, etc charts without constantly creating alerts and switching between charts.
 
BenTen

BenTen

Administrative
Staff
VIP
That's because you didn't call for data from the higher timeframe. Here is the updated script. The default timeframe is set to Daily. You can change it via the indicator's settings. I have also updated the plot as well, so the arrows are being displayed correctly.

Code:
# Input name of script
# Modified by BenTen at useThinkScript.com to include MTF option

input Period = aggregationPeriod.DAY;
def close = close(period = Period);
def high = high(period = Period);
def open = open(period = Period);
def low = low(period = Period);

def total = high - low;
def upper_candle = high - Max(open, close);
def lower_candle = Min(open, close) - low;
def trend_mult = if close >= open then 1 else -1;

def Upper_Sentiment = if total != 0 then 100 - ((upper_candle / total) * 100) else 0;
def Lower_Sentiment = if total != 0 then -100 + (( lower_candle / total) * 100) else 0;

plot UpperWickReversal = if Upper_Sentiment <= 33 and Upper_Sentiment != 0 then Upper_Sentiment else Double.NaN;
UpperWickReversal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
UpperWickReversal.SetLineWeight(4);
UpperWickReversal.AssignValueColor(Color.RED);

plot LowerWickReversal = if Lower_Sentiment >= -33 and Lower_Sentiment != 0 then Lower_Sentiment else Double.NaN;
LowerWickReversal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LowerWickReversal.SetLineWeight(4);
LowerWickReversal.AssignValueColor(Color.Green);
 
horserider

horserider

Well-known member
VIP
@JJSPX Cannot be done. Agg has to be higher than the chart time frame as BenTen hinted at in the previous post.
 
BenTen

BenTen

Administrative
Staff
VIP
@horserider Thanks for pointing that out. I was reading the reverse of his request (plotting something from higher agg on lower agg). @JJSPX The code I provided will do that. It will not be able to plot something from 15m on a 30m (or higher timeframe), should be the other way around.
 
J

JJSPX

New member
Thank you both! This is the exact issue... I did think it was possible, but it is not. BenTen - Thanks for providing the code, still helpful!
 
J

JJSPX

New member
@BenTen - Do you have a guide or short explanation as to why items such as "input" or "def" matter when calling the higher time frame? In the example above, it seemed very simple to include the input period calling to the higher time frame. I have a different set of code below, and can't get it to call to a higher time frame. This essentially just plots the Kijun/Tenkan cloud and then assigns a color to the Kijun line based on trend. This is used on a 30 minute chart, but I am also trying to plot the Daily information on the 30M chart.

Code:
input price = close;
input tenkan_period = 9;
input kijun_period = 26;
input displace = 0;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
Kijun.DefineColor("Up", Color.GREEN);
Kijun.DefineColor("Down", Color.RED);
Kijun.DefineColor("Even", Color.WHITE);
Kijun.AssignValueColor(if Kijun > Tenkan then Kijun.Color("Down") else (if Kijun == Tenkan then Kijun.Color("Even") else Kijun.Color("Up")));
Kijun.SetLineWeight(3);
 
BenTen

BenTen

Administrative
Staff
VIP
@JJSPX Without calling for higher timeframe data, ThinkorSwim will use the current timeframe that you’re on as the default value. Looking at the script you just posted above, you are not calling for the 30m timeframe. That’s why it doesn’t work.
 
J

JJSPX

New member
@BenTen - The code I had posted was the original code (sorry)... Here's what I am having an issue with... This below is still plotting 30M information....

Code:
input period = aggregationperiod.day;
def price = close(period = period);

input tenkan_period = 9;
input kijun_period = 26;
input displace = 0;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
Kijun.DefineColor("Up", Color.GREEN);
Kijun.DefineColor("Down", Color.RED);
Kijun.DefineColor("Even", Color.WHITE);
Kijun.AssignValueColor(if Kijun > Tenkan then Kijun.Color("Down") else (if Kijun == Tenkan then Kijun.Color("Even") else Kijun.Color("Up")));
Kijun.SetLineWeight(3);
 
BenTen

BenTen

Administrative
Staff
VIP
@JJSPX Take a look at the code I posted from Feb. Make note of the following snippet and apply that to your script:

Code:
input Period = aggregationPeriod.DAY;
def close = close(period = Period);
def high = high(period = Period);
def open = open(period = Period);
def low = low(period = Period);
 

Similar threads

Top