|
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.
|
|