Click here to Login





                                                   Round to Step anyone?

  0

0
Jim Harrison
2014-03-02 21:19:15


Need something like this for universal use maybe a RoundStep function? like var1= RoundStep(value,step); or var1 = RoundStep(close[1],SymbolInfo.TickSize)

I spotted need in AMM for futures calcs. where one would desire a more precise value in real time to assist in the process to place a limit/stop order @ an indicator value, ie. a MOving average as an example.

In real time the "last" value is not always the value one needs.

WARNING: Ugly Pseudo Code below

Simple example of issue: SMA values for ES, NQ,etc. are often not divisible by 0.25. If I am setting real time limit order or stop order prices using any value other that one that is rounded to 0.25 increments, the order is rejected based on invalid limit/stop price.

// var =cFunctions.Close();
step = Data.GetSymbolInfo(NewPosition.Symbol).TickSize;
value = cFunctions.CompileFormula("a = SMA(14);").GetVectorDouble("a"); //could be anything here just easily replicate the issue with SMA. Depending on the value used in formulas, we often get return that is not divisible by 0.25(Tick Value ES/NQ,W,SI, etc.)

//Shared Function RoundTo(value As Double, step As Double) As Double;
//Return Math.Round(value / step) * step;
//End Function;

Thanks for any assistance.



QuantShare
2014-03-03 13:15:15

  0

In QS language you can use:

a = ceil(close / ticksize()) * ticksize(); // to get higher values (multiple of step)

Or

a = ceil(close / ticksize()) * ticksize(); // to get lower values (multiple of step)




Jim Harrison
2014-03-03 17:41:01

  1

Thanks,

I think you meant:

a = ceil(close / ticksize()) * ticksize(); // to get higher values (multiple of step)

Or

a = floor(close / ticksize()) * ticksize(); // to get lower values (multiple of step)

Will check it out, thanks.



QuantShare
2014-03-04 11:20:16

  0

yes, sorry


No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
SMA - ROC mask
Survivorship bias-free S&P 500 database downloader
Volume Accumulation Trend Line
Historical EOD data for LSE-listed Stocks and ETFs
Volume Trend Index - Market Indicator

How-to Lessons
How to optimize an indicator in your trading system
How to optimize the stop limit of a trading system
How to download new quotes when selecting a chart
How to plot a stock using different periods in the same chart
How to optimize the number of positions in a trading system

Related Forum Threads
Dynamic Watchlist update for each time step during a simulation?
How to download the trading software
Percent Rank Function Needed
quotes for inactive stocks
to write and execute an Indicator

Blog Posts
Step by step on how to get free realtime/delayed data for stocks,...
Composite Indicators
Create Realtime Quote Sheets with the Watchlist Tool
Export Trading Orders from a Portfolio to a File
Money Management: Optimize the scale-in strategy









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.