Find the highest and lowest value of the series (MC.NET) - MultiCharts | futures io social day trading
futures io futures trading


Find the highest and lowest value of the series (MC.NET)
Updated: Views / Replies:1,518 / 4
Created: by Jeffrey Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Find the highest and lowest value of the series (MC.NET)

  #1 (permalink)
Elite Member
Hong Kong
 
Futures Experience: Beginner
Platform: MultiCharts, NinjaTrader
Favorite Futures: HSIF, ES
 
Posts: 10 since Jul 2010
Thanks: 2 given, 1 received

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?


Last edited by Jeffrey; April 22nd, 2015 at 01:05 PM.
Reply With Quote
 
  #2 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


Jeffrey View Post
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?

sure, cut & paste these codes;

#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;
......

curlowpos=LowestBar(Low,Period);
curlow=Low[curlowpos];

curhighpos=HighestBar(High, Period);
curhigh=High[curhighpos];
-------

Reply With Quote
 
  #3 (permalink)
Elite Member
Hong Kong
 
Futures Experience: Beginner
Platform: MultiCharts, NinjaTrader
Favorite Futures: HSIF, ES
 
Posts: 10 since Jul 2010
Thanks: 2 given, 1 received



cory View Post
sure, cut & paste these codes;

#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;
......

curlowpos=LowestBar(Low,Period);
curlow=Low[curlowpos];

curhighpos=HighestBar(High, Period);
curhigh=High[curhighpos];
-------

Hi Cory,

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.....

Reply With Quote
 
  #4 (permalink)
Elite Member
Jacksonville, Florida United States
 
Futures Experience: Intermediate
Platform: NT8, Fully custom
Broker/Data: NT Brokerage, Interactive Brokers
Favorite Futures: ES
 
Jasonnator's Avatar
 
Posts: 69 since Dec 2014
Thanks: 19 given, 44 received


Jeffrey View Post
Hi Cory,

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.....

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.

Reply With Quote
 
  #5 (permalink)
Elite Member
Hong Kong
 
Futures Experience: Beginner
Platform: MultiCharts, NinjaTrader
Favorite Futures: HSIF, ES
 
Posts: 10 since Jul 2010
Thanks: 2 given, 1 received

I have found the answer, there are some PublicFunctions available in MC.NET:

 
Code
		public Jeffrey_DonchianChannel(object _ctx):base(_ctx){
		
			// default 14 days
			Period = 14;			
		}		
		
		protected override void Create() {
			// create variable objects, function objects, plot objects etc.
			
			
			//plot1 = AddPlot(new PlotAttributes("ATR", EPlotShapes.Line, Color.Cyan, Color.Empty, 0, 0, true));
			
			upperBoundPlot = AddPlot(new PlotAttributes("UpperBound", EPlotShapes.Line, Color.Yellow, Color.Empty, 0, 0, true));
			lowerBoundPlot = AddPlot(new PlotAttributes("LowerBound", EPlotShapes.Line, Color.Yellow, Color.Empty, 0, 0, true));
			meanPlot = AddPlot(new PlotAttributes("Mean", EPlotShapes.Line, Color.Yellow, Color.Empty, 0, 0, true));
			
			upperBoundSeries = new VariableSeries<Double>(this);
			lowerBoundSeries = new VariableSeries<Double>(this);
			meanSeries = new VariableSeries<Double>(this);
		}
		
		protected override void StartCalc() {
			// assign inputs 
			
			//ExecInfo.MaxBarsBack = Period+1;
				
			#if DEBUG							
				Output.WriteLine("{0} - BarNumber: {1} - MaxBarsBack: {2}",
	            Bars.Time[0].ToString("yyyy/MM/dd HH:mm:ss"),
	            Bars.CurrentBarAbsolute() + 1,
	            ExecInfo.MaxBarsBack);
			#endif							
		}			
			
		
		protected override void CalcBar() {
		
			
			double upper = PublicFunctions.Highest(Bars.High, Period);
			double lower = PublicFunctions.Lowest(Bars.Low, Period);
			
			#if DEBUG			
				Output.WriteLine("Current bar is {0}", Bars.CurrentBar);
				Output.WriteLine("Date/Time: {0}, Upper: {1}, Lower: {2}", Bars.Time[0].ToString("yyyy/MM/dd HH:mm:ss"), upper, lower);
				Output.WriteLine("");
			#endif	
			
			// 0 means no displacement of the current bar
			upperBoundPlot.Set(0, upper);	
			lowerBoundPlot.Set(0, lower);	
			//meanPlot.Set(0, meanSeries.Value);	

		}
	}

Reply With Quote

Reply



futures io > > > > Find the highest and lowest value of the series (MC.NET)

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Efficient Code for finding highest high and lowest lows of a range of bars. xigreek NinjaTrader Programming 18 July 31st, 2015 03:54 PM
Highest High or Lowest Low past 3 days olobay EasyLanguage Programming 2 July 27th, 2014 03:06 PM
lowest and highest ankityadav MetaTrader 3 August 8th, 2013 11:04 AM
Total, Highest, Lowest Delta arnie MultiCharts 0 February 15th, 2013 07:24 PM
Highest or lowest swings luitom NinjaTrader Programming 4 January 27th, 2012 06:07 PM


All times are GMT -4. The time now is 11:02 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.09 seconds with 19 queries on phoenix via your IP 54.226.113.250