Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

januson

Januson Function Library

Recommended Posts

This is a collection of small and usefull functions from my library. I'll just post them as I write or review old ones :cool:

 

I'm using MultiCharts, but I'm almost sure that TradeStation users can compile them without any problems as both supports EasyLanguage.

 

***************************

Function: JK_Math_RoundToNearest

Just a small function from my library. I've discovered that RangeBars can give some funny open and closing values that needs to be comformed correct in order to write a pattern recognizer.

 

 

//FunctionName: JK_Math_RoundToNearest 
//Summary: A small function invented for rounding numbers to nearest precision i.e. round 100.27 to 100.25 or 95.86 to 95.75
//Author: Januson Nov2008, rev.0

//Example: JK_Math_RoundToNearest(100.58, 0.25) -> 100.50

inputs:
	valueToRound(NumericSimple),
	nearestFraction(NumericSimple);


begin

var:
	double PRECISION(10000); //constant



	JK_Math_RoundToNearest = IntPortion(valueToRound) + (round((fracportion(valueToRound)* PRECISION) /(nearestFraction * PRECISION), 0) * (nearestFraction * PRECISION))/PRECISION;

end;

 

Bump: When I develop indicators I need to have quick and easy access to debug information, i.e. Why is this value that at this point? I therefore insert JK_BarDateTime in the if-then or other points of interest.

 

Example from indicator:

if condition1 and condition5 then

begin

... yada yada

print(JK_BarDateTime, condition1, valueXX);

end;

 

I can then use the output window to track debug info quite easily :)

 

//FunctionName: JK_BarDateTime
//Summary: A function to convert the EasyLanguage datetime information from current bar
//Author: Januson Oct2008, rev.0

//Example: Print(JK_BarDateTime);

JK_BarDateTime = DateTimeToString(datetojulian(date) + ELTimeToDateTime_s(Time_s)) ;

Edited by januson

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.