Price pullbacks to 30Week Moving Average with CCI -100


Category:
0
0

Hi Mr Hahn,

I would like to customise a study to have a signal on TOS to scan out when price pullbacks to 30Week Moving average and the CCI is below 100 and price must be above ichimoku cloud. I would like the scan to provide a signal when these 3 conditions are met. Thanks

Attachments:
Marked as spam
Posted by (Questions: 8, Answers: 15)
Asked on May 6, 2017 6:40 am
887 views
0

The pullback part may seem easy enough until you start writing code. The other elements are very simple. But what exactly constitutes a pullback? Easy enough to spot them on a chart but the computer needs a perfectly precise definition. For your example screenshot you have 23 candles closing above the 30 MA then a close below it. So how many bars above the 30MA are required before you consider a close below it as a pullback? Greater than 10? Greater than 15? Some other number? And even after we define that rule in the code, you are still not assured of capturing the exact pattern that you consider a pullback. You may find that there are additional details required to get it just the way you expect.

( at May 6, 2017 8:48 am)
0
Private answer

Thanks for your comments. Does the computer able to scan when Price that touches 30WMA (at least 5 bars above 30MA) and CCI<100?

 

Marked as spam
Posted by (Questions: 8, Answers: 15)
Answered on May 21, 2017 1:49 am
0
Private answer

Ok, that last answer provided the final piece needed to complete the code for this. I have simply copied the code from the built in versions of Ichimoku and CCI. I cleaned up the code so that it plots the standard Ichimoku along with 30 period ma. The last eight lines of code are the ones I added to do the pattern detection. See attached screenshot showing a green arrow pointing up where the signal occurs.

input tenkan_period = 9;
input kijun_period = 26;
plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];
Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));
"Span A".SetDefaultColor(GetColor(3));
"Span B".SetDefaultColor(GetColor(4));
Chikou.SetDefaultColor(GetColor(5));
DefineGlobalColor("Bullish", Color.YELLOW);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Span A", "Span B", globalColor("Bullish"), globalColor("Bearish"));
input length = 14;
def price = close + low + high;
def linDev = lindev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def ma1 = Average(close, 30);
def priceAboveCloud = close > "Span A" and close > "Span B";
def priceAboveMa1 = close > ma1;
def atLeastFiveBarsAboveMa1 = Lowest(priceAboveMa1, 5) > 0;
def firstTouchInFiveBars = atLeastFiveBarsAboveMa1[1] and close < ma1;
plot signal = if firstTouchInFiveBars and CCI < 100 then low else Double.NaN;
signal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
signal.SetDefaultColor(Color.GREEN);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 21, 2017 11:33 am
0

Hi Pete,
i copied the code and pasted on Thinkscript Editor, but it does seems to be able to proceed to save the scan. Is there something missing in my steps?

( at May 25, 2017 8:21 am)
0

This was not created to be a scan. It was created to be a chart study, as per the original request. Many changes will be required to convert this to a scan.

( at May 25, 2017 8:49 am)
0
Hi Pete is there a way i can change this pullback to 30 exponential moving average instead of simple moving average?
( at July 25, 2018 8:16 pm)
0

Change this line:
def ma1 = Average(close, 30);

To this:
def ma1 = ExpAverage(close, 30);

( at July 25, 2018 9:18 pm)
0

thank you pete

( at July 25, 2018 11:13 pm)
0
Private answer

Thanks Pete. Let me try it out on ToS.

 

Marked as spam
Posted by (Questions: 8, Answers: 15)
Answered on May 25, 2017 7:55 am