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 Quick Summary with 1 posts (0 thanks)
    3. looks_3 Nevi with 1 posts (3 thanks)
    4. looks_4 ABCTG with 1 posts (0 thanks)
    1. trending_up 15,379 views
    2. thumb_up 5 thanks given
    3. group 4 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
 

How to reference historical price bars by time

 
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.


Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
NexusFi Journal Challenge - April 2024
Feedback and Announcements
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Futures True Range Report
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
 
 
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)

Thanked by:
 
 
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,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

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 Twitter Visit my NexusFi Trade Journal
 
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 ]

Thanked by:
 
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 144 since Jun 2020
Thanks Given: 10
Thanks Received: 147

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?

 
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

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 Twitter
 
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 144 since Jun 2020
Thanks Given: 10
Thanks Received: 147

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


 



Last Updated on July 2, 2020


© 2024 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 - Privacy Policy - Downloads - Top
no new posts