Resetting of Hourly BuyZone question

If you don't know where to start, start here! Don't be afraid to ask questions.

Moderator: moderators

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Wed Jan 09, 2008 8:02 pm

TRO,
Which eld would you use for 're-usable' code / a template if you were going to write one?
thx.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Wed Jan 09, 2008 8:32 pm

There is a TEMPLATE ELD that I wrote called:

_SMAA_TEMPLATE

Depending on what you are trying to do, TRO PLOT can be used as a template, too.

But if you learn how to use TRO PLOT, you probably don't need to write any indicators at all!!
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Thu Jan 10, 2008 2:53 pm

TRO, What functions do you normally use in EL to add time (in this case minutes) to a datetime? Thx.

begin edit 5PM
Was asking so I could stay close to your standard practices for managing time calculations.

Find below a concept I just put together for reset each interval should work on any ts bar type...got to go now. Maybe you can pick up on it overnight. thx

Code: Select all

inputs:
zoneSessStartTime(.01),  // user defined daily start time
tInterval(60), // user defined interval in minutes btwn zone re-calcs
inZmult(3),  // multiplier to get inner zone
outZmult(4) // multiplier to get outer zone
;// end inputs

var:
oZ(c),   // the ?core? of the current zone/, the ?open?
thisTicktime(0),  // ?formatted Now?
prevTickTime(0), // most recent ?formatted Now?   
nextRollTime(0), // when interval is up and time to set new ?open? for ZoneTrades
//zSssTime(encodetime(zoneSessStartTime)),
initDiff(0),  // initial time diff between now and user defined daily start time

bZ1(0),  // inner buy zone
bZ2(0), // outer buy zone
sZ1(0),  // inner sell zone
sZ2(0) // outer sell zone

;// end vars

thisTicktime = fracportion(ComputerDateTime);   //time

initDiff = intportion(timetominutes(thisTickTime - zoneSessStartTime) / tInterval);

if initDiff > 0 then begin
 nextRollTime = CalcTime(zoneSessStartTime, ((initDiff + 1) * tInterval));

end else begin   
 if prevTickTime < zoneSessStartTime and
    thisTicktime >= zoneSessStartTime then begin
  if barstatus(1) = 0 then 
    oZ = o
  else
    oZ = c;

  nextRollTime = CalcTime(zoneSessStartTime, tInterval);   
 
 end; // if prevTickTime < zoneSessStartTime and tickTime >= zoneSessStartTime   

end; // initDiff > 0

if prevTickTime < nextRollTime and
   thisTicktime >= nextRollTime then begin
  if barstatus(1) = 0 then 
    oZ = o
  else
    oZ = c;

 nextRollTime = CalcTime(nextRollTime, tInterval);

end; // if prevTickTime < nextRollTime and tickTime >= nextRollTime

prevTickTime =  thisTicktime;

if oZ > 0 then begin
 bZ1 = oZ + (uTick * inZmult);
 bZ2 = oZ + (uTick * outZmult);

 sZ1 = oZ - (uTick * inZmult);
 bZ2 = oZ - (uTick * outZmult);

 plot1(bZ1, "bZ1");
 plot2(bZ2, "bZ2");
 plot3(sZ1, "sZ1");
 plot4(sZ2, "sZ2");

end else begin
 noplot(1);
 noplot(2);
 noplot(3);
 noplot(4);

end; // if oZ > 0



//set plot style to dots


All the best
Last edited by obx on Fri Jan 11, 2008 5:38 pm, edited 1 time in total.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Fri Jan 11, 2008 12:16 am

That seems like an awful lot of code!!

Just use a MOD function to see if the time ends in 00!
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Fri Jan 11, 2008 5:36 pm

TheRumpledOne wrote:That seems like an awful lot of code!!
Just use a MOD function to see if the time ends in 00!


thx a lot TRO :)

the (lot of) code was little more than pseudo code for the concept of user set start time and interval ? so not locked to 00 and 60 mins and timebars.
should have been more clear about that.

basically-
if now is greater than user defined daily start time (ie is not bound to ts sessionstarttime, but may be equal to it) then
compute how many intervals past daily start time that now is
add that much time in (intervals + 1) to get start of next nextRollTime
else if now is less than user defined daily start time set logic to catch the ?open? when
user defined daily start time is passed

subsequent nextRollTime tested for and ?open? set when nextRollTime time is passed

editing the code above so if nextRollTime time is passed intrabar, then the ?open? to use is moved to the tick just after nextRollTime time is passed
also added comments.

Any one got time to make it work?

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Tue Jan 22, 2008 10:57 pm

"Dynamic" BuyZone just bought the USDJPY
Statistically sound start time.
Statistically sound duration (currently close to 48 minutes btw)
Statistically sound zones
All reset daily
Attachments
dynamicBuySellZone.jpg
dynamicBuySellZone.jpg (176.88 KiB) Viewed 354 times

BlackJack
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Wed May 31, 2006 2:13 am
Reputation: 0
Gender: Male

Postby BlackJack » Wed Jan 23, 2008 10:55 am

obx wrote:Is there an eld that automatically resets each new bar? Thx


Hi Obx,

We, those of us that still use ts2ki, have a couple of problems that don't seem to be an issue with other platforms. One is that ts2ki can only 'plot' four items in any one indicator so it takes two indicators to fully plot Avery's Buy/Sell Zone. Another problem comes from the data feeds that we use. We really don't have a fixed session 'open' value that can be used as the starting index for calculations. And as the FX is 'open' 24/5+ there are 5 day changes where the hour value goes from 2400 to 0000. Also, we need to somehow deal with the 'nightly maintenance' data gap.

I've addressed these problem in the following way - I run one indicator code on a tick chart set to plot the open of the first tick of the hour. This indicator only plots the open value. This value is passed via a global memory variable to three other indicators. One uses this 'open' value to calculate and plot the Buy/Sell Zones on the same tick chart. The other two indicators use the value to calculate and plot the 'open', 'buy' and 'sell' zones on a 5 min chart. Make sure that your computer clock is set and correct. "Atomic" clock works well.

The 'nightly maintenance' issue just has to be lived with. However, one can determine when this takes place so as to lessen the impact. 12 midnight GMT seems to be a rather slow period - the plot is made but its a couple of minutes off. Then at 0100 its ploted correctly again.

As I only trade the GBP and the JPY this means four charts - two tick and two 5 min charts - which fit well on my dual monitor setup. With one monitor you could make a couple of 'workspaces' and just click between the two.

If your interested I'll post the code that I use.

BJ

BlackJack
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Wed May 31, 2006 2:13 am
Reputation: 0
Gender: Male

Postby BlackJack » Wed Jan 23, 2008 10:59 am

obx wrote:Is there an eld that automatically resets each new bar? Thx


Hi Obx,

We, those of us that still use ts2ki, have a couple of problems that don't seem to be an issue with other platforms. One is that ts2ki can only 'plot' four items in any one indicator so it takes two indicators to fully plot Avery's Buy/Sell Zone. Another problem comes from the data feeds that we use. We really don't have a fixed session 'open' value that can be used as the starting index for calculations. And as the FX is 'open' 24/5+ there are 5 day changes where the hour value goes from 2400 to 0000. Also, we need to somehow deal with the 'nightly maintenance' data gap.

I've addressed these problem in the following way - I run one indicator code on a tick chart set to plot the open of the first tick of the hour. This indicator only plots the open value. This value is passed via a global memory variable to three other indicators. One uses this 'open' value to calculate and plot the Buy/Sell Zones on the same tick chart. The other two indicators use the value to calculate and plot the 'open', 'buy' and 'sell' zones on a 5 min chart. Make sure that your computer clock is set and correct. "Atomic" clock works well.

The 'nightly maintenance' issue just has to be lived with. However, one can determine when this takes place so as to lessen the impact. 12 midnight GMT seems to be a rather slow period - the plot is made but its a couple of minutes off. Then at 0100 its ploted correctly again.

As I only trade the GBP and the JPY this means four charts - two tick and two 5 min charts - which fit well on my dual monitor setup. With one monitor you could make a couple of 'workspaces' and just click between the two.

If your interested I'll post the code that I use.

BJ

BlackJack
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Wed May 31, 2006 2:13 am
Reputation: 0
Gender: Male

Postby BlackJack » Wed Jan 23, 2008 11:00 am

obx wrote:Is there an eld that automatically resets each new bar? Thx


Hi Obx,

We, those of us that still use ts2ki, have a couple of problems that don't seem to be an issue with other platforms. One is that ts2ki can only 'plot' four items in any one indicator so it takes two indicators to fully plot Avery's Buy/Sell Zone. Another problem comes from the data feeds that we use. We really don't have a fixed session 'open' value that can be used as the starting index for calculations. And as the FX is 'open' 24/5+ there are 5 day changes where the hour value goes from 2400 to 0000. Also, we need to somehow deal with the 'nightly maintenance' data gap.

I've addressed these problem in the following way - I run one indicator code on a tick chart set to plot the open of the first tick of the hour. This indicator only plots the open value. This value is passed via a global memory variable to three other indicators. One uses this 'open' value to calculate and plot the Buy/Sell Zones on the same tick chart. The other two indicators use the value to calculate and plot the 'open', 'buy' and 'sell' zones on a 5 min chart. Make sure that your computer clock is set and correct. "Atomic" clock works well.

The 'nightly maintenance' issue just has to be lived with. However, one can determine when this takes place so as to lessen the impact. 12 midnight GMT seems to be a rather slow period - the plot is made but its a couple of minutes off. Then at 0100 its ploted correctly again.

As I only trade the GBP and the JPY this means four charts - two tick and two 5 min charts - which fit well on my dual monitor setup. With one monitor you could make a couple of 'workspaces' and just click between the two.

If your interested I'll post the code that I use.

BJ

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Wed Jan 23, 2008 3:08 pm

BlackJack wrote: If your interested I'll post the code that I use.

Sure BlackJack. Every little bit helps. :) Many thanks.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “beginners forum”