NexusFi: Find Your Edge


Home Menu

 





Adding minutes to an hour in easylanguage


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one bnichols with 1 posts (0 thanks)
    2. looks_two onava with 1 posts (0 thanks)
    3. looks_3 furytrader with 1 posts (1 thanks)
    4. looks_4 garyfritz with 1 posts (0 thanks)
    1. trending_up 3,803 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Adding minutes to an hour in easylanguage

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

HI All,

Im trying to join a minutes parm with an hour par, For example. i want to join 1600 with 43 minutes = 1643 and use it as a parm. does anyone know how to do this.( i dont have the calctime function by the way)

many thanks

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
15 thanks
Bigger Wins or Fewer Losses?
15 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #2 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460

In PowerLanguage (knock off of EasyLanguage) I treat times as natural numbers (positive integers), so that if

Hours = 16

and

Minutes = 43

then

a time of 1643 becomes myTime = Hours*100 + Minutes.

Converting a time of 1643 to minutes, say,

value1 = intportion(myTime/100);
myMinutes = value1*60 +(myTime - value1*100);

Functions that use times (e.g. to place drawing objects) or convert to "ticks since some datum" don't seem to mind.

Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
furytrader's Avatar
 furytrader 
Lake Forest, IL USA
 
Experience: Intermediate
Platform: MultiCharts + CTS T4
Broker: Advantage Futures, IQFeed.net
Trading: YM, ES, EU, US, S
Posts: 153 since Jun 2011
Thanks Given: 109
Thanks Received: 147


A few years ago, I wrote the following EasyLanguage function called "addMinutes":

 
Code
Inputs: RefTime(numeric),RefMinutesToAdd(numeric);

Vars: vOriginalMinutes(0), vOriginalHours(0);
Vars: vTestMinutes(0);
Vars: vTempMinutes(0), vTempHours(0);
Vars: vNewMinutes(0), vNewHours(0);

vOriginalHours = IntPortion(RefTime/100);
vOriginalMinutes = Mod(RefTime,100);

vTestMinutes = vOriginalMinutes + RefMinutesToAdd;

If vTestMinutes <= 59 Then Begin 
   vNewMinutes = vTestMinutes;
   vNewHours = vOriginalHours;
End;

If vTestMinutes > 59 Then Begin 
   
   vTempMinutes = Mod(vTestMinutes,60);
   vTempHours = IntPortion(vTestMinutes/60);

   vNewMinutes = vTempMinutes;

   If vNewMinutes > 59 Then Begin 
      vNewMinutes = vNewMinutes - 60;
      vTempHours = vTempHours + 1;
   End;

   vNewHours = vOriginalHours + vTempHours;
   
   If vNewHours > 23 Then vNewHours = vNewHours - 24;

End;

AddMinutes = (vNewHours * 100) + vNewMinutes;
It takes as its inputs the original time (in standard EL military time format) and the number of minutes you want to add and returns the new time.

I think there are easier ways in EasyLanguage to do this ... but this works for me!

Reply With Quote
Thanked by:
  #4 (permalink)
garyfritz
Fort Collins, CO, United States
 
Posts: 2 since Oct 2012
Thanks Given: 0
Thanks Received: 1

TS has CalcTime(RefTime, MinuteChange) to do this.

And the code is trivially simple:

 
Code
CalcTime = MinutesToTime( TimeToMinutes( RefTime ) + MinuteChange ) ;

Reply With Quote




Last Updated on March 6, 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