NexusFi: Find Your Edge


Home Menu

 





How to reference historical price bars by time v2


Discussion in EasyLanguage Programming

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




 
Search this Thread

How to reference historical price bars by time v2

  #1 (permalink)
mandelmus
Dallas, TX
 
Posts: 8 since Jun 2011
Thanks Given: 2
Thanks Received: 3

I'm trying to develop a lunch-time lull range breakout strategy. In order to do that, I need to do some calculations based on referencing historical price bars by time.

I followed the suggestions posted on a related thread ... "How to reference historical price bars by time" ... but it was insufficient. The code works fine up until 1100 today. When it hits 1100 today, the code seems to calculate the difference between the price at 1300 yesterday and 1100 today (instead of yesterday). I want it to reference 1100 and 1300 from the previous day instead of the current day.

 
Code
[IntrabarOrderGeneration = TRUE]

Variables:
    storedClose1(0),
    storedClose2(0),
    storedClose3(0);
    
// Store close of a specific time    
if (Time = 1100) then  // supposed to be for 1100 of previous day
    storedClose1 = Close;
if (Time = 1300) then  // supposed to be for 1300 of previous day
    storedClose2 = Close;
if (Time = 1130) then  // supposed to be for 1130 of current day
    storedClose3 = Close;

// Compare it with the current close
if (Time >= 1130) and ( Close > ( (storedClose2 - storedClose1) + storedClose3 ) ) then
    Buy next bar at market;

Here is my vision ...

1) Calculate the price difference between the following:
... a) Price at 1100 CST of the previous trading day (roughly the beginning of the lunch-time lull)
... b) Price at 1300 CST of the previous trading day (roughly the end of the lunch-time lull)
... c) For example: $25 price at 1300 yesterday - $20 price at 1100 yesterday = +$5 difference

2) If the price difference is positive:
... a) I would draw a trendline at the level of the price at 1130 (1130am CST today) + the price difference
... b) I would enter long if intrabar price crosses above the trendline ... I would exit at 2% profit or set a stop loss at 5%
... c) For example: $30 price at 1130 today + $5 difference = enter long if price crosses above $35 and set exit at either 2% profit or 5% stop loss

3) If the price difference is negative:
... a) I would draw a trendline at the level of the price at 1130 (1130am CST today) - the price difference
... b) I would enter short if intrabar price crosses below the trendline ... I would exit at 2% profit or set a stop loss at 5%
... c) For example: $30 price at 1130 today - $5 difference = enter short if price crosses below $25 and set exit at either 2% profit or 5% stop loss

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628


mandelmus,

the way you wrote the code TS has no way of knowing that you want to use the value at the same time of the last day. So you need to store the value yourself on the current day and use it on the next day.

something like this should get you going:

 
Code
Variables:
   currentClose1(0),
   currentClose2(0),
    storedClose1(0),
    storedClose2(0),
    storedClose3(0);
    
// Store close of a specific time    
if (Time = 1100) then  // supposed to be for 1100 of previous day
begin
    storedClose1 = currentClose1 ;
    currentClose1 = Close ;
end ;
if (Time = 1300) then  // supposed to be for 1300 of previous day
begin
    storedClose2 = currentClose2 ;
    currentClose2 = Close ;
end ;
if (Time = 1130) then  // supposed to be for 1130 of current day
    storedClose3 = Close;
Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on February 23, 2015


© 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