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 Big Mike with 1 posts (0 thanks)
    3. looks_3 Jura with 1 posts (2 thanks)
    4. looks_4 billtf with 1 posts (0 thanks)
    1. trending_up 16,298 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?
Iran Fired a Missile at Israel Last Night. The $8M June …
Prediction Markets & Event Contracts
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
Rubios Good News Within Hours and the 30-Day Math: Why H …
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)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691



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,583

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: 183 since Jun 2020
Thanks Given: 18
Thanks Received: 175

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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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: 183 since Jun 2020
Thanks Given: 18
Thanks Received: 175

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