how to get highest number using for loop in EL - EasyLanguage Programming | futures io social day trading
futures io futures trading


how to get highest number using for loop in EL
Updated: Views / Replies:384 / 6
Created: by Sinuhet Attachments:1

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
 

how to get highest number using for loop in EL

  #1 (permalink)
Elite Member
London
 
Futures Experience: Advanced
Platform: Multicharts
Favorite Futures: ES
 
Posts: 4 since Oct 2015
Thanks: 2 given, 3 received

how to get highest number using for loop in EL

Dear all
I would like to ask for help.
I have a "For loop"with for x =0 to 9 returning correctly 10 different numbers on each bar (confirmed by Print).
I need to pick up the highest number from these 10 numbers and do some further computing with it.
I have tried with Highest function and with Maxlist function, but so far failed.
Any help would be highly appreciated.
Thank you

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary


Sinuhet,

the easiest will likely be to use a variable and compare during the loop if the current loop value is higher than the stored value in the variable. Make sure to remember resetting the variable each time before you enter the loop.

Something along the lines of this should do it:
 
Code
myTrackingVariable = -999999 ;

for ii = 0 to 9 
begin 
   //update the tracking variable
   if High[ii] > myTrackingVariable then
      myTrackingVariable = High[ii] ;
 end ;
At the end of this loop myTrackingVariable will hold the highest high of the last ten bars.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #4 (permalink)
Elite Member
London
 
Futures Experience: Advanced
Platform: Multicharts
Favorite Futures: ES
 
Posts: 4 since Oct 2015
Thanks: 2 given, 3 received

Thx ABCTG. I am afraid I still do something wrong, since getting only the last value in the loop. I have created code as an example and a screenshot to it. I simply would like to get at the end of the loop the highest Bar Range which occured during the looping.
Would be great if you could look where I am wrong.
Thank you
Sinuhet

 
Code
Code:
Inputs: Strength(3), 	                // bars on either side of the swing 
	    Length(250);		// within "length" trailing bars

Vars:    SHBB1(0),		       //number of bars ago the last Swing High occurred
            SHBB2(0),		       //number of bars ago 2nd last Swing High occurred
            MaxRange(-999999),//Value of max Bar Range
            RangeX(0),		      //Bar (price) Range
            x(0);			      //Counter for "FOR LOOP"

{define Swing Highs}
SHBB1 = (SwingHighBar(1,High,Strength,Length));
SHBB2 = (SwingHighBar(2,High,Strength,Length));

{paint Swing High Bars}
If SHBB1 = Strength then
PlotPaintBar[SHBB1](high[SHBB1],low[SHBB1],open[SHBB1],close[SHBB1], "Swing High Bar",Red);


{Find Max Range Bar if trend UP}
If high[SHBB1] > high[SHBB2] {= last Swing High > previous Swing High} then 
Begin
     if SHBB1 = Strength {new Last Swing High just created} then
     begin
	   MaxRange = -999999;	//reset before loop begins!
	   For x = 0 to SHBB2       //loop from the current bar to the 2nd last Swing High 
          begin
		 RangeX = High[x] - Low[x];		// define Range first
		 If RangeX[x] > MaxRange then
		 MaxRange = RangeX[x];		
          end;
     end;
End;
//**************************************************************************************
//DEBUG:
// Display MaxRange over the last Bar
If MaxRange <> MaxRange[1] then
Text_New(date,time,high,NumToStr(MaxRange,6)+"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

// For control display Range over each Bar
Text_New(date,time,high,NumToStr(High-Low,6)+"\n\n\n\n\n\n");
Screenshot:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following user says Thank You to Sinuhet for this post:
 
  #5 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

Sinuhet,

you are welcome.
What's the purpose of using RangeX[x] in your loop instead of RangeX? The values can/will be different and from your code it appears you are looking for
 
Code
RangeX = High[x] - Low[x];	
if RangeX > MaxRange then 
    MaxRange = RangeX;
This should give you the bar range within the bars you loop over.
By the way you can show your appreciation for posts on futures.io by clicking the "Thanks" button next to a post.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #6 (permalink)
Elite Member
London
 
Futures Experience: Advanced
Platform: Multicharts
Favorite Futures: ES
 
Posts: 4 since Oct 2015
Thanks: 2 given, 3 received

Thank you!
Now works everything as supposed to!
Sinuhet

Reply With Quote
The following user says Thank You to Sinuhet for this post:
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

Sinuhet,

great, I am glad to hear that. Thanks for letting me know.

Regards,

ABCTG

Reply With Quote

Reply



futures io > > > > > how to get highest number using for loop in EL

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
highest bar close occuring within the last X number of bars . . . . jmejedi NinjaTrader Programming 37 October 6th, 2014 01:52 AM
Nested Loop zeller4 NinjaTrader Programming 2 May 28th, 2014 05:15 PM
Avoiding trading loop in script mcteague NinjaTrader Programming 5 December 28th, 2012 03:18 AM
OODA Loop and Trading...... tradersam Psychology and Money Management 1 May 18th, 2011 03:36 PM
foreach loop problem gomad NinjaTrader Programming 14 May 17th, 2011 08:40 PM


All times are GMT -4. The time now is 06:47 PM.

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-14 in 0.11 seconds with 20 queries on phoenix via your IP 54.226.227.175