Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 00:37:41 +0000



Post From: Float value truncated / simplified.

[2020-08-21 17:33:48]
User92573 - Posts: 491
Dear Support / forum I'm struggling with a conversion.

Any assistance appreciated.

This is a typical example and what I'd like is the values displayed in the Tool Values Window on a bar by bar basis. As is the case with the current float value.



SCSFExport scsf_FloatToString(SCStudyInterfaceRef sc)
{

SCSubgraphRef Subgraph_Value1 = sc.Subgraph[0];
SCSubgraphRef Subgraph_Value2 = sc.Subgraph[1];

if (sc.SetDefaults)
{


Subgraph_Value1.Name = "Value 1";
Subgraph_Value1.DrawStyle = DRAWSTYLE_IGNORE;

Subgraph_Value2.Name = "Value 2";
Subgraph_Value2.DrawStyle = DRAWSTYLE_IGNORE;

Input_ATRLength.Name = "ATR Length";
Input_ATRLength.SetInt(10);

return;

}

// Do processing

// ATR example

sc.ATR(sc.BaseDataIn, Subgraph_ATR, Input_ATRLength.GetInt() - 1, MOVAVGTYPE_SIMPLE);


float atrOneBarAgo = 0.0f;
?string? strOneBarAgo = "0"; // I want the float value presented in this string variable to 1 or 2 places after the point (obviously the code here is incorrect also)


atrOneBarAgo = Subgraph_ATR[sc.Index - 1]; // for example is 1.1234
strOneBarAgo = "?atrOneBarAgo?"; // 1.1 or 1.12 is the outcome I'm trying to achieve


sc.Subgraph[0]= atrOneBarAgo;
sc.Subgraph[1]= strOneBarAgo;


}


Many thanks