NexusFi: Find Your Edge


Home Menu

 





Code to increment every two hours.


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one onava with 3 posts (0 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 SPMC with 1 posts (0 thanks)
    4. looks_4 ABCTG with 1 posts (0 thanks)
    1. trending_up 2,464 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Code to increment every two hours.

  #1 (permalink)
onava
London/England, Zurich/Switzerland
 
Posts: 20 since Apr 2012
Thanks Given: 2
Thanks Received: 1

HI all.

I was wondering how to i increment time to do something every 2 hours as easylanguage on has the function hour. I tried

if hour(t) > hour(t[2]) then
..

but that doesnt work. any ideas anyone ?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
phantomtrader's Avatar
 phantomtrader 
Reno, Nevada
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Trading: ZN, ZB, CL
Frequency: Daily
Duration: Minutes
Posts: 588 since May 2011
Thanks Given: 217
Thanks Received: 990


I have time limitations in my strategies although not as often as 2 hours. This is what I use:

Inputs: time1(630), time2 (930);

If time >= time1 and time <= time 2 then begin

Put conditions for trade here;

end;

Depending how many 2 hour periods you want segregated, you could repeat this process assigning new times i.e. time3, time4. It's almost like writing the same strategy multiple times unfortunately. There may be an easier way and you might also ask on the TS forum for help.

Reply With Quote
  #4 (permalink)
onava
London/England, Zurich/Switzerland
 
Posts: 20 since Apr 2012
Thanks Given: 2
Thanks Received: 1

i definitely dont want to repeat for every 2 hours the code below.. I think i need some kind of loop or something like below. can anyone help on this. thanks

for counter =0 to hour(t) = 24 then begin

( do stuff)

counter = counter +2;






phantomtrader View Post
I have time limitations in my strategies although not as often as 2 hours. This is what I use:

Inputs: time1(630), time2 (930);

If time >= time1 and time <= time 2 then begin

Put conditions for trade here;

end;

Depending how many 2 hour periods you want segregated, you could repeat this process assigning new times i.e. time3, time4. It's almost like writing the same strategy multiple times unfortunately. There may be an easier way and you might also ask on the TS forum for help.


Reply With Quote
  #5 (permalink)
onava
London/England, Zurich/Switzerland
 
Posts: 20 since Apr 2012
Thanks Given: 2
Thanks Received: 1

up




onava View Post
i definitely dont want to repeat for every 2 hours the code below.. I think i need some kind of loop or something like below. can anyone help on this. thanks

for counter =0 to hour(t) = 24 then begin

( do stuff)

counter = counter +2;


Reply With Quote
  #6 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213

You could use Mod, ie to plot a histogram every 2 hours on a 5 minute 24 h chart use :

If Mod(Time,200) = 0 then plot1 (1);

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

This might work for you, too:

 
Code
Inputs:
	ResetMinutes		(120);

Variables:
	ResetCounter		(0),
	NewResetTime		(0);

if Time > NewResetTime then
begin
	NewResetTime = TimeToMinutes(Time) + ResetMinutes;
	NewResetTime = MinutesToTime(NewResetTime);
	
	ResetCounter += 1;
end;

Plot1(ResetCounter, "ResetCounter");
Hope this helps,
ABCTG

Follow me on Twitter Reply With Quote




Last Updated on May 12, 2013


© 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