For the code, check my published script here:
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.
If we break above the RCH handle defined as the fat orange ( or red in some codes ) line we might instead build a normal larger Cup With Handle.
If the Reversed Cup With Handle is true and the pattern holds, we will move down with great force really soon towards the target price defined by the fat purple ( or blue in some codes ) line.
For more information about Cup with Handle, use google: