Populate an Array with Pivot Points - MultiCharts | futures io social day trading
futures io futures trading


Populate an Array with Pivot Points
Updated: Views / Replies:1,282 / 3
Created: by JHall65 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
 

Populate an Array with Pivot Points

  #1 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received

Populate an Array with Pivot Points

I am designing a range trading system that uses pivot points. My first task is to populate an array with all the pivots as they happen. I have a good chunk of code, but it seems to run endlessly. I am not sure how to debug this type of problem. Any help would be greatly appreciated and of course I'll share the end results with the forum.


 
Code
Inputs:	NumberPivots(10), DiffVal(0), 
		LeftStrength(3),RightStrength(3); 

Vars:		counter(0),
		oPivotPriceL(0),oPivotBarL(0),oPivotPriceH(0),oPivotBarH(0),Length(0);

Array: 	Pivots[30,3] (0); //Creats a 2d array and intializes values to 0;

If BarNumber = 1 then 
ClearPrintLog;

//This sets the length to ensure that the same pivot is not observed twice.
Length = RightStrength +1;

//This evaluates each bar to check for a pivot.
value2 = Pivot(L,Length,LeftStrength,RightStrength,1,-1,oPivotPriceL,oPivotBarL);
value4 = Pivot(H,Length,LeftStrength,RightStrength,1,1,oPivotPriceH,oPivotBarH);

	
			For counter = 0 to (NumberPivots - 1) begin
				Pivots[counter,0]=Pivots[counter+1,0]; 
				Pivots[counter,1]=Pivots[counter+1,1];
				Pivots[counter,2]=Pivots[counter+1,2];
				Pivots[counter,3]=Pivots[counter+1,3];
			End;
	
	
			//Add any new pivot low lines
			If (value2 = 1 AND oPivotBarL = RightStrength) then 
				Begin
					Pivots[NumberPivots,0] = BarNumber-RightStrength; // The Bar Number
					Pivots[NumberPivots,1] = RightStrength; //The Number of Bars Ago
					Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
					Pivots[NumberPivots,3] = oPivotPriceL; // The lower pivot price.
				End;
	
	
	
			//Add any new pivot high lines
			If (value4 = 1 AND oPivotBarH = RightStrength) then 
				Begin
					Pivots[NumberPivots,0] = BarNumber-RightStrength; // The Bar Number
					Pivots[NumberPivots,1] = RightStrength;
					Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
					Pivots[NumberPivots,3] = oPivotPriceH; // The lower pivot price.
				End;
				
If LastBarOnChart then begin
	Print("Pivots[:,0]: ", Pivots[NumberPivots,0]);
	Print("Pivots[:,1]: ", Pivots[NumberPivots,1]); 
	Print("Pivots[:,2]: ", Pivots[NumberPivots,2]);
	Print("Pivots[:,3]: ", Pivots[NumberPivots,3]:4:4);	
End;


Last edited by JHall65; August 26th, 2013 at 03:51 PM.
Reply With Quote
 
  #2 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,527 since Apr 2013
Thanks: 229 given, 854 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer

Hi JHall65,

what do you mean with runs endlessly? It seems to calculate quickly here.

What are you trying to do with this piece of code? I think your intention is to move the previously stored pivot in the array one step down to make room for a new pivot. However you are executing this code on every bar, this will probably cause unwanted results as you will likely have multiple indices with the same value.

 
Code
For counter = 0 to (NumberPivots - 1) begin
Pivots[counter,0]=Pivots[counter+1,0]; 
Pivots[counter,1]=Pivots[counter+1,1];
Pivots[counter,2]=Pivots[counter+1,2];
Pivots[counter,3]=Pivots[counter+1,3];
End;
Regards,
ABCTG


JHall65 View Post
I am designing a range trading system that uses pivot points. My first task is to populate an array with all the pivots as they happen. I have a good chunk of code, but it seems to run endlessly. I am not sure how to debug this type of problem. Any help would be greatly appreciated and of course I'll share the end results with the forum.


 
Code
Inputs:	NumberPivots(10), DiffVal(0), 
		LeftStrength(3),RightStrength(3); 

Vars:		counter(0),
		oPivotPriceL(0),oPivotBarL(0),oPivotPriceH(0),oPivotBarH(0),Length(0);

Array: 	Pivots[30,3] (0); //Creats a 2d array and intializes values to 0;

If BarNumber = 1 then 
ClearPrintLog;

//This sets the length to ensure that the same pivot is not observed twice.
Length = RightStrength +1;

//This evaluates each bar to check for a pivot.
value2 = Pivot(L,Length,LeftStrength,RightStrength,1,-1,oPivotPriceL,oPivotBarL);
value4 = Pivot(H,Length,LeftStrength,RightStrength,1,1,oPivotPriceH,oPivotBarH);

	
			For counter = 0 to (NumberPivots - 1) begin
				Pivots[counter,0]=Pivots[counter+1,0]; 
				Pivots[counter,1]=Pivots[counter+1,1];
				Pivots[counter,2]=Pivots[counter+1,2];
				Pivots[counter,3]=Pivots[counter+1,3];
			End;
	
	
			//Add any new pivot low lines
			If (value2 = 1 AND oPivotBarL = RightStrength) then 
				Begin
					Pivots[NumberPivots,0] = BarNumber-RightStrength; // The Bar Number
					Pivots[NumberPivots,1] = RightStrength; //The Number of Bars Ago
					Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
					Pivots[NumberPivots,3] = oPivotPriceL; // The lower pivot price.
				End;
	
	
	
			//Add any new pivot high lines
			If (value4 = 1 AND oPivotBarH = RightStrength) then 
				Begin
					Pivots[NumberPivots,0] = BarNumber-RightStrength; // The Bar Number
					Pivots[NumberPivots,1] = RightStrength;
					Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
					Pivots[NumberPivots,3] = oPivotPriceH; // The lower pivot price.
				End;
				
If LastBarOnChart then begin
	Print("Pivots[:,0]: ", Pivots[NumberPivots,0]);
	Print("Pivots[:,1]: ", Pivots[NumberPivots,1]); 
	Print("Pivots[:,2]: ", Pivots[NumberPivots,2]);
	Print("Pivots[:,3]: ", Pivots[NumberPivots,3]:4:4);	
End;


Reply With Quote
 
  #3 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received

Fixed Code - New Problems


Thanks ABCTG. I figured out that the code keep "calculating" if you do not have a minimum number of bars on your chart. I'm not sure why that is...

You're correct about cascading the values for every bar. I fixed that per your recommendation. Now I am finding that I have incorrect BarNumber(s) turning up. I am not sure why this is happening, so I tried counting the bars manually in the code; same result. Any ideas? I need to be able to store the BarNumber value in the array for comparison purposes.

 
Code
Inputs:	NumberPivots(100), DiffVal(0), 
		LeftStrength(3),RightStrength(3); 

Vars:		counter(0),
		oPivotPriceL(0),oPivotBarL(0),oPivotPriceH(0),oPivotBarH(0),Length(0),
		BarCount(0);

Arrays: 	Pivots[101,4](0); //Creats a 2d array and intializes values to 0;

BarCount = BarCount+1; 

If BarNumber = 1 then 
ClearPrintLog;

//This evaluates each bar to check for a pivot.
value2 = Pivot(L,RightStrength+1,LeftStrength,RightStrength,1,-1,oPivotPriceL,oPivotBarL);
value4 = Pivot(H,RightStrength+1,LeftStrength,RightStrength,1,1,oPivotPriceH,oPivotBarH);
	
	
//Add any new pivot low
If (value2 = 1 AND oPivotBarL = RightStrength) then Begin

	//Cascade all the values
	For counter = 0 to (NumberPivots-1) begin
		Pivots[counter,0]=Pivots[counter+1,0];  
		Pivots[counter,1]=Pivots[counter+1,1]; 
		Pivots[counter,2]=Pivots[counter+1,2];
		Pivots[counter,3]=Pivots[counter+1,3];
		Pivots[counter,4]=Pivots[counter+1,4];
	End;
	
	
	Pivots[NumberPivots,0] = BarNumber; // The Bar Number
	Pivots[NumberPivots,1] = BarNumber - RightStrength; //The Number of Bars Ago
	Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
	Pivots[NumberPivots,3] = oPivotPriceL; // The lower pivot price.
	Pivots[NumberPivots,4] = -1; //Identifies this as a low pivot.
End;
	
	 
	
//Add any new pivot high
If (value4 = 1 AND oPivotBarH = RightStrength) then Begin

	//Cascade all the values
	For counter = 0 to (NumberPivots-1) begin
		Pivots[counter,0]=Pivots[counter+1,0]; 
		Pivots[counter,1]=Pivots[counter+1,1]; 
		Pivots[counter,2]=Pivots[counter+1,2];
		Pivots[counter,3]=Pivots[counter+1,3];
		Pivots[counter,4]=Pivots[counter+1,4];
	End;

	Pivots[NumberPivots,0] = BarNumber; // The Bar Number
	Pivots[NumberPivots,1] = BarNumber - RightStrength;
	Pivots[NumberPivots,2] = absvalue(H[RightStrength]-L[RightStrength]); // The Bar Body Size
	Pivots[NumberPivots,3] = oPivotPriceH; // The lower pivot price.
	Pivots[NumberPivots,4] = 1; //Identifies this as a low pivot.
End;
		
				
If LastBarOnChart then begin
	For counter=0 to NumberPivots begin

		Print(
		"   Pivots[:,0]: ", Pivots[Counter,0],
		"   Pivots[:,1]: ", Pivots[Counter,1],
		"   Pivots[:,2]: ", Pivots[Counter,2]:4:4,
		"   Pivots[:,3]: ", Pivots[Counter,3]:4:4,
		"   Pivots[:,4]: ", Pivots[Counter,4]);
		
	End;	
End;
Print(BarCount,BarNumber);

Reply With Quote
 
  #4 (permalink)
Trading for Profit
Houston, TX
 
Futures Experience: Intermediate
Platform: TradeStation
Broker/Data: TradeStation
Favorite Futures: CL
 
LogicalTrader's Avatar
 
Posts: 294 since Aug 2013
Thanks: 1,420 given, 752 received

Try storing the value in oPivotBarL and oPivotBarH variables in the array instead of the BarNumber. The Pivot function copies the swing high/low bar number to this ref variable when it is called.

Reply With Quote

Reply



futures io > > > > Populate an Array with Pivot Points

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot points FKtrader Platforms and Indicators 5 May 17th, 2013 07:42 PM
Edit pivot points indicator jsengxx2 NinjaTrader Programming 2 April 22nd, 2013 01:39 PM
Looking for daily pivot points for CL, ZN, ZF Chipmunk Traders Hideout 11 November 29th, 2010 02:48 AM
Swing/Pivot Points trs3042 Traders Hideout 3 November 28th, 2010 10:58 PM
How to calculate Pivot points correctly: settlement or close ? trendisyourfriend The Elite Circle 6 June 10th, 2010 11:44 AM


All times are GMT -4. The time now is 07:19 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-13 in 0.09 seconds with 27 queries on phoenix via your IP 54.196.182.102