-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathTraderSmarts_Unofficial.cpp
More file actions
169 lines (154 loc) · 5.02 KB
/
TraderSmarts_Unofficial.cpp
File metadata and controls
169 lines (154 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "sierrachart.h"
SCDLLName("TraderSmarts Unofficial DLL")
SCString ReadTextFile(SCStudyInterfaceRef sc, SCString FileLocation)
{
char TextBuffer[1000] = {};
int FileHandle = 1;
unsigned int* p_BytesRead = new unsigned int(0);
sc.OpenFile(FileLocation.GetChars(), n_ACSIL::FILE_MODE_OPEN_EXISTING_FOR_SEQUENTIAL_READING, FileHandle);
sc.ReadFile(FileHandle, TextBuffer, 1000, p_BytesRead);
sc.CloseFile(FileHandle);
return TextBuffer;
}
SCSFExport scsf_TraderSmarts(SCStudyInterfaceRef sc)
{
int i = sc.Index;
SCInputRef Input_FileName = sc.Input[0];
if (sc.SetDefaults)
{
sc.GraphName = "TraderSmarts Unofficial";
sc.GraphRegion = 0;
sc.AutoLoop = 1;
Input_FileName.Name = "Filename to read";
Input_FileName.SetPathAndFileName("C:\\temp\\tradersmarts.txt");
return;
}
SCString PathAndFileName = Input_FileName.GetPathAndFileName();
SCString MyInputString("");
SCString w("");
float& fStart = sc.GetPersistentFloat(0);
float& fEnd = sc.GetPersistentFloat(1);
SCString& desc = sc.GetPersistentSCString(2);
if (sc.UpdateStartIndex == 0)
{
sc.AddMessageToLog("starting bro", 0);
if (MyInputString == "")
MyInputString.Format(ReadTextFile(sc, PathAndFileName));
std::vector<SCString> sLines;
MyInputString.ParseLines(sLines);
int idx = 1;
for (const SCString& ss : sLines)
{
if (strstr(ss, "MTS Numbers:"))
{
int i = ss.IndexOf(':');
SCString yy = ss.Right(ss.GetLength() - i - 2);
sc.AddMessageToLog(w.Format("MTS = |%s|", yy.GetChars()), 1);
std::vector<char*> tokens;
yy.Tokenize(", ", tokens);
for (SCString s : tokens)
{
fStart = std::stof(s.GetChars());
sc.AddMessageToLog(w.Format("Token = %f", fStart), 1);
s_UseTool Tool;
Tool.LineStyle = LINESTYLE_DASHDOTDOT;
Tool.TextAlignment = DT_RIGHT;
Tool.DrawingType = DRAWING_HORIZONTALLINE;
Tool.BeginValue = fStart;
Tool.EndValue = fStart;
Tool.ChartNumber = sc.ChartNumber;
Tool.BeginDateTime = sc.BaseDateTimeIn[0];
Tool.EndDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
Tool.AddMethod = UTAM_ADD_OR_ADJUST;
Tool.ShowPrice = 0;
Tool.Text.Format("MTS");
Tool.FontSize = 9;
Tool.LineWidth = 1;
Tool.LineNumber = idx;
Tool.Color = COLOR_GAINSBORO;
Tool.FontBold = true;
sc.UseTool(Tool);
idx++;
}
}
//sc.AddMessageToLog(ss, 0);
if (strstr(ss, "Sand") || strstr(ss, "Long") || strstr(ss, "Short"))
{
int id = ss.IndexOf('-');
if (id > 0)
{
int i = ss.IndexOf(' ');
if (i > 0)
{
// 20294.25 - 20283.25 Range Short
fStart = std::stof(ss.Left(i).GetChars());
int ix = ss.IndexOf(' ', i + 3);
SCString yy = ss.GetSubString(ix - i - 3, i + 3);
desc = ss.GetSubString(ss.GetLength() - ix - 2, ix + 1);
fEnd = std::stof(yy.GetChars());
sc.AddMessageToLog(w.Format("Split = %f, %f", fStart, fEnd), 1);
s_UseTool Tool;
Tool.LineStyle = LINESTYLE_DASHDOTDOT;
Tool.LineWidth = 1;
Tool.TransparencyLevel = 70;
Tool.TextAlignment = DT_RIGHT;
Tool.DrawingType = DRAWING_RECTANGLE_EXT_HIGHLIGHT;
Tool.BeginValue = fStart;
Tool.EndValue = fEnd;
Tool.ChartNumber = sc.ChartNumber;
Tool.BeginDateTime = sc.BaseDateTimeIn[0];
Tool.EndDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
Tool.AddMethod = UTAM_ADD_OR_ADJUST;
Tool.ShowPrice = 0;
Tool.Text.Format("%s", desc.GetChars());
Tool.FontSize = 9;
Tool.LineNumber = idx;
if (strstr(desc, "Sand"))
Tool.Color = COLOR_GAINSBORO;
else if (strstr(desc, "Short"))
Tool.Color = COLOR_RED;
else if (strstr(desc, "Long"))
Tool.Color = COLOR_LIME;
Tool.FontBold = true;
Tool.SecondaryColor = Tool.Color;
sc.UseTool(Tool);
}
}
else
{
int i = ss.IndexOf(' ');
if (i > 0)
{
fStart = std::stof(ss.Left(i).GetChars());
desc = ss.GetSubString(ss.GetLength() - i - 2, i + 1);
sc.AddMessageToLog(w.Format("%s = %f", desc.GetChars(), fStart), 1);
s_UseTool Tool;
Tool.LineStyle = LINESTYLE_DASHDOTDOT;
Tool.TextAlignment = DT_RIGHT;
Tool.DrawingType = DRAWING_HORIZONTALLINE;
Tool.BeginValue = fStart;
Tool.EndValue = fStart;
Tool.ChartNumber = sc.ChartNumber;
Tool.BeginDateTime = sc.BaseDateTimeIn[0];
Tool.EndDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
Tool.AddMethod = UTAM_ADD_OR_ADJUST;
Tool.ShowPrice = 0;
Tool.Text.Format("%s", desc.GetChars());
Tool.FontSize = 9;
Tool.LineWidth = 1;
Tool.LineNumber = idx;
if (strstr(desc, "Sand"))
Tool.Color = COLOR_GAINSBORO;
else if (strstr(desc, "Short"))
Tool.Color = COLOR_RED;
else if (strstr(desc, "Long"))
Tool.Color = COLOR_LIME;
Tool.FontBold = true;
sc.UseTool(Tool);
}
}
}
idx++;
}
}
}