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 อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย 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