<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: find multiple peak values in a column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449387#M69615</link>
    <description>&lt;P&gt;See if this works the way you are thinking&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

colCount = N Cols( dt );
// Loop across all of the columns
For( i = 1, i &amp;lt;= colCount, i++,

	// Create the new column and set all values to 0
	dt &amp;lt;&amp;lt; New Column( "Optimal signal" || Char( i ), set each value( 0 ) );
	
	// Get the name of the column to work on
	theColName = Column( dt, i ) &amp;lt;&amp;lt; get name;
	
	// Find all of the High Points
	Eval(
		Parse(
			"theRows = dt&amp;lt;&amp;lt;get rows where(lag(:\!"" || theColName || "\!"n,1) &amp;lt;= :\!"" || theColName
			 || "\!"n &amp;amp;   lag(:\!"" || theColName || "\!"n,-1) &amp;lt;= :\!"" || theColName ||
			"\!"n |
	(row()==1 &amp;amp; lag(:\!"" || theColName || "\!"n,-1) &amp;lt;= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) &amp;amp; lag(:\!"" || theColName || "\!"n,1) &amp;lt;= :\!"" ||
			theColName || "\!"n)
);"
		)
	);
	
	// Set the found rows to -1
	If( N Rows( theRows ) &amp;gt; 0,
		Column( dt, N Cols( dt ) )[theRows] = -1
	);

	// Find all of the Low Points
	Eval(
		Parse(
			"theRows = dt&amp;lt;&amp;lt;get rows where(lag(:\!"" || theColName || "\!"n,1) &amp;gt;= :\!"" || theColName
			 || "\!"n &amp;amp;   lag(:\!"" || theColName || "\!"n,-1) &amp;gt;= :\!"" || theColName ||
			"\!"n |
	(row()==1 &amp;amp; lag(:\!"" || theColName || "\!"n,-1) &amp;gt;= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) &amp;amp; lag(:\!"" || theColName || "\!"n,1) &amp;gt;= :\!"" ||
			theColName || "\!"n)
);"
		)
	);

	// Set the found rows to 1
	If( N Rows( theRows ) &amp;gt; 0,
		Column( dt, N Cols( dt ) )[theRows] = 1
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Jan 2022 10:28:42 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-01-06T10:28:42Z</dc:date>
    <item>
      <title>find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/62919#M33840</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working a data table that have time and length, and the length data is like wave. I want to find&amp;nbsp;peak value of length of each wave, and label the time&amp;nbsp; when the peak happens in a new column as "peak".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone take a look and help me with the script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 00:01:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/62919#M33840</guid>
      <dc:creator>Kevin</dc:creator>
      <dc:date>2018-07-14T00:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/62925#M33844</link>
      <description>&lt;P&gt;Here is a new column in your data table that detects peaks.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 02:16:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/62925#M33844</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-14T02:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/63105#M33902</link>
      <description>&lt;P&gt;A lot of thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 17:52:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/63105#M33902</guid>
      <dc:creator>Kevin</dc:creator>
      <dc:date>2018-07-17T17:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449241#M69597</link>
      <description>&lt;P&gt;Hello Super TxNelsol,&lt;/P&gt;&lt;P&gt;I am pleased to greet you, a query:&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Close (200) - 1.18076&lt;BR /&gt;Close (199) - 1.18073&lt;BR /&gt;Close (198) - 1.18071&lt;BR /&gt;Optimal signal1: -1&lt;BR /&gt;Optimal signal2: 0&lt;BR /&gt;Optimal signal3: 0&lt;/P&gt;&lt;P&gt;Close (200) - 1.18056&lt;BR /&gt;Close (199) - 1.18056&lt;BR /&gt;Close (198) - 1.18057&lt;BR /&gt;Optimal signal1: 0&lt;BR /&gt;Optimal signal2: 0&lt;BR /&gt;Optimal signal3: 0&lt;/P&gt;&lt;P&gt;Close (200) - 1.18094&lt;BR /&gt;Close (199) - 1.18077&lt;BR /&gt;Close (198) - 1.1805&lt;BR /&gt;Optimal signal1: 0&lt;BR /&gt;Optimal signal2: 0&lt;BR /&gt;Optimal signal 3: 1&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 18:14:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449241#M69597</guid>
      <dc:creator>Marco1</dc:creator>
      <dc:date>2022-01-05T18:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449242#M69598</link>
      <description>&lt;P&gt;Scoping the Attachment 200 column table&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 18:21:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449242#M69598</guid>
      <dc:creator>Marco1</dc:creator>
      <dc:date>2022-01-05T18:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449387#M69615</link>
      <description>&lt;P&gt;See if this works the way you are thinking&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

colCount = N Cols( dt );
// Loop across all of the columns
For( i = 1, i &amp;lt;= colCount, i++,

	// Create the new column and set all values to 0
	dt &amp;lt;&amp;lt; New Column( "Optimal signal" || Char( i ), set each value( 0 ) );
	
	// Get the name of the column to work on
	theColName = Column( dt, i ) &amp;lt;&amp;lt; get name;
	
	// Find all of the High Points
	Eval(
		Parse(
			"theRows = dt&amp;lt;&amp;lt;get rows where(lag(:\!"" || theColName || "\!"n,1) &amp;lt;= :\!"" || theColName
			 || "\!"n &amp;amp;   lag(:\!"" || theColName || "\!"n,-1) &amp;lt;= :\!"" || theColName ||
			"\!"n |
	(row()==1 &amp;amp; lag(:\!"" || theColName || "\!"n,-1) &amp;lt;= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) &amp;amp; lag(:\!"" || theColName || "\!"n,1) &amp;lt;= :\!"" ||
			theColName || "\!"n)
);"
		)
	);
	
	// Set the found rows to -1
	If( N Rows( theRows ) &amp;gt; 0,
		Column( dt, N Cols( dt ) )[theRows] = -1
	);

	// Find all of the Low Points
	Eval(
		Parse(
			"theRows = dt&amp;lt;&amp;lt;get rows where(lag(:\!"" || theColName || "\!"n,1) &amp;gt;= :\!"" || theColName
			 || "\!"n &amp;amp;   lag(:\!"" || theColName || "\!"n,-1) &amp;gt;= :\!"" || theColName ||
			"\!"n |
	(row()==1 &amp;amp; lag(:\!"" || theColName || "\!"n,-1) &amp;gt;= :\!"" || theColName ||
			"\!"n) |
	(row()==N Rows(dt) &amp;amp; lag(:\!"" || theColName || "\!"n,1) &amp;gt;= :\!"" ||
			theColName || "\!"n)
);"
		)
	);

	// Set the found rows to 1
	If( N Rows( theRows ) &amp;gt; 0,
		Column( dt, N Cols( dt ) )[theRows] = 1
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jan 2022 10:28:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449387#M69615</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-01-06T10:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449611#M69648</link>
      <description>&lt;P&gt;Dear Jim,&lt;/P&gt;&lt;P&gt;I am new to JMP, could you please adapt the script to the attached table?&lt;BR /&gt;Greetings&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 23:52:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449611#M69648</guid>
      <dc:creator>Marco1</dc:creator>
      <dc:date>2022-01-06T23:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449616#M69651</link>
      <description>&lt;P&gt;Here is all you need to do&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open the data table&lt;/LI&gt;
&lt;LI&gt;Go to&amp;nbsp; &amp;nbsp; File=&amp;gt;New=&amp;gt;Script&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This will open a blank script window&lt;/LI&gt;
&lt;LI&gt;Cut and past the script from the webpage into the Script Window&lt;/LI&gt;
&lt;LI&gt;Run the script by clicking on the&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1641529000188.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38779iD2BA12E33AB203A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1641529000188.png" alt="txnelson_0-1641529000188.png" /&gt;&lt;/span&gt;icon in the Script Window
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;That will run the script against the newly opened data table.&lt;/P&gt;
&lt;P&gt;I strongly suggest that you take the time to read the Discovering JMP document available under the Help pull down menu.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 04:19:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449616#M69651</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-01-07T04:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: find multiple peak values in a column</title>
      <link>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449918#M69675</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 05:00:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-multiple-peak-values-in-a-column/m-p/449918#M69675</guid>
      <dc:creator>Marco1</dc:creator>
      <dc:date>2022-01-08T05:00:18Z</dc:date>
    </item>
  </channel>
</rss>

