Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Find the highest and lowest value of the series (MC.NET)
I am trying to implement a Donchian channel indicator which needs to find the highest and lowest value of the past <period> bar. Say period is 20 then I need to find the highest high and lowest lowe value of the previous 20 bars every time I call the CalcBar() method.
Is there any simple way to do this? Instead of looping previous n bar every time?
Can you help answer these questions from other members on NexusFi?
#region Variables
....
// User defined variables (add any user defined variables below)
......
private double curlow,curhigh,lasthigh,lastlow,targethigh,targetlow, savelow =0,savehigh=0;
......
.............
protected override void OnBarUpdate()
{
if (CurrentBar <Period) ///// Do not calculate if we don't have enough bars
return;
......
Thanks for the suggestion. However I am using MC.NET instead of NT7. I am actually trying to move the Donchian indicator from NT7 to MC.NET ... However I can't find the functions like MAX in MC.NET so I am wondering do I have to build one on my own.....
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
You could you the standard .NET Math.Max(a, b) which is simple and great for code maintenance down the road. Performance wise, it's nearly identical to inlining, stackoverflow thread on that. DotNetPearls has a quick 30 second read on it that's pretty good too.