NexusFi: Find Your Edge


Home Menu

 





Newbie question - using historical value before assigned


Discussion in EasyLanguage Programming

Updated
    1. trending_up 972 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Newbie question - using historical value before assigned

  #1 (permalink)
 rickkeller 
Shanghai, China
 
Experience: Advanced
Platform: Ninjatrader
Trading: Forex
Posts: 3 since Aug 2012
Thanks Given: 0
Thanks Received: 0

I'm familiar with C# but I can't wrap my head around some EasyLanguage concepts and its hard for me to search for the answers to this type of question in forums or in the language reference guides.

Can someone explain how the EasyLanguage processor handles historical values (Hp[1],HP[2], IPeak[1]) below in the code when the lines are first encountered:

HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2];

Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];

IPeak = .991*IPeak[1];

If Absvalue(Filt) > IPeak Then IPeak = AbsValue(Filt);

Does it just skip over until populated or use a zero in place of historical values? If it uses a zero then I assume the programmer must be very careful when developing equation otherwise you can get into a situation where assigning a zero will always result in zero.

For instance if IPeak[1] starts out as 0 then IPeak will stay 0 until Absvalue(Filt) != 0?

And HP will be this part of equation ((1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) ) first bar, then (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] second bar, then finally full equation after 3rd bar?

I occasionally find code I want to convert to c# so I have to handle these unassigned values differently and just not sure if I am understand the big picture

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Futures True Range Report
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338



rickkeller View Post
I'm familiar with C# but I can't wrap my head around some EasyLanguage concepts and its hard for me to search for the answers to this type of question in forums or in the language reference guides.

Can someone explain how the EasyLanguage processor handles historical values (Hp[1],HP[2], IPeak[1]) below in the code when the lines are first encountered:

HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2];

Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];

IPeak = .991*IPeak[1];

If Absvalue(Filt) > IPeak Then IPeak = AbsValue(Filt);

Does it just skip over until populated or use a zero in place of historical values? If it uses a zero then I assume the programmer must be very careful when developing equation otherwise you can get into a situation where assigning a zero will always result in zero.

For instance if IPeak[1] starts out as 0 then IPeak will stay 0 until Absvalue(Filt) != 0?

And HP will be this part of equation ((1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) ) first bar, then (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] second bar, then finally full equation after 3rd bar?

I occasionally find code I want to convert to c# so I have to handle these unassigned values differently and just not sure if I am understand the big picture

Easy Language has a setting referred to as "max Bars back". It uses these bars to initialize calculations.

So if maxbarsback=10, then strategy engine will not do any of the calculations/lookback until the 10th or 11th bar. So, it should handle what you are doing correctly.

Follow me on Twitter Reply With Quote
  #4 (permalink)
 rickkeller 
Shanghai, China
 
Experience: Advanced
Platform: Ninjatrader
Trading: Forex
Posts: 3 since Aug 2012
Thanks Given: 0
Thanks Received: 0


kevinkdog View Post
Easy Language has a setting referred to as "max Bars back". It uses these bars to initialize calculations.

So if maxbarsback=10, then strategy engine will not do any of the calculations/lookback until the 10th or 11th bar. So, it should handle what you are doing correctly.

Thanks for reply. I guess I understand that in terms of bars, but my confusion is with the historical values of the variables. So if maxbarsback = 10 in the HP equation that takes care of the Close[1], Close[2], etc but the engine must be making some assumptions about the HP[1], HP[2] in the same equation?

So the first part of the HP equation (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) can be handled by the historic bars, but not the 2nd and 3rd part of the equation since that is self referencing. So does it just assume 0 for HP[1] and HP[2] in that case?

Sorry if I am not clear

Started this thread Reply With Quote
  #5 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


rickkeller View Post
Thanks for reply. I guess I understand that in terms of bars, but my confusion is with the historical values of the variables. So if maxbarsback = 10 in the HP equation that takes care of the Close[1], Close[2], etc but the engine must be making some assumptions about the HP[1], HP[2] in the same equation?

So the first part of the HP equation (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) can be handled by the historic bars, but not the 2nd and 3rd part of the equation since that is self referencing. So does it just assume 0 for HP[1] and HP[2] in that case?

Sorry if I am not clear

I suggest you put a print statement in your code, and see what it is calculating. I've explained it, and you are not going to believe me (and that's ok, I'd want to see proof too), so I think you should try it and see. That will eliminate all doubts.

Follow me on Twitter Reply With Quote
  #6 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338

Just to clarify, if you have "max number of bars study will reference" aka "maxbarsback" set at 10:

It will start calculating on bar 11.

HP on bar 11 will calculate based on the equation

HP[1] on bar 11 will be zero

HP[2] on bar 11 will be zero



Sorry if my other answer was unclear.


here is some I used to run it with.



var: alpha1(.5),HP(0),IPeak(0),filt(0),c1(1),c2(1.5),c3(2.0);


HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2];



var: bl(" ");
print(date,bl,currentbar,bl,hp,bl,hp[1],bl,hp[2]);

Follow me on Twitter Reply With Quote
  #7 (permalink)
 rickkeller 
Shanghai, China
 
Experience: Advanced
Platform: Ninjatrader
Trading: Forex
Posts: 3 since Aug 2012
Thanks Given: 0
Thanks Received: 0


kevinkdog View Post

HP[1] on bar 11 will be zero

HP[2] on bar 11 will be zero

Ok thanks that is what I was thinking, just confused by the self referencing of equation in HP and Filt.

Sorry I was trying to figure it out in my head since I don't use platforms that run on easylanguage and can't test/print. It looks like multicharts has that capability so maybe I can test with that in future.

Started this thread Reply With Quote




Last Updated on November 3, 2019


© 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