Highest high for specific bars - easylanguage code suggestion - futures io
futures io



Highest high for specific bars - easylanguage code suggestion


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 11 posts (2 thanks)
    2. looks_two cactus1973 with 10 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 edgefirst with 1 posts (1 thanks)
    1. trending_up 3,009 views
    2. thumb_up 5 thanks given
    3. group 6 followers
    1. forum 24 posts
    2. attach_file 3 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Highest high for specific bars - easylanguage code suggestion

(login for full post details)
  #1 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

Hello, everyone,
I am not very experienced with easylanguage, I have difficulty in coding the command to find highest (high, 5) only among the previous bars that have a minimum lower than the level x.

I hope I have explained well, I also enclose an image for more clarity. The result should return the maximum of bar A.

Anyone have any suggestions?

Thank you in advance

Gioak

Attached Thumbnails
Click image for larger version

Name:	B.png
Views:	77
Size:	28.2 KB
ID:	262400  
Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(82 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(25 thanks from 6 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(25 thanks from 9 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Maybe a little bit different journalby Malykubo
(6 thanks from 3 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
73 thanks
Would You Sell Your System?
71 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
32 thanks
Big Mike in Ecuador
27 thanks
 
(login for full post details)
  #3 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received


Hi Gioak,

I would suggest looking into the "for loop" as you will have to cycle through the previous bars and only include those that are lower than X in your tracking of the highest high.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #4 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

Yes, but unfortunately I don't know how to select only the bars with the minimum lower than x.

Gioak

Reply With Quote
 
(login for full post details)
  #5 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

post the code you have for the loop and I am sure someone can point you in the right direction.

You might want to take a look at the free EasyLanguage Essentials PDF that you can find on the net. It will explain the basis and cover loops, too.

Regards,

ABCTG


cactus1973 View Post
Yes, but unfortunately I don't know how to select only the bars with the minimum lower than x.

Gioak


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #6 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

HI ABCTG,

Thanks for your suggestions, I'll try to examine the free EasyLanguage Essentials PDF.

The code should be something like this:

Var: x(0), y(0);
For x = 1 to 5 and for y = 5 downto 1 begin

IF L [x] < x and H [x] = highest(high,y) then A = H [x] ;
end;

The problem is that I can't find the highest(high) only among the bars that have a minimum < than x.

Regards
Gioak

Reply With Quote
 
(login for full post details)
  #7 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

you can access the value for some reserved words like High by using a number within square brackets. Where the number specifies how many bars back from the currently processed bar you want to look at (while 0 is the most recent bar). Then you can compare this High and check it it matches your condition and only store it within a variable if it matches your condition and is higher than the currently stored value within the variable.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

HI ABCTG,
thanks for the suggestions, my difficulty is in finding the correct criterion to distinguish first only the bars that have a minimum of less than x and then be able to find among them (only among them) the bar with the highest max.

Regards
Gioak

Reply With Quote
 
(login for full post details)
  #9 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

cactus1973,

I would suggest to start simple. Create a loop that simply finds the highest high over the last X bars, without using the highest high function. You would use a variable to store the highest high within the loop in, by checking if the High for the bar you are currently looking at is higher than the value stored in the variable. If it is, you update the variable, if if's not, you do nothing. The only thing to add would be to reset the variable each time before you start with the loop (for example by setting the variable value to -999999 to ensure that it can be updated to a new high and that you don't store old information in the variable).

Regards,

ABCTG


cactus1973 View Post
HI ABCTG,
thanks for the suggestions, my difficulty is in finding the correct criterion to distinguish first only the bars that have a minimum of less than x and then be able to find among them (only among them) the bar with the highest max.

Regards
Gioak


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #10 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received


HI ABCTG,
I think that highest high of x bars back is not useful, you don't need to know highest high unless it has a minimum lower than x.
Infact what you need to know with a loop from 0 to 5 is which lows are lower than X and then among them which one has the highest maximum, it will be A like pic. Between the 5 bars back there could be a higher high than A but if it doesn't have a minimum lower than x I don't care.

Regards,

Gioak

Attached Thumbnails
Click image for larger version

Name:	abc.jpg
Views:	57
Size:	85.3 KB
ID:	262711  
Reply With Quote
 
(login for full post details)
  #11 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

this was just a suggestion so that you can easily familiarize yourself with the basics, as this can be helpful in learning EasyLanguage. Once you have the simple code working, you can easily adapt it to what you have in mind.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #12 (permalink)
 SidewalkAerobics 
Los Angels
 
Experience: Intermediate
Platform: MultiChart
Trading: Emini ES
 
Posts: 115 since Aug 2018
Thanks: 173 given, 71 received

You can create an array to store the value (highest high for the last 6 bars) for every bar.

Then at a later time you can call up the X place in the array to see the highest bar for that (6 bar) subset.

If you are worried about nanoseconds in your code, this might not be the most efficient way, but it is an easy way to code.

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Kolnidrei
Lyon/France
 
 
Posts: 5 since Aug 2012
Thanks: 1 given, 4 received

If I remember well you have the functions HHV and LLV in easylanguage.
So the highest high of the last 5 bars would be HHV( H, 5 ), the lowest low LLV( L, 5 ),
the highest open HHV( O, 5 ) etc.

Reply With Quote
The following 2 users say Thank You to Kolnidrei for this post:
 
(login for full post details)
  #14 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Kolnidrei,

HHV and LLV are part of Metastock as far as I am aware, but maybe someone created them for Tradestation as custom functions, too. However you can accomplish the same using the built-in functions Highest and Lowest i.e. Highest( High, 5 ) would give you the highest high over the last five bars in EasyLanguage.

Regards,

ABCTG


Kolnidrei View Post
If I remember well you have the functions HHV and LLV in easylanguage.
So the highest high of the last 5 bars would be HHV( H, 5 ), the lowest low LLV( L, 5 ),
the highest open HHV( O, 5 ) etc.


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #15 (permalink)
 edgefirst 
Las Cruces, NM
 
Experience: Advanced
Platform: Tradestation, MC, NT
Broker: TradeStation, IB
Trading: Liquid futures contracts
 
Posts: 56 since Sep 2009
Thanks: 379 given, 85 received

Hi Gioak,

hh will be the value you want.
hh_barsback will be the location (bars back).

 
Code
var: hh(0), hh_barsback(0);
hh = 0;
for k = 0 to N-1 begin
    if Low[k] < x and High[k] > hh then begin 
        hh = High[k];
        hh_barsback = k;
    end;
end;

Reply With Quote
The following user says Thank You to edgefirst for this post:
 
(login for full post details)
  #16 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

Hi edgefirst, thank you for your suggestion.. but my difficulty was in coding the command to find highest (high, 5) only among the bars previous to the current bars that have a minimum lower than the level x, that is the high of the current bar.

Gioak

Reply With Quote
 
(login for full post details)
  #17 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

this is exactly what the code @edgefirst posted provides, just replace x with High.
You would also have to make k a variable and N could be an input with the value of 5.

Regards,

ABCTG


cactus1973 View Post
Hi edgefirst, thank you for your suggestion.. but my difficulty was in coding the command to find highest (high, 5) only among the bars previous to the current bars that have a minimum lower than the level x, that is the high of the current bar.

Gioak


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #18 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

Hi ABCTG ,
I have elaborated the code following the instructions but as you can see from the output HH is not calculated, I suppose something is wrong;

input: N(4);
var:Lsetup(0), K(0), hh_barsback(0),hh(0);

IF D > D[1]then begin

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;
end;

HH = 0;
for k = 0 to N-1 begin
if Low[k] < Lsetup and High[k] > hh then begin
HH = High[k];
hh_barsback = k;
end;
end;

print(File("C:\Users\utente\Desktop\outputMulticharts\test.txt")," symbol ",symbol," date ",date:7:0,spaces(2)," time ",time:4:0,spaces(2)," spaces(3)," lsetup ",lsetup,spaces(3)," hh ",hh);

Reply With Quote
 
(login for full post details)
  #19 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

check your values for Lsetup as they might prevent the code from finding values on bars you are checking.

It might make sense to take one step back by removing the "Low[k] < Lsetup" to confirm that the code is able to find the highest high within the lookback.
Once you know that this part is working correctly you can proceed in tracking down what is not working correctly when you re-introduce "Low[k] < Lsetup" to your rules.

Regards,

ABCTG


cactus1973 View Post
Hi ABCTG ,
I have elaborated the code following the instructions but as you can see from the output HH is not calculated, I suppose something is wrong;

input: N(4);
var:Lsetup(0), K(0), hh_barsback(0),hh(0);

IF D > D[1]then begin

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;
end;

HH = 0;
for k = 0 to N-1 begin
if Low[k] < Lsetup and High[k] > hh then begin
HH = High[k];
hh_barsback = k;
end;
end;

print(File("C:\Users\utente\Desktop\outputMulticharts\test.txt")," symbol ",symbol," date ",date:7:0,spaces(2)," time ",time:4:0,spaces(2)," spaces(3)," lsetup ",lsetup,spaces(3)," hh ",hh);


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #20 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received


ABCTG View Post
Hi Gioak,

check your values for Lsetup as they might prevent the code from finding values on bars you are checking.

It might make sense to take one step back by removing the "Low[k] < Lsetup" to confirm that the code is able to find the highest high within the lookback.
Once you know that this part is working correctly you can proceed in tracking down what is not working correctly when you re-introduce "Low[k] < Lsetup" to your rules.

Regards,

ABCTG

I've tried but I think the code has some problem finding the highest high, it does not calculate hh.

If D > D[1]then begin

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;
end;

input: N(4);
var: K(0), hh_barsback(0),hh(0);


HH = 0;
for k = 0 to N-1 begin
if {Low[k] < Lsetup and} High[k] > hh then begin
HH = High[k];
hh_barsback = k;
end;
end;
print(File("C:\Users\utente\Desktop\outputMulticharts\test.txt")," symbol ",symbol," date ",date:7:0,spaces(2)," time ",time:4:0,spaces(2)," lsetup ",lsetup,spaces(3)," hh ",hh);


Regards,

Gioak

Reply With Quote
 
(login for full post details)
  #21 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Giok,

you would have to provide more information as we can't see the debug files you created that make you think the code does not compute a value for hh.

Using the following code in an indicator works fine on my end.
 
Code
input: N(4);
var: K(0), hh_barsback(0),hh(0);

HH = 0;

for k = 0 to N-1 
begin
	if High[k] > hh then 
	begin
		HH = High[k];
		hh_barsback = k;
	end;
end;

Plot1( HH, "HH" ) ;
Regards,

ABCTG


cactus1973 View Post
I've tried but I think the code has some problem finding the highest high, it does not calculate hh.

If D > D[1]then begin

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;
end;

input: N(4);
var: K(0), hh_barsback(0),hh(0);


HH = 0;
for k = 0 to N-1 begin
if {Low[k] < Lsetup and} High[k] > hh then begin
HH = High[k];
hh_barsback = k;
end;
end;
print(File("C:\Users\utente\Desktop\outputMulticharts\test.txt")," symbol ",symbol," date ",date:7:0,spaces(2)," time ",time:4:0,spaces(2)," lsetup ",lsetup,spaces(3)," hh ",hh);


Regards,

Gioak


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #22 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received

Hi ABCTG,

Putting the code in an indicator it works, i've tried. Like signal it does not work, i don't understand the reason.
I attached the debug file.

Regards,

Gioak

Attached Files
Register to download File Type: txt test.txt (732.9 KB, 9 views)
Reply With Quote
 
(login for full post details)
  #23 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Giok,

in general the code should give you the same results in both indicator and strategy and the code from my previous post works fine within a strategy on my end.
You can utilize i_SetPlotValue and i_GetPlotValue to exchange values between a strategy and an indicator on the same chart and plot the values. This can help in tracking differences down.

Regards,

ABCTG


cactus1973 View Post
Hi ABCTG,

Putting the code in an indicator it works, i've tried. Like signal it does not work, i don't understand the reason.
I attached the debug file.

Regards,

Gioak


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #24 (permalink)
cactus1973
Canicattì Italy
 
 
Posts: 15 since Nov 2018
Thanks: 0 given, 0 received


ABCTG View Post
Hi Giok,

in general the code should give you the same results in both indicator and strategy and the code from my previous post works fine within a strategy on my end.
You can utilize i_SetPlotValue and i_GetPlotValue to exchange values between a strategy and an indicator on the same chart and plot the values. This can help in tracking differences down.

Regards,

ABCTG

Hi ABCTG, thank you for your seggestion, i've tried the code like indicator and it works,even if it doesn't calculate what it should be.
This is the what i've elaborated, how you can see it does not work.

Regards
Gioak

input: N(4),Mystop(1000);
var: Lsetup(0), K(0), hh_barsback(0), hh(0);

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;

hh = 0;
for k = 0 to N-1 begin
if Low[k] < Lsetup and High[k] > hh then begin
hh = High[k];
hh_barsback = k;
end;
end;
If hh <> 0 then begin
IF C[1] < hh and C > hh then buy next bar at market;
IF marketposition > 0 then hh = 0;
end;
Setstopcontract;
setstoploss(MyStop);

Reply With Quote
 
(login for full post details)
  #25 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 received

Hi Gioak,

as previously suggested, check your values for Lsetup as they might prevent the code from finding values on bars you are checking.
You might also want to consider if it could make sense to store the value of 'hh' in an additional variable, which only gets reset
after an entry.

Regards,

ABCTG



cactus1973 View Post
Hi ABCTG, thank you for your seggestion, i've tried the code like indicator and it works,even if it doesn't calculate what it should be.
This is the what i've elaborated, how you can see it does not work.

Regards
Gioak

input: N(4),Mystop(1000);
var: Lsetup(0), K(0), hh_barsback(0), hh(0);

Lsetup = 0;
If C < L[1] and L = lowest(low,5) then Lsetup = H ;

hh = 0;
for k = 0 to N-1 begin
if Low[k] < Lsetup and High[k] > hh then begin
hh = High[k];
hh_barsback = k;
end;
end;
If hh <> 0 then begin
IF C[1] < hh and C > hh then buy next bar at market;
IF marketposition > 0 then hh = 0;
end;
Setstopcontract;
setstoploss(MyStop);


Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Highest high for specific bars - easylanguage code suggestion


Last Updated on March 1, 2019


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 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