Single Green Candle SMA20 and Kijun


Category:
0
0

Hi Pete, I’m trying to find a code to capture a single green candle that opens below both SMA20 and Kijun AND closes above both of those lines in the same day.

Thanks

RESOLVED
Marked as spam
Posted by (Questions: 7, Answers: 16)
Asked on November 13, 2018 11:53 am
55 views
0
Private answer

Since you posted this in the Chart Studies topic I will provide the solution in the form of a chart study. Here is the code, as well as a screenshot showing what it looks like.

input tenkan_period = 9;
input kijun_period = 26;
input smaLength = 20;
def Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot sma = Average(close, smaLength);
def conditionKijun = close[1] < Kijun[1] and open < Kijun and close > Kijun;
def conditionSMA = close[1] < sma[1] and open < sma and close > sma;
plot signal = conditionKijun and conditionSMA;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal.SetDefaultColor(Color.CYAN);
signal.SetLineWeight(3);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on November 13, 2018 12:43 pm
0

I entered the codes and it’s giving me this message at the bottom: Exactly one plot expected.

( at November 13, 2018 12:47 pm)
0

As I mentioned, this question was posted in the Chart Studies topic. So a chart study is what I have provided. If you are getting a message that only plot is expected that can only be because you are trying to apply it as a scan.

( at November 13, 2018 1:17 pm)
0

Ohh, so I need to post it in the Stock Scanners topic. Let me do that. Sorry about that.

( at November 13, 2018 1:45 pm)
0

You don’t need to post this again. No sense duplicating it. I can show you the scan version here.

input tenkan_period = 9;
input kijun_period = 26;
input smaLength = 20;
def Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
def Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
def sma = Average(close, smaLength);
def conditionKijun = close[1] < Kijun[1] and open < Kijun and close > Kijun;
def conditionSMA = close[1] < sma[1] and open < sma and close > sma;
plot signal = conditionKijun and conditionSMA;

That is a version that will work as a scan. Seems you could benefit from watching our videos that cover the scan topic. https://www.hahn-tech.com/category/tos/scans-tos/

This is pretty simple to convert and just watching a half dozen videos would surely show you how this is done.

( at November 13, 2018 1:57 pm)
0

Thanks Pete. Will definitely watch the videos in the link you provided ?

( at November 13, 2018 2:15 pm)
0

Hi Pete, I have been wondering can one same code for a Candle cross 2 different SMA’s to create a signal arrow? Instead of Candle Crossing SMA and Kijun.

( at December 14, 2018 9:06 pm)
0

Yes it can be done. But you will need to post this as a new request so we don’t muddy up the context of this post.

( at December 15, 2018 10:31 am)
0

Sure thing. Thanks.

( at December 15, 2018 4:30 pm)