Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 00:28:01 +0000



Post From: Access data using GDIFunction DrawToChart()

[2024-01-21 14:27:42]
User895355 - Posts: 55
Here is the main processing code. Since I'm running it on "Chart Replay", the crash happens when I stop the chart replay, the chart never recovers and crashes.


// Section 2 - Do data processing here
SCString msg;
int currentDate = sc.BaseDateTimeIn[sc.Index].GetDate();
int currentTime = sc.BaseDateTimeIn[sc.Index].GetTime();
SCDateTime currentBar = COMBINE_DATE_TIME(currentDate, currentTime);
SCDateTime newYorkStart = COMBINE_DATE_TIME(currentDate, HMS_TIME(9, 30, 0));
SCDateTime newYorkEnd = COMBINE_DATE_TIME(currentDate, HMS_TIME(16, 30, 0));
char rotationLetter = GetRotationLetter(sc);

if (currentBar < newYorkStart || currentBar > newYorkEnd)
return;
std::map<float, std::vector<char>, std::greater<float>> *tpoMap = (std::map<float, std::vector<char>, std::greater<float>> *)sc.GetPersistentPointer(sc.Input[0].GetInt());
std::map<float, std::vector<char>>::iterator it;

if (sc.LastCallToFunction || sc.IsFullRecalculation)
{
if (tpoMap != NULL)
{
/* sc.FreeMemory(tpoMap); */
delete tpoMap;
sc.SetPersistentPointer(sc.Input[0].GetInt(), NULL);
tpoMap = NULL;
}
return;
}
if (tpoMap == NULL)
{
tpoMap = new std::map<float, std::vector<char>, std::greater<float>>;
if (tpoMap != NULL)
sc.SetPersistentPointer(sc.Input[0].GetInt(), tpoMap);
else
return;
}

if (tpoMap != NULL)
{
it = tpoMap->find(sc.Close[sc.Index]);
if (it != tpoMap->end())
{
for (it = tpoMap->begin(); it != tpoMap->end(); it++)
{
std::vector<char> &charVector = it->second;

bool letterExists = false;
for (char c : charVector)
{
if (c == rotationLetter)
{
letterExists = true;
break;
}
}
if (!letterExists)
{
it->second.push_back(rotationLetter);
}
}
}
else
{
tpoMap->insert({sc.Close[sc.Index], std::vector<char>{rotationLetter}});
sc.SetPersistentPointer(sc.Input[0].GetInt(), tpoMap);
}
}

sc.p_GDIFunction = DrawToChart;
}

Date Time Of Last Edit: 2024-01-21 14:33:14