Larry Williams COT proxy

Chazbono68

New member
Hi all,

I did some digging and found some code online regarding Larry Williams indicators. I am most interested in the COT proxy. But I am not sure how to convert this code to thinkscript.

Larry Commerical Proxy Index
Larry Williams said he even dont need COT report to buil COT index. Here his formula:

MovingAvg(Open-Close, bars used in average)/MovingAvg(Range,bars used in average)*50 +50
 
Hi all,

I did some digging and found some code online regarding Larry Williams indicators. I am most interested in the COT proxy. But I am not sure how to convert this code to thinkscript.

Larry Commerical Proxy Index
Larry Williams said he even dont need COT report to buil COT index. Here his formula:

MovingAvg(Open-Close, bars used in average)/MovingAvg(Range,bars used in average)*50 +50
Here is my code with auto level for the limits of the COT Index since it varies on every stock. Hope you like it. ;-)
Ruby:
#########################################################
#Created by dag. 05.15.2022
#Version 1.0
#This Script mimics the COT Large Traders Net position

declare lower;
declare hide_on_intraday;


DefineGlobalColor("HeavyBought", color.Green);
DefineGlobalColor("Normal", Color.Gray);
DefineGlobalColor("HeavySelling", Color.Red);



input ManualWeeklyBarsAgo = 8;
input Commodity = {default Stocks, Currencies, Metal, Meats, Softs_Sugar_coffee, Cotton, Grains, DollarIndex, Bonds, Energies, Manual};

def barsAgo; #Williams is using the 13 weeks or 65 Daily for /SI (Silver or /Gold and 90 daysFromDate for Currencies;
def CurrentPeriod = GetAggregationPeriod();

switch (Commodity) {
case Stocks:
barsAgo = 13;
case Currencies:
barsAgo = 26;
case Metal:
barsAgo = 26;
case Meats:
barsAgo = 13;
case Softs_Sugar_coffee:
barsAgo = 13;
case Cotton:
barsAgo = 26;
case Grains:
barsAgo = 26;
case DollarIndex:
barsAgo = 13;
case Bonds:
barsAgo = 52;
case Energies:
barsAgo = 13;
case Manual:
barsAgo = ManualWeeklyBarsAgo;

}

def AggregationPeriod = if getaggregationPeriod() == AggregationPeriod.Month then AggregationPeriod.Month else if getaggregationPeriod() == AggregationPeriod.Week then AggregationPeriod.Week else AggregationPeriod.Week ;


def c = close(period = AggregationPeriod);
def o = open(period = AggregationPeriod);
def h = high(period = AggregationPeriod);
def l = low(period = AggregationPeriod);



#def rangeIBD = if l > h[1] then (c - c[1]) / (h - c[1]) else if h < l[1] then (c - l) / (c[1] - l) else (c - l) / (h - l);
def WilliamsRange = trueRange(h,c,l);


plot COTIndex = Average(o - c, barsAgo) / Average(WilliamsRange, barsAgo) * 50 + 50; # instead you may use *100
COTIndex.SetDefaultColor(Color.RED);


#################### Levels ###########

input IndexColoring = {default AutoLevels, ManualLevels};

Input HeavyBaughtLevelManual= 60;
Input HeavySoldLevelManual = 30;

def BarAgoForLimits = barsAgo;
input levelsMultiplier = 5;
input ShowLevels = yes;




plot UnderV = HeavyBaughtLevelManual;
UnderV.assignValueColor(Color.Green);
UnderV.setHiding(!ShowLevels);

plot OverVal = HeavySoldLevelManual;
OverVal.assignValueColor(Color.Red);
OverVal.setHiding(!ShowLevels);



###### Auto Levels


def HighestHigh = Highest(COTIndex, BarAgoForLimits);
def LowestLow = Lowest(COTIndex, BarAgoForLimits);

def HeavyBuyers = Average(HighestHigh, BarAgoForLimits*levelsMultiplier);
#HeavyBuyers.SetDefaultColor(Color.GREEN);
#HeavyBuyers.sethiding(!ShowLevels);

def HeavySellers = Average(LowestLow, BarAgoForLimits*levelsMultiplier);
#HeavySellers.SetDefaultColor(Color.RED);
#HeavySellers.sethiding(!ShowLevels);




COTIndex.AssignValueColor (if COTIndex >= HeavyBuyers then Color.GREEN else if COTIndex <= HeavySellers then Color.RED else Color.WHITE);

COTIndex.AssignValueColor (if IndexColoring == IndexColoring.AutoLevels then (if COTIndex >= HeavyBuyers then GlobalColor("HeavyBought") else if COTIndex <= HeavySellers then GlobalColor("HeavySelling") else GlobalColor("Normal")) else (if COTIndex >= HeavyBaughtLevelManual then GlobalColor("HeavyBought") else if COTIndex <= HeavySoldLevelManual then GlobalColor("HeavySelling") else GlobalColor("Normal")));

#########################################################
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Awesome. Very much wanted and needed. Thank you!

Any chance that code could be modified for intraday periods?
Here is my code modified for use intraday. However please note that as per L. Williams the COT Proxy Index was designed for Weekly use only and tested by him. Intraday may give you allots of false signals.

Happy Trading ;-)

#########################################################
#Created by dag. 07.06.2022
#Version 1.1 #Added Code for Intraday usage. Suggest using AggregationPeriod.Week as per Williams.
#This Script mimics the COT Large Traders Net position

declare lower;
#declare hide_on_intraday;


DefineGlobalColor("HeavyBought", color.Green);
DefineGlobalColor("Normal", Color.Gray);
DefineGlobalColor("HeavySelling", Color.Red);



input ManualWeeklyBarsAgo = 8;
input Commodity = {default Stocks, Currencies, Metal, Meats, Softs_Sugar_coffee, Cotton, Grains, DollarIndex, Bonds, Energies, Manual};

def barsAgo; #Williams is using the 13 weeks or 65 Daily for /SI (Silver or /Gold and 90 daysFromDate for Currencies;
def CurrentPeriod = GetAggregationPeriod();

switch (Commodity) {
case Stocks:
barsAgo = 13;
case Currencies:
barsAgo = 26;
case Metal:
barsAgo = 26;
case Meats:
barsAgo = 13;
case Softs_Sugar_coffee:
barsAgo = 13;
case Cotton:
barsAgo = 26;
case Grains:
barsAgo = 26;
case DollarIndex:
barsAgo = 13;
case Bonds:
barsAgo = 52;
case Energies:
barsAgo = 13;
case Manual:
barsAgo = ManualWeeklyBarsAgo;

}

input ForIntradayUsePeriod = {default No_DefaultAsPerWilliams, Yes_Auto, Yes_Manual};
input PeriodManual = aggregationPeriod.DAY;

def AggregationPeriod = if ForIntradayUsePeriod == ForIntradayUsePeriod.Yes_Auto then getaggregationPeriod() else if ForIntradayUsePeriod == ForIntradayUsePeriod.Yes_Manual then PeriodManual else if ForIntradayUsePeriod == ForIntradayUsePeriod.No_DefaultAsPerWilliams then (if getaggregationPeriod() == AggregationPeriod.Month then AggregationPeriod.Month else if getaggregationPeriod() == AggregationPeriod.Week then AggregationPeriod.Week else AggregationPeriod.Week) else double.nan ;


def c = close(period = AggregationPeriod);
def o = open(period = AggregationPeriod);
def h = high(period = AggregationPeriod);
def l = low(period = AggregationPeriod);



def WilliamsRange = trueRange(h,c,l);


plot COTIndex = Average(o - c, barsAgo) / Average(WilliamsRange, barsAgo) * 50 + 50; # instead you may use *100


#################### Levels ###########

input IndexColoring = {default AutoLevels, ManualLevels};

Input HeavyBaughtLevelManual= 60;
Input HeavySoldLevelManual = 30;

def BarAgoForLimits = barsAgo;
input levelsMultiplier = 5;
input ShowLevels = yes;




plot UnderV = HeavyBaughtLevelManual;
UnderV.assignValueColor(Color.Green);
UnderV.setHiding(!ShowLevels);

plot OverVal = HeavySoldLevelManual;
OverVal.assignValueColor(Color.Red);
OverVal.setHiding(!ShowLevels);



###### Auto Levels


def HighestHigh = Highest(COTIndex, BarAgoForLimits);
def LowestLow = Lowest(COTIndex, BarAgoForLimits);

def HeavyBuyers = Average(HighestHigh, BarAgoForLimits*levelsMultiplier);
def HeavySellers = Average(LowestLow, BarAgoForLimits*levelsMultiplier);



COTIndex.AssignValueColor (if IndexColoring == IndexColoring.AutoLevels then (if COTIndex >= HeavyBuyers then GlobalColor("HeavyBought") else if COTIndex <= HeavySellers then GlobalColor("HeavySelling") else GlobalColor("Normal")) else (if COTIndex >= HeavyBaughtLevelManual then GlobalColor("HeavyBought") else if COTIndex <= HeavySoldLevelManual then GlobalColor("HeavySelling") else GlobalColor("Normal")));

#########################################################
 
Here is my code modified for use intraday. However please note that as per L. Williams the COT Proxy Index was designed for Weekly use only and tested by him. Intraday may give you allots of false signals.

Happy Trading ;-)

#########################################################
#Created by dag. 07.06.2022
#Version 1.1 #Added Code for Intraday usage. Suggest using AggregationPeriod.Week as per Williams.
#This Script mimics the COT Large Traders Net position

declare lower;
#declare hide_on_intraday;


DefineGlobalColor("HeavyBought", color.Green);
DefineGlobalColor("Normal", Color.Gray);
DefineGlobalColor("HeavySelling", Color.Red);



input ManualWeeklyBarsAgo = 8;
input Commodity = {default Stocks, Currencies, Metal, Meats, Softs_Sugar_coffee, Cotton, Grains, DollarIndex, Bonds, Energies, Manual};

def barsAgo; #Williams is using the 13 weeks or 65 Daily for /SI (Silver or /Gold and 90 daysFromDate for Currencies;
def CurrentPeriod = GetAggregationPeriod();

switch (Commodity) {
case Stocks:
barsAgo = 13;
case Currencies:
barsAgo = 26;
case Metal:
barsAgo = 26;
case Meats:
barsAgo = 13;
case Softs_Sugar_coffee:
barsAgo = 13;
case Cotton:
barsAgo = 26;
case Grains:
barsAgo = 26;
case DollarIndex:
barsAgo = 13;
case Bonds:
barsAgo = 52;
case Energies:
barsAgo = 13;
case Manual:
barsAgo = ManualWeeklyBarsAgo;

}

input ForIntradayUsePeriod = {default No_DefaultAsPerWilliams, Yes_Auto, Yes_Manual};
input PeriodManual = aggregationPeriod.DAY;

def AggregationPeriod = if ForIntradayUsePeriod == ForIntradayUsePeriod.Yes_Auto then getaggregationPeriod() else if ForIntradayUsePeriod == ForIntradayUsePeriod.Yes_Manual then PeriodManual else if ForIntradayUsePeriod == ForIntradayUsePeriod.No_DefaultAsPerWilliams then (if getaggregationPeriod() == AggregationPeriod.Month then AggregationPeriod.Month else if getaggregationPeriod() == AggregationPeriod.Week then AggregationPeriod.Week else AggregationPeriod.Week) else double.nan ;


def c = close(period = AggregationPeriod);
def o = open(period = AggregationPeriod);
def h = high(period = AggregationPeriod);
def l = low(period = AggregationPeriod);



def WilliamsRange = trueRange(h,c,l);


plot COTIndex = Average(o - c, barsAgo) / Average(WilliamsRange, barsAgo) * 50 + 50; # instead you may use *100


#################### Levels ###########

input IndexColoring = {default AutoLevels, ManualLevels};

Input HeavyBaughtLevelManual= 60;
Input HeavySoldLevelManual = 30;

def BarAgoForLimits = barsAgo;
input levelsMultiplier = 5;
input ShowLevels = yes;




plot UnderV = HeavyBaughtLevelManual;
UnderV.assignValueColor(Color.Green);
UnderV.setHiding(!ShowLevels);

plot OverVal = HeavySoldLevelManual;
OverVal.assignValueColor(Color.Red);
OverVal.setHiding(!ShowLevels);



###### Auto Levels


def HighestHigh = Highest(COTIndex, BarAgoForLimits);
def LowestLow = Lowest(COTIndex, BarAgoForLimits);

def HeavyBuyers = Average(HighestHigh, BarAgoForLimits*levelsMultiplier);
def HeavySellers = Average(LowestLow, BarAgoForLimits*levelsMultiplier);



COTIndex.AssignValueColor (if IndexColoring == IndexColoring.AutoLevels then (if COTIndex >= HeavyBuyers then GlobalColor("HeavyBought") else if COTIndex <= HeavySellers then GlobalColor("HeavySelling") else GlobalColor("Normal")) else (if COTIndex >= HeavyBaughtLevelManual then GlobalColor("HeavyBought") else if COTIndex <= HeavySoldLevelManual then GlobalColor("HeavySelling") else GlobalColor("Normal")));

#########################################################
Thanks a bunch. Is it possible to add futures to this code ?
 
I would like to look at NQ and ES futures could these be added ?
Just for your records, Larry Williams was using the 13 weeks or 65 Daily for /SI (Silver or /Gold) and 90 days for Currencies. Actual the drop-down list is a reference to how many bars ago should count from history for the calculation.

What Larry Williams found to work best was for:
Stocks: 13 weeks or 65 days
Currencies: 26 weeks or 130 days
Metal: 26 weeks or 130 days
Meats: 13 weeks or 65 days
Softs_Sugar_coffee: 13 weeks or 65 days
Cotton: 26 weeks or 130 days
Grains: 26 weeks or 130 days
DollarIndex: 13 weeks or 65 days
Bonds: 52 weeks or 260 days
Energies: 13 weeks or 65 days

So actually instead you can select from commodity properties manual selection and add your preferable "weekly bars ago" on the settings. So as you may see is fully customizable

Hope the above assists you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
483 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top