Login Page - Create Account

Support Board


Date/Time: Wed, 19 Mar 2025 07:52:21 +0000



Post From: ACSIL - file in use after closing it

[2022-10-17 12:55:44]
tomna1993 - Posts: 24
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// READ PARAMETERS FROM CHART FOR LOGGING AND CREATE LOG FILE WITH HEADER
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(r_ExportData == 1)
    {
      // Get chart bar period in seconds

      n_ACSIL::s_BarPeriod BarPeriod;
      sc.GetBarPeriodParameters(BarPeriod);
      if (BarPeriod.ChartDataType == INTRADAY_DATA && BarPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS)
        Log_TimeFrame = BarPeriod.IntradayChartBarPeriodParameter1;

      //--------------------------------------------------------------------
      // Get chart symbol
      Log_Symbol = sc.GetChartSymbol(sc.ChartNumber);

      //--------------------------------------------------------------------
      // Open log file for logging, if file not found create a new file
      int FileHandle;
      if(!sc.OpenFile(Input_LogPath.GetPathAndFileName(), n_ACSIL::FILE_MODE_OPEN_EXISTING_FOR_SEQUENTIAL_READING, FileHandle))
      {
        sc.CloseFile(FileHandle);
        SCString TempString;
        //--------------------------------------------------------------------
        // Get subgraph names from signal and context study
        //--------------------------------------------------------------------
        LogDataToFile.Clear();
        TempString.Clear();
        //--------------------------------------------------------------------
        // Write log header
        LogDataToFile.Append("Symbol;Direction;Timeframe;OpenDate;OpenTime;CloseDate;CloseTime;BarsInTrade;Qty;Commission");
        LogDataToFile.Append(";Grid0;Grid100;IniStop;SignalSize(Tick);TickValue");
        LogDataToFile.Append(";OpenPrice;AvgClosePrice;AvgCloseGrid;IniRisk;PnL;RR;MinimumPrice;MinimumGrid;MaximumPrice;MaximumGrid");
        LogDataToFile.Append(";LastTargetReachedGrid;LastTargetReachedPrice;LastStopReachedGrid;LastStopReachedPrice");

        SCGraphData StudyData;

        sc.GetStudyArraysFromChartUsingID(sc.ChartNumber, Input_SignalStudy.GetStudyID(), StudyData);
        int ArraySize = StudyData.GetArraySize();

        for(r_LoopCount = 0; r_LoopCount < ArraySize; r_LoopCount++)
        {
          TempString = sc.GetStudySubgraphName(Input_SignalStudy.GetStudyID(), r_LoopCount);
          LogDataToFile.AppendFormat(";%s", TempString.GetChars());
        }

        sc.GetStudyArraysFromChartUsingID(Input_ContextStudy.GetChartNumber(), Input_ContextStudy.GetStudyID(), StudyData);
        ArraySize = StudyData.GetArraySize();

        for(r_LoopCount = 0; r_LoopCount < ArraySize; r_LoopCount++)
        {
          sc.GetStudySubgraphNameFromChart(Input_ContextStudy.GetChartNumber(), Input_ContextStudy.GetStudyID(), r_LoopCount, TempString);
          LogDataToFile.AppendFormat(";%s", TempString.GetChars());
        }

        LogDataToFile.Append("\n");

        SaveDataToLogFile(sc, Input_LogPath.GetPathAndFileName(), LogDataToFile);
    
        sc.AddMessageToLog("Create log file and header",0);
        LogDataToFile.Clear();
      }
    }