cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-62919%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Etrovare%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-62919%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECiao%2C%3C%2FP%3E%3CP%3ESto%20lavorando%20su%20una%20tabella%20di%20dati%20che%20ha%20tempo%20e%20lunghezza%20e%20i%20dati%20sulla%20lunghezza%20sono%20come%20un'onda.%20Voglio%20trovare%20il%20valore%20di%20picco%20della%20lunghezza%20di%20ciascuna%20onda%20ed%20etichettare%20il%20momento%20in%20cui%20il%20picco%20si%20verifica%20in%20una%20nuova%20colonna%20come%20%22picco%22.%3C%2FP%3E%3CP%3EQualcuno%20pu%C3%B2%20dare%20un'occhiata%20e%20aiutarmi%20con%20la%20sceneggiatura%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449918%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449918%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECiao%20Jim%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESemplicissimo%20applicare%20lo%20script%2C%20ma%20l'obiettivo%20%C3%A8%20che%20in%20ogni%20nuova%20colonna%20trovi%20una%20formula%20per%20trovare%20i%20prezzi%20azionari%20pi%C3%B9%20alti%20(picchi)%20e%20posizionare%20-1%2C%20mentre%20i%20prezzi%20azionari%20pi%C3%B9%20bassi%20posizionare%201...%20all'interno%20di%20un%20intervallo%20di%20colonne%20che%20definisco%20(colonna%20intervallo%20%3D%201-2%20o%201-10%20o%201-100%20o%201-1000%20...%20ecc)%2C%20cio%C3%A8%20in%20uno%20scenario%20ipotetico%20utilizzando%20uno%20storico%20dei%20prezzi%20delle%20azioni%20...%20quali%20momenti%20della%20giornata%20sarebbero%20stati%20ottimali%20per%20acquistare%20azioni%20a%20un%20prezzo%20inferiore%20....%20e%20.....%20vendere%20azioni%20nei%20momenti%20di%20prezzo%20pi%C3%B9%20alto%20o%20in%20aumento%20......%2C%20in%20modo%20tale%20da%20poter%20addestrare%20una%20rete%20neurale%20ad%20imparare%20ad%20acquistare%20quando%20l'azione%20il%20prezzo%20raggiunge%20il%20punto%20pi%C3%B9%20basso%20o%201%20e%20vendi%20quando%20il%20prezzo%20delle%20azioni%20raggiunge%20il%20punto%20pi%C3%B9%20alto%20o%20-1%20e%20quando%20il%20prezzo%20%C3%A8%20con%20poco%20movimento%20la%20formula%20mette%200%3C%2FP%3E%3CP%3ESaluti%2C%3C%2FP%3E%3CP%3EMarco%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449616%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449616%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEcco%20tutto%20quello%20che%20devi%20fare%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EApri%20la%20tabella%20dei%20dati%3C%2FLI%3E%0A%3CLI%3EVai%20a%20File%3D%26gt%3BNuovo%3D%26gt%3BScript%20Si%20aprir%C3%A0%20una%20finestra%20di%20script%20vuota%3C%2FLI%3E%0A%3CLI%3ETaglia%20e%20incolla%20lo%20script%20dalla%20pagina%20Web%20nella%20finestra%20Script%3C%2FLI%3E%0A%3CLI%3EEsegui%20lo%20script%20facendo%20clic%20su%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22txnelson_0-1641529000188.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22txnelson_0-1641529000188.png%22%20style%3D%22width%3A%2023px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22txnelson_0-1641529000188.png%22%20style%3D%22width%3A%2023px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F38779iD2BA12E33AB203A4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22txnelson_0-1641529000188.png%22%20alt%3D%22txnelson_0-1641529000188.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%20icona%20nella%20finestra%20dello%20script%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ECi%C3%B2%20eseguir%C3%A0%20lo%20script%20sulla%20tabella%20dati%20appena%20aperta.%3C%2FP%3E%0A%3CP%3EConsiglio%20vivamente%20di%20leggere%20il%20documento%20Discovering%20JMP%20disponibile%20nel%20menu%20a%20discesa%20Guida.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449611%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449611%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECaro%20Jim%2C%3C%2FP%3E%3CP%3ESono%20nuovo%20in%20JMP%2C%20potresti%20adattare%20lo%20script%20alla%20tabella%20allegata%3F%3CBR%20%2F%3E%20Saluti%3C%2FP%3E%3CP%3EMarco%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449387%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449387%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVedi%20se%20funziona%20come%20stai%20pensando%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Current%20Data%20Table()%3B%0A%0AcolCount%20%3D%20N%20Cols(%20dt%20)%3B%0A%2F%2F%20Loop%20across%20all%20of%20the%20columns%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20colCount%2C%20i%2B%2B%2C%0A%0A%20%2F%2F%20Create%20the%20new%20column%20and%20set%20all%20values%20to%200%0A%20dt%20%26lt%3B%26lt%3B%20New%20Column(%20%22Optimal%20signal%22%20%7C%7C%20Char(%20i%20)%2C%20set%20each%20value(%200%20)%20)%3B%0A%20%0A%20%2F%2F%20Get%20the%20name%20of%20the%20column%20to%20work%20on%0A%20theColName%20%3D%20Column(%20dt%2C%20i%20)%20%26lt%3B%26lt%3B%20get%20name%3B%0A%20%0A%20%2F%2F%20Find%20all%20of%20the%20High%20Points%0A%20Eval(%0A%20%20Parse(%0A%20%20%20%22theRows%20%3D%20dt%26lt%3B%3CGET%20rows%3D%22%22%20where%3D%22%22%3E%200%2C%0A%20%20Column(%20dt%2C%20N%20Cols(%20dt%20)%20)%5BtheRows%5D%20%3D%20-1%0A%20)%3B%0A%0A%20%2F%2F%20Find%20all%20of%20the%20Low%20Points%0A%20Eval(%0A%20%20Parse(%0A%20%20%20%22theRows%20%3D%20dt%26lt%3B%3CGET%20rows%3D%22%22%20where%3D%22%22%3E%3D%20%3A%5C!%22%22%20%7C%7C%20theColName%0A%20%20%20%20%7C%7C%20%22%5C!%22n%20%26amp%3B%20%20%20lag(%3A%5C!%22%22%20%7C%7C%20theColName%20%7C%7C%20%22%5C!%22n%2C-1)%20%26gt%3B%3D%20%3A%5C!%22%22%20%7C%7C%20theColName%20%7C%7C%0A%20%20%20%22%5C!%22n%20%7C%0A%20(row()%3D%3D1%20%26amp%3B%20lag(%3A%5C!%22%22%20%7C%7C%20theColName%20%7C%7C%20%22%5C!%22n%2C-1)%20%26gt%3B%3D%20%3A%5C!%22%22%20%7C%7C%20theColName%20%7C%7C%0A%20%20%20%22%5C!%22n)%20%7C%0A%20(row()%3D%3DN%20Rows(dt)%20%26amp%3B%20lag(%3A%5C!%22%22%20%7C%7C%20theColName%20%7C%7C%20%22%5C!%22n%2C1)%20%26gt%3B%3D%20%3A%5C!%22%22%20%7C%7C%0A%20%20%20theColName%20%7C%7C%20%22%5C!%22n)%0A)%3B%22%0A%20%20)%0A%20)%3B%0A%0A%20%2F%2F%20Set%20the%20found%20rows%20to%201%0A%20If(%20N%20Rows(%20theRows%20)%20%26gt%3B%200%2C%0A%20%20Column(%20dt%2C%20N%20Cols(%20dt%20)%20)%5BtheRows%5D%20%3D%201%0A%20)%3B%0A)%3B%3C%2FGET%3E%3C%2FGET%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449242%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449242%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAmbito%20della%20tabella%20delle%20colonne%20Allegato%20200%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-449241%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-449241%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECiao%20Super%20TxNelsol%2C%3C%2FP%3E%3CP%3ESono%20lieto%20di%20salutarvi%2C%20una%20domanda%3A%3C%2FP%3E%3CP%3EIn%20allegato%20una%20tabella%20con%20200%20colonne%20di%20prezzi%20azionari%20alti%20e%20bassi%2C%20vorrei%20creare%20nuove%20colonne%20che%20indichino%20o%20posizionino%201%20per%20i%20prezzi%20pi%C3%B9%20bassi%20e%20-1%20per%20i%20prezzi%20pi%C3%B9%20alti%20(picchi)%2C%200%20per%20il%20resto%20dei%20prezzi.%3C%2FP%3E%3CP%3EChiudi%20(200)%20-%201.18076%3CBR%20%2F%3E%20Chiudi%20(199)%20-%201.18073%3CBR%20%2F%3E%20Chiudi%20(198)%20-%201.18071%3CBR%20%2F%3E%20Segnale%20ottimale1%3A%20-1%3CBR%20%2F%3E%20Segnale%20ottimale2%3A%200%3CBR%20%2F%3E%20Segnale%20ottimale3%3A%200%3C%2FP%3E%3CP%3EChiudi%20(200)%20-%201.18056%3CBR%20%2F%3E%20Chiudi%20(199)%20-%201.18056%3CBR%20%2F%3E%20Chiudi%20(198)%20-%201.18057%3CBR%20%2F%3E%20Segnale%20ottimale1%3A%200%3CBR%20%2F%3E%20Segnale%20ottimale2%3A%200%3CBR%20%2F%3E%20Segnale%20ottimale3%3A%200%3C%2FP%3E%3CP%3EChiudi%20(200)%20-%201.18094%3CBR%20%2F%3E%20Chiudi%20(199)%20-%201.18077%3CBR%20%2F%3E%20Chiudi%20(198)%20-%201.1805%3CBR%20%2F%3E%20Segnale%20ottimale1%3A%200%3CBR%20%2F%3E%20Segnale%20ottimale2%3A%200%3CBR%20%2F%3E%20Segnale%20ottimale%203%3A%201%3C%2FP%3E%3CP%3ESaluti%2C%3C%2FP%3E%3CP%3EMarco%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63105%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63105%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGrazie%20mille!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-62925%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20trova%20pi%C3%B9%20valori%20di%20picco%20in%20una%20colonna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-62925%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEcco%20una%20nuova%20colonna%20nella%20tabella%20dei%20dati%20che%20rileva%20i%20picchi.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Kevin
Level I

find multiple peak values in a column

Hello,

I am working a data table that have time and length, and the length data is like wave. I want to find peak value of length of each wave, and label the time  when the peak happens in a new column as "peak". 

Can someone take a look and help me with the script?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: find multiple peak values in a column

Here is a new column in your data table that detects peaks.

Jim

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: find multiple peak values in a column

Here is a new column in your data table that detects peaks.

Jim
Kevin
Level I

Re: find multiple peak values in a column

A lot of thanks!!

Marco1
Level IV

Re: find multiple peak values in a column

Hello Super TxNelsol,

I am pleased to greet you, a query:

Attached a table with 200 columns of high and low stock prices, I would like to create new columns that indicate or place 1 for lower prices and -1 for the highest prices (peaks), 0 for the rest of prices.

Close (200) - 1.18076
Close (199) - 1.18073
Close (198) - 1.18071
Optimal signal1: -1
Optimal signal2: 0
Optimal signal3: 0

Close (200) - 1.18056
Close (199) - 1.18056
Close (198) - 1.18057
Optimal signal1: 0
Optimal signal2: 0
Optimal signal3: 0

Close (200) - 1.18094
Close (199) - 1.18077
Close (198) - 1.1805
Optimal signal1: 0
Optimal signal2: 0
Optimal signal 3: 1

Greetings,

Marco

Marco1
Level IV

Re: find multiple peak values in a column

Scoping the Attachment 200 column table

txnelson
Super User

Re: find multiple peak values in a column

See if this works the way you are thinking

Names Default To Here( 1 );
dt = Current Data Table();

colCount = N Cols( dt );
// Loop across all of the columns
For( i = 1, i <= colCount, i++,

	// Create the new column and set all values to 0
	dt << New Column( "Optimal signal" || Char( i ), set each value( 0 ) );
	
	// Get the name of the column to work on
	theColName = Column( dt, i ) << get name;
	
	// Find all of the High Points
	Eval(
		Parse(
			"theRows = dt<<get rows where(lag(:\!"" || theColName || "\!"n,1) <= :\!"" || theColName
			 || "\!"n &   lag(:\!"" || theColName || "\!"n,-1) <= :\!"" || theColName ||
			"\!"n |
	(row()==1 & lag(:\!"" || theColName || "\!"n,-1) <= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) & lag(:\!"" || theColName || "\!"n,1) <= :\!"" ||
			theColName || "\!"n)
);"
		)
	);
	
	// Set the found rows to -1
	If( N Rows( theRows ) > 0,
		Column( dt, N Cols( dt ) )[theRows] = -1
	);

	// Find all of the Low Points
	Eval(
		Parse(
			"theRows = dt<<get rows where(lag(:\!"" || theColName || "\!"n,1) >= :\!"" || theColName
			 || "\!"n &   lag(:\!"" || theColName || "\!"n,-1) >= :\!"" || theColName ||
			"\!"n |
	(row()==1 & lag(:\!"" || theColName || "\!"n,-1) >= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) & lag(:\!"" || theColName || "\!"n,1) >= :\!"" ||
			theColName || "\!"n)
);"
		)
	);

	// Set the found rows to 1
	If( N Rows( theRows ) > 0,
		Column( dt, N Cols( dt ) )[theRows] = 1
	);
);
Jim
Marco1
Level IV

Re: find multiple peak values in a column

Dear Jim,

I am new to JMP, could you please adapt the script to the attached table?
Greetings

Marco

txnelson
Super User

Re: find multiple peak values in a column

Here is all you need to do

  1. Open the data table
  2. Go to    File=>New=>Script       This will open a blank script window
  3. Cut and past the script from the webpage into the Script Window
  4. Run the script by clicking on the txnelson_0-1641529000188.pngicon in the Script Window

     

That will run the script against the newly opened data table.

I strongly suggest that you take the time to read the Discovering JMP document available under the Help pull down menu.

Jim
Marco1
Level IV

Re: find multiple peak values in a column

Hi Jim,

 

Super easy to apply the Script, but the objective is for a formula in each new column to find the highest stock prices (peaks) and place -1 and the lowest stock prices place 1 ... within a column range that I define (column range = 1-2 or 1-10 or 1-100 or 1-1000 ... etc), that is, in a hypothetical scenario using a history of stock prices ... what moments During the day they would have been optimal to buy shares at a lower price .... and ..... sell shares at times of higher price or rise ......, in such a way that it can train a neural network to learn to buy when the share price reaches its lowest point or 1 and sell when the share price reaches its highest point or -1 and when the price is with little movement the formula put 0

Greetings,

Marco

Recommended Articles