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 3,224 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 
phantomtrader's Avatar
 phantomtrader 
New York City, New York
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader
Trading: ES, NQ
Frequency: Daily
Duration: Minutes
Posts: 613 since May 2011
Thanks Given: 231
Thanks Received: 1,029


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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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 X Reply With Quote




Last Updated on May 12, 2013


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