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
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
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