NexusFi: Find Your Edge


Home Menu

 





getting only positive value's


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one spajansen with 3 posts (0 thanks)
    2. looks_two tpredictor with 2 posts (1 thanks)
    3. looks_3 ABCTG with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 2,232 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 spajansen 
Arnhem , the Netherlands
 
Experience: Beginner
Platform: TRADESTATION
Broker: Tradestation
Trading: NQ
Posts: 7 since Feb 2017
Thanks Given: 4
Thanks Received: 1

hi dudes amd dudettes,

i'm fairly new to easylanguage and i'm trying to get the smallest POSITIVE value out of a list.

i'm aware of minlist, maxlist, absvalue, pos and min but i'm still stuck.

for example: for the list -1, -2, 1, 3 the favored output should be 1.

who can steer me in the right direction??


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 thanks
  #3 (permalink)
 tpredictor 
North Carolina
 
Experience: Beginner
Platform: NinjaTrader, Tradestation
Trading: es
Posts: 644 since Nov 2011


One simple way is not to store any negative values in the list. If you need the negative values for another purpose, create an additional array variable. See the psuedo code at below:

 
Code
If (x< 0) then skip
Your other most straightforward option is to read each item in the list using a for loop. Additionally, you could simply keep a running track of the smallest item thereby not requiring any search at all.


 
Code
y = x >= 0 and x < y: x, y


Reply With Quote
  #4 (permalink)
 spajansen 
Arnhem , the Netherlands
 
Experience: Beginner
Platform: TRADESTATION
Broker: Tradestation
Trading: NQ
Posts: 7 since Feb 2017
Thanks Given: 4
Thanks Received: 1

hi,
i was hoping this to be posible without the use of an array.
i have never build an array.....
the values i am storing are fixed (floor pivots) and i want to find the one that is the closed below the current price.


Started this thread Reply With Quote
  #5 (permalink)
 tpredictor 
North Carolina
 
Experience: Beginner
Platform: NinjaTrader, Tradestation
Trading: es
Posts: 644 since Nov 2011

Arrays aren't very difficult to use: you might look into them. However, if you want to avoid an array and only have a few items you can use the code below which is basically implementation of pseudo method shown above:

 
Code
Once begin
Value10 = -1;  // This can be used as a check to see if any positive value was found
end;

Value10 = iff(Value1 >= 0 and value1 < value10, value1,value10);
Value10 = iff(Value2 >= 0 and value2 < value10, value2,value10);


Reply With Quote
  #6 (permalink)
 spajansen 
Arnhem , the Netherlands
 
Experience: Beginner
Platform: TRADESTATION
Broker: Tradestation
Trading: NQ
Posts: 7 since Feb 2017
Thanks Given: 4
Thanks Received: 1

thank you,
it dowsnt look pretty but it seems to work


 
Code
vars: piv1(0),piv2(0),piv3(0),piv4(0),piv5(0),piv6(0),piv7(0),piv8(0),piv9(0),piv10(0),piv11(0),piv12(0),piv13(0);
	
piv1 = iff((L-pp)>0,(L-PP), 99999);
piv2 = iff((L-rr1)>0,(L-rr1), 99999);
piv3 = iff((L-rr2)>0,(L-rr2), 99999);
piv4 = iff((L-rr3)>0,(L-rr3), 99999);
piv5 = iff((L-ss1)>0,(L-ss1), 99999);
piv6 = iff((l-ss2)>0,(L-ss2), 99999);
piv7 = iff((l-ss3)>0,(l-ss3), 99999);
piv8 = iff((L-m0)>0,(L-M0), 99999);
piv9 = iff((l-m1)>0,(l-m1), 99999);
piv10 = iff((l-m2)>0,(l-m2), 99999);
piv11 = iff((L-m3)>0,(L-M3), 99999);
piv12 = iff((l-m4)>0,(l-m4), 99999);
piv13 = iff((l-m5)>0,(l-m5), 99999);
	
	
closestpivot_l  =L -(Minlist(piv1,piv2,piv3,piv4,piv5,piv6,piv7,piv8,piv9,piv10,piv11,piv12,piv13))


Started this thread Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

spajansen,

pretty is in the eye of the beholder - if it works for you, great.

If you want to create it more efficient you can take a look at a "for loop" (as @tpredictor mentioned) and the "switch" statement and combine them (basically loop from 0 to 12 and have the switch statement return the corresponding pivot to your current loop count) - you don't even have to use an array in that approach, just one variable that holds your current pivot (within the loop) and one variable that holds the current smallest positive value.

Regards,

ABCTG


Follow me on X Reply With Quote




Last Updated on July 31, 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