NexusFi: Find Your Edge


Home Menu

 





Help extract last change.


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one victorg20013 with 7 posts (0 thanks)
    2. looks_two Hideyoshi with 3 posts (1 thanks)
    3. looks_3 rleplae with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,942 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 12 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0

I have double A be a down arrow sequence, the 3 digit number.
I also have double B be a bar number, the 4 digit number.

As A gets created, it jumps to a new B. (Arrow # might be static but changes to different bar number).

DownArrow: 434 1433
DownArrow: 434 1434
DownArrow: 434 1435
DownArrow: 436 1440
DownArrow: 436 1441
DownArrow: 438 1447
DownArrow: 438 1448
DownArrow: 440 1450
DownArrow: 442 1453
DownArrow: 442 1454
DownArrow: 442 1455

My question is, how do I get the last B of A, before A switches to a new number?

Here is what I want: new arrow list C and new bar number D.

a434 b1435
a436 b1441
a438 b1448
a440 b1450
a442 b1455

So basically, I just want to know what last B is associated with what A.
So that if I run:
if ( C == a436)
{
Print(D);
}
then the output should be
"b1441"


Cheers!



UPDATE:
Would the best approach be index?
if so
how would I get:

C[0] = 1455;
C[1] =1450;
C[2] = 1448;
C[3] =1441;
C[4] = 1435;


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Would a node-based workflow for automated trading be useful?
Traders Hideout
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,855


Something like this mike work.
The mechanism used is a List.

 
Code
int i;

List<double> C = new List<double>();
List<double> D = new List<double>();

double barnr=0;
for (i=0;i<A.Count()-1;i++)
{
  if (A[i] <> barnr)
   {
     barnr=A[i];
     C.add(A[i]);
     D.add(B[i])
    } 
  else
    {  
     D[D.Count()-1]=B[i];
    }
}

At the end you will end up with two new lists that are reduced
and only hold you last value.


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0


rleplae View Post
Something like this mike work.
The mechanism used is a List.

 
Code
int i;

List<double> C = new List<double>();
List<double> D = new List<double>();

double barnr=0;
for (i=0;i<A.Count()-1;i++)
{
  if (A[i] <> barnr)
   {
     barnr=A[i];
     C.add(A[i]);
     D.add(B[i])
    } 
  else
    {  
     D[D.Count()-1]=B[i];
    }
}

At the end you will end up with two new lists that are reduced
and only hold you last value.

Thanks for the response,
I'm running NT7, and I get the following errors.
1. cannot apply indexing with [] to an expression of type 'int'
2. int does not contain a definition for count and no extension method count accepting first arugument of.....
3. system.collections.generic.list<double> does not contain a definition for add and no extentision....
4. non-invocable member system.collections.generic.list<double>.count cannot be used like a method.


Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,855


victorg20013 View Post
Thanks for the response,
I'm running NT7, and I get the following errors.
1. cannot apply indexing with [] to an expression of type 'int'
2. int does not contain a definition for count and no extension method count accepting first arugument of.....
3. system.collections.generic.list<double> does not contain a definition for add and no extentision....
4. non-invocable member system.collections.generic.list<double>.count cannot be used like a method.

The example was 'conceptually', please post your full code if you want advice
are you building a strategy or an indicator ?


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0


rleplae View Post
The example was 'conceptually', please post your full code if you want advice
are you building a strategy or an indicator ?

Unfortunately I can't post the code here. its an indi.


Reply With Quote
  #7 (permalink)
 Hideyoshi 
Germany
 
Experience: None
Platform: Oanda
Trading: Forex
Posts: 9 since Feb 2011
Thanks Given: 568
Thanks Received: 2

Just put A and B into a TreeMap (https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html) and then use the values() method.


Reply With Quote
  #8 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0


Hideyoshi View Post
Just put A and B into a TreeMap and then use the values() method.

I have never used the TreeMap, is it only Java?


Reply With Quote
  #9 (permalink)
 Hideyoshi 
Germany
 
Experience: None
Platform: Oanda
Trading: Forex
Posts: 9 since Feb 2011
Thanks Given: 568
Thanks Received: 2

Yes, it is pure Java. Here is an example which should fit your requirements:



import java.util.TreeMap;
import java.util.Map;

public class Test {

static public void main(String[] args) {
int[] a = {434, 434, 434, 436, 436, 438, 438, 440, 442, 442, 442};
int[] b = {1433, 1434, 1435, 1440, 1441, 1447, 1448, 1450, 1453, 1454, 1455};

TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();
for (int i=0; i<a.length; i++) {
map.put(Integer.valueOf(a[i]), Integer.valueOf(b[i]));
}

for (Map.Entry<Integer,Integer> entry : map.entrySet()) {
System.out.println("key ->" + entry.getKey() + ", value->" + entry.getValue());
}
}
}

Result:

key ->434, value->1435
key ->436, value->1441
key ->438, value->1448
key ->440, value->1450
key ->442, value->1455


Reply With Quote
  #10 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0


Unfortunately, NinjaScript is in C#. Are there other alternatives?


Reply With Quote




Last Updated on February 15, 2017


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts