NexusFi: Find Your Edge


Home Menu

 





calculate past data


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,822 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

Hi experts,

I'm totally noob to EL, so sorry if this bothers you a bit, but any help would be greatly appreciated.

I'd like to know how to reference past data and calculate the information at that specific time. I've read the books and understand how to reference past data based on time/date. But, when it comes to caculate series of data FROM a specific time in the past, i'm a bit stuck.

Example:
-I'm at time 1000
-I want to calculate MACD (Close, 8,23,11) NOT at current time but FROM 0959, then FROM 0958, so on and so forth for the past 5 min.

I was able to program the function to calculate the MACD from current time. But, i don't know how to reference and calculate from a specific time in the past without referencing the exact time in my code. i want my code to reference, t-1min, t-2min, t-3min, etc...

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to distinguish between trending and mean reversion
The Elite Circle
Top Pick Trading reviews?
Trading Reviews and Vendors
Need help Heiken Ashi system
NinjaTrader
NinjaTrader indicator for last bar percentages
NinjaTrader
IB Gateway / IBKR (semi-) daily restart / login
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Vinny E-Mini & Algobox Review TRADE ROOM
8 thanks
Futures spread trading grains education sources?
6 thanks
Wheres the videos?
3 thanks
Just another trading journal: PA, Wyckoff & Trends
3 thanks
Blue wave trading review
2 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 491
Thanks Received: 1,634


loi5139,

I am not exactly sure if I understand you correctly, but wouldn't it work to access the previous values for the MACD directly? If you store the MACD in a variable, you can access its previous values like with any other variable.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

If i use the MACD function, it will calculate the current close price of current bar plus the close price of previous bars as i specified.

Doing so, i might not get the correct data if the current bar hasn't closed yet. Say i'm using a 1min chart and i'm 15seconds into the bar.

If i'm at 1000 and calculate the MACD into 15seconds (at time 10:00:15) of the current bar and store it, that data is not accurate because the bar has not closed yet. In the same line of thought, it'd only accurate if i calculate the MACD from 0959 since the data is complete.

I might not fully understand the whole thing, but judging from MACD graph in TS, the MACD histogram of the current bar moves up/down as the market evolves.

If i use MACD[11], it will calculate MACD from the current bar with the previous number of bars as indicated. I'm right or wrong?

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 491
Thanks Received: 1,634


loi5139 View Post
If i use MACD[11], it will calculate MACD from the current bar with the previous number of bars as indicated. I'm right or wrong?

Let's assume you have a variable called MACD, then MACD[11] will be the value that variable had at the close 11 bars before the current bar.

I am still unclear of what you are trying to achieve, but you will likely run into issues when you try to access intrabar timestamps. In indicators you can't directly access intrabar information for historical bars and in signals with intrabar order generation I'd say from the top of the head the exact timestamp of the ticks is not available in Tradestation (definitely not via legacy EasyLanguage and I wouldn't suggest using OOEL concepts without having a solid understanding of EasyLanguage first).

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

Ok, I think i understand now. Please tell me if i'm right.

So i'm at time 1000.
If i use EL MACD function as it, it will calculate the current bar data with previous close as indicated in the function variable.

If i use MACD(Close,9,14)[1], it will calculate the data from bar at 0959. MACD(Close,9,14)[2] from bar at 0958, so on and so forth. Am i correct?

Basically, i'm trying to use the MACDDiff value from each of the previous 5 bars.

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 491
Thanks Received: 1,634

When you take a look at the default MACD indicator code, there are three variables that hold the values for the MACD and histogram.

 
Code
MyMACD = MACD( Close, FastLength, SlowLength ) ;
MACDAvg = XAverage( MyMACD, MACDLength ) ;
MACDDiff = MyMACD - MACDAvg ;
If you write MACDDiff[1] in your code the for example, this will give you the value of the histogram on the previous bar.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

I tried this MACD( Close[1], FastLength, SlowLength ), then Close[2], Close[3], etc...

That does exactly what i wanted, it calculates the MACD from past bar. It's like accessing MACD data in the past.

This doesn't work though: MACD( Close, FastLength, SlowLength )[2]

I tried that and compared the data with TS's chart data, and the function return different data.

Thanks

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 491
Thanks Received: 1,634

When using these three versions:

 
Code
MyMACD = MACD( Close, FastLength, SlowLength ) ;

Plot1( MyMACD[1], "MyMACD" ) ;

MyMACD2 = MACD( Close[1], FastLength, SlowLength ) ;

Plot2( MyMACD2, "MyMACD2" ) ;

Plot3( MACD( Close, FastLength, SlowLength )[1], "MyMACD3" ) ;
Plot1 and Plot3 give you the same result as it's basically the same statement.
In the beginning Plot2 will differ as you start with a different price.
On a long enough timeline Plot2 will closely match the other two, too. This is caused by the nature of the exponential average that will contain traces of all data points.

If the method used for Plot2 gives you what you are looking for, then use that.
By the way you can show your appreciation for a post here on Futures.io using the "Thanks" button under it.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2


Thanks for your explaination. Was very helpful.

Reply With Quote
Thanked by:




Last Updated on May 25, 2016


© 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 - Sitemap - Downloads - Top
no new posts