R2D2B2C2

Code for Cup With Handle calculations (using Pine)

Cup with Handle formation calculations using Pine.

First of all, ignore all other lines in the example chart except the two FAT lines. The two fat lines are the ones that define the Cup With handle or in the example chart: a Reversed Cup With Handle.

Note: Handle does not always develop and sometimes the final target price is reached without forming any handle.
This script can calculate both Cup With Handle ( CH ) and Reversed Cup With Handle ( RCH ). Just order the input values accordingly.

For more information about Cup With Handle, use google:
www.google.se/search?q=cup+with...

The script need two input parameters: The highest price in the Cup formation and the lowest price in the cup formation or vice versa for the Reversed Cup formation.

Best regards,
/Hull, 2015.05.20.16:31
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
study(title="Cup With Handle", shorttitle="CH/RCH", overlay=true)

// Inputs should be: The edges of the potential cup, and the bottom of that potential cup formation.
// Usually the highest and lowest values of price inside a cup with handle formation.
// This code can do both Cup with handle(CH) and Reversed Cup with handle (RCH). Just use the correct order of the inputs.
// For more info about Cup With Handle, use google:
// https://www.google.se/search?q=cup+with+handle+chart+pattern&biw=1858&bih=938&source=lnms&tbm=isch&sa=X&ei=r5VcVZS3JMKhsgHig4DYAg&ved=0CAYQ_AUoAQ
// Note: There is not always a defined handle. Sometimes the final target is reached immediately without any noticable "handle".
Cup_edge = input(title="Cup edge", type=float, defval=0.0, minval=0.0)
Cup_bottom = input(title="Cup bottom", type=float, defval=0.0, minval=0.0)

// simple function for fibonacci calculations, if ever needed. Can be ignored for CH/RCH.
fib1618(x) => x*1.618
fib0618(x) => x*0.618
fib0382(x) => x*0.382

// These below calculations are not used in this CH/RCH example, but I leave them in here in case for experimentations.

A = Cup_bottom
B = fib0618(Cup_edge - Cup_bottom) + A 
C = B - fib1618(Cup_edge - Cup_bottom) 
D = C - fib0382(C - B)
E = D - Cup_edge + Cup_bottom

// Experimental plotting of CH/RCH fibowaves.
//plot(B,title='B wave end', color=green,linewidth=2,offset=15) 
//plot(C,title='C wave end', color=blue,linewidth=2,offset=30) 
//plot(D,title='D wave end', color=purple,linewidth=2,offset=45) 
//plot(E,title='E wave end', color=red,linewidth=2,offset=60)

// This is what the example is going to plot. Simple Cup with Handle. Handle target and Final target.
Depth = Cup_edge - Cup_bottom
Handle = Cup_edge - (Depth*0.5)
Target = Cup_edge + (Depth*0.79)

// As the code below explains: blue is the final target price, red is the potential "handle" price.
plot(Handle, title='Handle', color=red, linewidth=2, offset=0 )
plot(Target, title='Target', color=blue, linewidth=2, offset=0 )
// Best regards, Hull