NexusFi: Find Your Edge


Home Menu

 





How to reference historical price bars by time


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Small Dog with 2 posts (0 thanks)
    2. looks_two Nevi with 1 posts (3 thanks)
    3. looks_3 ABCTG with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 16,268 views
    2. thumb_up 5 thanks given
    3. group 4 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
billtf
New York, NY USA
 
Posts: 1 since Feb 2012
Thanks Given: 1
Thanks Received: 0

Hey everyone, I'm a new member to this forum. I had a question regarding how to reference a historical bar in Easylanguage. I know you can use [1] to reference a previous bar, but I can't figure out how to return the close of a particular time. For example I want to setup a reversal play at the end of the day is price has moved more than a certain amount from another reference bar. This is what I've tried so far *inputs: starttime(1530), endtime(1555); variables: barcalc(0); barcalc=endtime-starttime; If Time = endtime and (close[barcalc] - close) 10 then buy next bar at market;* I think this should work on a 1 minute chart but TS gives me an error saying it cannot reference the number of bars. Any help would be appreciated.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Requests Tag 50 Trader Identity Data From CME and I …
Traders Hideout
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
Energy Futures Shatter All-Time Daily Volume: 8.3 Millio …
Commodities
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



billtf View Post
Hey everyone, I'm a new member to this forum.

I had a question regarding how to reference a historical bar in Easylanguage.

I know you can use [1] to reference a previous bar, but I can't figure out how to return the close of a particular time.

For example I want to setup a reversal play at the end of the day is price has moved more than a certain amount from another reference bar. This is what I've tried so far:
 
Code
inputs: starttime(1530), endtime(1555);   

variables: barcalc(0);    

barcalc=endtime-starttime;    

If Time = endtime and (close[barcalc] - close) 10 then  
buy next bar at market;
I think this should work on a 1 minute chart but TS gives me an error saying it cannot reference the number of bars. Any help would be appreciated.

You could try to store the close price on a specific time, like..

 
Code
Variables:
    storedClose(0);
    
// Store close of a specific time    
if (Time = 1530) then
    storedClose = Close;
    
// Compare it with the current close
if (Time = 1555) and ((Close - storedClose) >= 10) then
    Buy next bar at market;
(Tip: use enters and the [ code ] and [ / code ] tags around your answer for easier reading/better understanding)


Reply With Quote
Thanked by:
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557

I am thinking MultiCharts 8 has added some new functionality in this area, but am not on right computer to check the changelog right now.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
Nevi
phoenix az
 
Posts: 4 since Aug 2011
Thanks Given: 0
Thanks Received: 1

The simplest way to reference past bars is to create a counter, start at your specified time or condition, then use that counter to reference how many bars ago your condition occurred.
Here is a basic signal that uses a counter to reference a previous bar.
[ code ]
vars: count(0);
if barnumber>0 then begin
count = 0;
if time = 830 then begin
count = count[1] + 1;
end;
if time = 1430 then begin
if close > (close[count] +10 then
sell short next bar at market;
end;
[ / code ]


Reply With Quote
Thanked by:
  #6 (permalink)
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 182 since Jun 2020
Thanks Given: 18
Thanks Received: 172

I have a similar albeit more complex problem. I need to determine trading session using hourly bars in Forex. Forex day in Sydney starts at 7:00 and ends at 6:59. I need to determine the the range of the previous day. HighD and HighD won't work because it starts a midnight.

Do I have to build the array of prices and then use high and low from it?


Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

ursus,

you could use two variables and track the high and low within certain times yourself. There are a few examples for that posted on nexusfi.com that should get you going.
This one for example:

Regards,

ABCTG


ursus View Post
I have a similar albeit more complex problem. I need to determine trading session using hourly bars in Forex. Forex day in Sydney starts at 7:00 and ends at 6:59. I need to determine the the range of the previous day. HighD and HighD won't work because it starts a midnight.

Do I have to build the array of prices and then use high and low from it?


Follow me on X Reply With Quote
  #8 (permalink)
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 182 since Jun 2020
Thanks Given: 18
Thanks Received: 172

Thanks for this. I have to twist my brain to figure out how to code the session that ctosses midnight.


Reply With Quote




Last Updated on July 2, 2020


© 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