Range Break Help - futures io
futures io futures trading



Range Break Help


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ummmx2 with 3 posts (0 thanks)
    2. looks_two ABCTG with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 bchip with 1 posts (1 thanks)
    1. trending_up 939 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 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
 

Range Break Help

(login for full post details)
  #1 (permalink)
Miami Florida/Dade
 
 
Posts: 7 since Oct 2016
Thanks: 2 given, 0 received

Hello,

I am new to easy language and just trying to code a few basic things for practice. My exercise in this code was to create a range and get the computer to plot a horizontal line framing the range (at the high and the low) from the start time to the end time and then recognize a break to the upside or break to the downside of the range.

Thought Process:
I created a for loop to try and get the computer to recognize the highest high and lowest low across a specified number of bars back.

I then tried to store this value in 2 variables called ONRHigh and ONRLow.

I then wanted to see if I could get text to print on the bars that closed higher or lower than the range for that day to verify that I had wrote the code for the highest high and lowest low of the range correct. I did not get the correct print. It would randomly print maybe one "up" during each day at a location that did not make sense.

I also wanted to see if I could plot the trendlines to see if maybe I could check where it's plotting the lines but when I tried to apply it to the chart I keep getting an error "tried to reference back more bars than allowed by the current maxbarsback". I tried changing this to extremely high numbers and no dice. I know its with the trendline section of the code because when I put the /// to comment it out the error does not happen.

 
Code
Inputs:
NumBarsBack (108),
TimeBegin (1805),
TimeEnd(0200);

Variables:
BarBackNo (0),
ONRHigh (0),
ONRLow (0),
ONRHighLine (ONRHigh);

ONRHigh = -99;
ONRLow = -99;

If Date <> Date[1] then Begin
	If Time =  TimeEnd then Begin	
		For BarBackNo = 0 to NumBarsBack
		Begin 
			ONRHigh = Highest(H, NumBarsBack);
			ONRLow = Lowest (L, NumBarsBack);
			End;
	End;
	If Close > ONRHigh then Value1 = text_new (D, T, H, "Up");
	If Close < ONRLow then Value2 = text_new (D, T, L, "Down");	
End;

ONRHighLine = TL_New (Date, Time[TimeBegin], ONRHigh, Date[1], Time[TimeEnd], ONRHigh);
TL_SetExtRight(ONRHighLine, True);
If anyone could please help me or point me in the right direction I would really appreciate it as it's a bit frustrating when I have no idea what I'm doing wrong.

Reply With Quote

Can you help answer these questions
from other members on futures io?
Trying to transform single contracts into a continuous contract from historical data
NinjaTrader
S&P 500 Advance Decline
NinjaTrader
Kube777 Market Orders
Platforms and Indicators
Market trading data-streaming or gaming in NT8?
NinjaTrader
DMIC 2059 program
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Big Mike in Ecuador
127 thanks
How did you learn to trade?
104 thanks
2020 profit and loss results
40 thanks
Is NT8 the right platform for scalping?
26 thanks
The Small Exchange (www.smallexchange.com)
26 thanks
 
(login for full post details)
  #3 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,224 since Apr 2013
Thanks: 405 given, 1,466 received


ummmx2,

you perform most of your code logic on the first bar of the new day only. Unless this bar happens to have the same time as your TimeBegin input, you might not perform the check on every day. Besides that it's not clear why you would use a loop here as the ONRHigh and ONRLow variables would only hold the value for the last loop iteration anyway and highest and lowest functions internally perform a loop already.
This is a good example where commenting the code could be helpful to explain your intentions, as without knowing why you do what you do it is harder to point you in the right direction.

Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #4 (permalink)
Miami Florida/Dade
 
 
Posts: 7 since Oct 2016
Thanks: 2 given, 0 received

Ok so I had it perform the logic on the last bar because I wanted it to start the look back period at the end of where I wanted the range. So say I wanted the range from 5pm-2am. I had it start the logic at 2am and look back whatever amount of bars from there. In this case 108 bars. I wanted to store the highest high within that range and the lowest low within that range so that after the end time I could assess a break on whatever side of the range. This is why I thought a for loop would be good to store the value of the variables for just the day and restart the next day.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,224 since Apr 2013
Thanks: 405 given, 1,466 received

ummmx2,

I would suggest using the print reserved word to check when your logic is evaluated and what exactly happens within the code and if it is even executed when you think it is.

Regards,

ABCTG


ummmx2 View Post
Ok so I had it perform the logic on the last bar because I wanted it to start the look back period at the end of where I wanted the range. So say I wanted the range from 5pm-2am. I had it start the logic at 2am and look back whatever amount of bars from there. In this case 108 bars. I wanted to store the highest high within that range and the lowest low within that range so that after the end time I could assess a break on whatever side of the range. This is why I thought a for loop would be good to store the value of the variables for just the day and restart the next day.


Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #6 (permalink)
Miami Florida/Dade
 
 
Posts: 7 since Oct 2016
Thanks: 2 given, 0 received

Ok I've been stuck on this for a few days and I really don't know what to do or how to go about fixing this. I tried to lookup and implement the print function but it's not sending anything to the print log and the help screen for the print function is confusing. I wrote out my logic line by line so that maybe I could get some insight as to where I'm going wrong with my thinking.

 
Code
Inputs:
NumBarsBack (108),
TimeBegin (1805),
TimeEnd(0200);

Variables:
BarBackNo (0),
ONRHigh (0),
ONRLow (0),
ONRHighLine (ONRHigh);

ONRHigh = -99 //this is an attempt to reset the variables after each day but I suppose ONR high variable reset should be put at a positive 9999?
ONRLow = -99 

If Date <> Date[1] then Begin //Using this to reset the code every day
	If Time =  TimeEnd then Begin //This line is to start executing the code when the range is over	
		For BarBackNo = 0 to NumBarsBack //This section is to look back (at the range indicated from this bar back to wherever number bars back I specify)
		Begin 
			ONRHigh = Highest(H, NumBarsBack); //these are to get the high and low within that range and to store in a variable
			ONRLow = Lowest (L, NumBarsBack);
			End;
	End;
	If Close > ONRHigh then Value1 = text_new (D, T, H, "Up"); //we are now attempting to use the stored variables as the high/low of the range and assessing a break above/below
	If Close < ONRLow then Value2 = text_new (D, T, L, "Down");	//I wanted text new as a way to check to make sure the breaks were happening in the right place
	Print(ELDateToString(date), Time, Time:0:0, ONRHigh, ONRLow); //this is a sad attempt to print something to the printlog because I have no idea what I'm doing here
End;

//ONRHighLine = TL_New (Date, Time[TimeBegin], ONRHigh, Date[1], Time[TimeEnd], ONRHigh);

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Africa
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
 
Posts: 93 since Sep 2017
Thanks: 128 given, 76 received


ummmx2 View Post
Hello,

I am new to easy language and just trying to code a few basic things for practice. My exercise in this code was to create a range and get the computer to plot a horizontal line framing the range (at the high and the low) from the start time to the end time and then recognize a break to the upside or break to the downside of the range.

I would try a different approach, if I understand it correctly your basically looking at the ORB Strategy.

I see you do the FOR loop, but you dont have to, the engine goes and checks each bar from back to front,
so its technically doing the for loop for you.
So you are currently
- looping through each bar and then
- doing a second loop at each bar

To get the high and low of each bar during a time you can

---Reset----
If Date <> Date[1] then
Begin
ONRHigh = -999999;
ONRLow = +999999;
end;

---Get the range values---
if Time >= 0900 and Time < 1000
begin
ONRHigh = MaxList( ONRHigh, High );
ONRLow = MinList( ONRLow, Low );
End;

---After closing time---
if Time >= 1000
begin
if High > ONRHigh buy at....
if Low < ONRLow sell at...
end;


This will only get you 1 day's view, i.e. it will work for an algo but not
for an indicator where you try and plot every days range.

* you also need to make sure that the timeframe selected is smaller so it fits in the timerange

Hope that helps.

Reply With Quote
The following user says Thank You to bchip for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Range Break Help


Last Updated on March 23, 2020


Upcoming Webinars and Events
 

Journal Challenge!

February
 

Battlestations!

March
     



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