mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-23 07:38:13 +00:00
Issue #100: implemented second function SymbolInfoString (MT5)
This commit is contained in:
@@ -16,12 +16,13 @@ namespace MtApi5
|
|||||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ConvertToMtTime(DateTime time)
|
public static int ConvertToMtTime(DateTime? time)
|
||||||
{
|
{
|
||||||
var result = 0;
|
var result = 0;
|
||||||
if (time == DateTime.MinValue) return result;
|
if (time == null || time == DateTime.MinValue)
|
||||||
|
return result;
|
||||||
var tmpTime = new DateTime(1970, 1, 1);
|
var tmpTime = new DateTime(1970, 1, 1);
|
||||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,8 @@
|
|||||||
<Compile Include="Requests\RequestType.cs" />
|
<Compile Include="Requests\RequestType.cs" />
|
||||||
<Compile Include="Requests\OrderSendResult.cs" />
|
<Compile Include="Requests\OrderSendResult.cs" />
|
||||||
<Compile Include="Requests\Response.cs" />
|
<Compile Include="Requests\Response.cs" />
|
||||||
|
<Compile Include="Requests\SymbolInfoStringRequest.cs" />
|
||||||
|
<Compile Include="Requests\SymbolInfoStringResult.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
||||||
|
|||||||
+18
-1
@@ -1386,6 +1386,23 @@ namespace MtApi5
|
|||||||
return SendCommand<string>(Mt5CommandType.SymbolInfoString, commandParameters);
|
return SendCommand<string>(Mt5CommandType.SymbolInfoString, commandParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Returns the corresponding property of a specified symbol.
|
||||||
|
///</summary>
|
||||||
|
///<param name="symbolName">Symbol name.</param>
|
||||||
|
///<param name="propId">Identifier of a symbol property.</param>
|
||||||
|
///<param name="value">Variable of the string type receiving the value of the requested property.</param>
|
||||||
|
public bool SymbolInfoString(string symbolName, ENUM_SYMBOL_INFO_STRING propId, out string value)
|
||||||
|
{
|
||||||
|
var response = SendRequest<SymbolInfoStringResult>(new SymbolInfoStringRequest
|
||||||
|
{
|
||||||
|
SymbolName = symbolName,
|
||||||
|
PropId = propId
|
||||||
|
});
|
||||||
|
|
||||||
|
value = response?.StringVar;
|
||||||
|
return response?.RetVal ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///The function returns current prices of a specified symbol in a variable of the MqlTick type.
|
///The function returns current prices of a specified symbol in a variable of the MqlTick type.
|
||||||
@@ -1561,7 +1578,7 @@ namespace MtApi5
|
|||||||
///</returns>
|
///</returns>
|
||||||
public bool ChartTimePriceToXY(long chartId, int subWindow, DateTime? time, double price, out int x, out int y)
|
public bool ChartTimePriceToXY(long chartId, int subWindow, DateTime? time, double price, out int x, out int y)
|
||||||
{
|
{
|
||||||
var commandParameters = new ArrayList { chartId, subWindow, Mt5TimeConverter.ConvertToMtTime((DateTime)time), price };
|
var commandParameters = new ArrayList { chartId, subWindow, Mt5TimeConverter.ConvertToMtTime(time), price };
|
||||||
var str = SendCommand<string>(Mt5CommandType.ChartTimePriceToXY, commandParameters);
|
var str = SendCommand<string>(Mt5CommandType.ChartTimePriceToXY, commandParameters);
|
||||||
var res = false;
|
var res = false;
|
||||||
x = 0;
|
x = 0;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace MtApi5.Requests
|
|||||||
PositionOpen = 4,
|
PositionOpen = 4,
|
||||||
OrderCheck = 5,
|
OrderCheck = 5,
|
||||||
MarketBookGet = 6,
|
MarketBookGet = 6,
|
||||||
IndicatorCreate = 7
|
IndicatorCreate = 7,
|
||||||
|
SymbolInfoString = 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace MtApi5.Requests
|
||||||
|
{
|
||||||
|
internal class SymbolInfoStringRequest : RequestBase
|
||||||
|
{
|
||||||
|
public override RequestType RequestType => RequestType.SymbolInfoString;
|
||||||
|
|
||||||
|
public string SymbolName { get; set; }
|
||||||
|
public ENUM_SYMBOL_INFO_STRING PropId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace MtApi5.Requests
|
||||||
|
{
|
||||||
|
internal class SymbolInfoStringResult
|
||||||
|
{
|
||||||
|
public bool RetVal { get; set; }
|
||||||
|
public string StringVar { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Executable → Regular
+250
-237
@@ -705,8 +705,27 @@ int executeCommand()
|
|||||||
case 131: //IndicatorRelease
|
case 131: //IndicatorRelease
|
||||||
Execute_IndicatorRelease();
|
Execute_IndicatorRelease();
|
||||||
break;
|
break;
|
||||||
|
case 132: //GetLastError
|
||||||
|
Execute_GetLastError();
|
||||||
|
break;
|
||||||
|
case 143: //ResetLastError
|
||||||
|
Execute_ResetLastError();
|
||||||
|
break;
|
||||||
|
case 153: //TerminalInfoString
|
||||||
|
Execute_TerminalInfoString();
|
||||||
|
break;
|
||||||
|
case 204: //TerminalInfoInteger
|
||||||
|
Execute_TerminalInfoInteger();
|
||||||
|
break;
|
||||||
|
case 205: //TerminalInfoDouble
|
||||||
|
Execute_TerminalInfoDouble();
|
||||||
|
break;
|
||||||
|
case 236: //ChartApplyTemplate
|
||||||
|
Execute_ChartApplyTemplate();
|
||||||
|
break;
|
||||||
|
case 237: //ChartApplyTemplate
|
||||||
|
Execute_ChartSaveTemplate();
|
||||||
|
break;
|
||||||
case 241: //ChartOpen
|
case 241: //ChartOpen
|
||||||
Execute_ChartOpen();
|
Execute_ChartOpen();
|
||||||
break;
|
break;
|
||||||
@@ -722,36 +741,6 @@ int executeCommand()
|
|||||||
case 252: //ChartGetString
|
case 252: //ChartGetString
|
||||||
Execute_ChartGetString();
|
Execute_ChartGetString();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 236: //ChartApplyTemplate
|
|
||||||
Execute_ChartApplyTemplate();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 237: //ChartApplyTemplate
|
|
||||||
Execute_ChartSaveTemplate();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 153: //TerminalInfoString
|
|
||||||
Execute_TerminalInfoString();
|
|
||||||
break;
|
|
||||||
case 204: //TerminalInfoInteger
|
|
||||||
Execute_TerminalInfoInteger();
|
|
||||||
break;
|
|
||||||
case 205: //TerminalInfoDouble
|
|
||||||
Execute_TerminalInfoDouble();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 132: //GetLastError
|
|
||||||
Execute_GetLastError();
|
|
||||||
break;
|
|
||||||
case 143: //ResetLastError
|
|
||||||
Execute_ResetLastError();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Print("Unknown command type = ", commandType);
|
Print("Unknown command type = ", commandType);
|
||||||
sendVoidResponse(ExpertHandle, _response_error);
|
sendVoidResponse(ExpertHandle, _response_error);
|
||||||
@@ -5581,6 +5570,206 @@ void Execute_ResetLastError()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Execute_ChartOpen()
|
||||||
|
{
|
||||||
|
string symbol;
|
||||||
|
int timeframe;
|
||||||
|
StringInit(symbol, 100, 0);
|
||||||
|
|
||||||
|
if (!getStringValue(ExpertHandle, 0, symbol, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartOpen", "symbol", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getIntValue(ExpertHandle, 1, timeframe, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartOpen", "timeframe", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!sendLongResponse(ExpertHandle, ChartOpen(symbol, (ENUM_TIMEFRAMES)timeframe), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartOpen", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartFirst()
|
||||||
|
{
|
||||||
|
if (!sendLongResponse(ExpertHandle, ChartFirst(), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartFirst", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartNext()
|
||||||
|
{
|
||||||
|
long ChartId;
|
||||||
|
|
||||||
|
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartFirst", "ChartId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendLongResponse(ExpertHandle, ChartNext(ChartId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartFirst", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartSymbol()
|
||||||
|
{
|
||||||
|
long ChartId;
|
||||||
|
|
||||||
|
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartSymbol", "ChartId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendStringResponse(ExpertHandle, ChartSymbol(ChartId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartSymbol", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartApplyTemplate()
|
||||||
|
{
|
||||||
|
long ChartId;
|
||||||
|
string TemplateFileName;
|
||||||
|
StringInit(TemplateFileName, 100, 0);
|
||||||
|
|
||||||
|
|
||||||
|
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartApplyTemplate", "ChartId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getStringValue(ExpertHandle, 1, TemplateFileName, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartApplyTemplate", "TemplateFileName", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||||
|
|
||||||
|
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartApplyTemplate", _response_error);
|
||||||
|
}
|
||||||
|
ChartRedraw(ChartId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartSaveTemplate()
|
||||||
|
{
|
||||||
|
long ChartId;
|
||||||
|
string TemplateFileName;
|
||||||
|
StringInit(TemplateFileName, 100, 0);
|
||||||
|
|
||||||
|
|
||||||
|
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartSaveTemplate", "ChartId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getStringValue(ExpertHandle, 1, TemplateFileName, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartSaveTemplate", "TemplateFileName", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||||
|
|
||||||
|
if (!sendBooleanResponse(ExpertHandle, ChartSaveTemplate(ChartId, TemplateFileName), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartSaveTemplate", _response_error);
|
||||||
|
}
|
||||||
|
ChartRedraw(ChartId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_ChartGetString()
|
||||||
|
{
|
||||||
|
long ChartId;
|
||||||
|
int PropId;
|
||||||
|
|
||||||
|
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartGetString", "ChartId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getIntValue(ExpertHandle, 1, PropId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("ChartGetString", "PropId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendStringResponse(ExpertHandle, ChartGetString(ChartId, (ENUM_CHART_PROPERTY_STRING)PropId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("ChartGetString", _response_error);
|
||||||
|
}
|
||||||
|
ChartRedraw(ChartId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_TerminalInfoString()
|
||||||
|
{
|
||||||
|
int propertyId;
|
||||||
|
|
||||||
|
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("TerminalInfoString", "propertyId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendStringResponse(ExpertHandle, TerminalInfoString((ENUM_TERMINAL_INFO_STRING)propertyId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("TerminalInfoString", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_TerminalInfoInteger()
|
||||||
|
{
|
||||||
|
int propertyId;
|
||||||
|
|
||||||
|
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("TerminalInfoInteger", "propertyId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendIntResponse(ExpertHandle, TerminalInfoInteger((ENUM_TERMINAL_INFO_INTEGER)propertyId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("TerminalInfoInteger", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute_TerminalInfoDouble()
|
||||||
|
{
|
||||||
|
int propertyId;
|
||||||
|
|
||||||
|
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("TerminalInfoDouble", "propertyId", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendDoubleResponse(ExpertHandle, TerminalInfoDouble((ENUM_TERMINAL_INFO_DOUBLE)propertyId), _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("TerminalInfoDouble", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintParamError(string paramName)
|
void PrintParamError(string paramName)
|
||||||
{
|
{
|
||||||
Print("[ERROR] parameter: ", paramName);
|
Print("[ERROR] parameter: ", paramName);
|
||||||
@@ -5752,6 +5941,9 @@ string OnRequest(string json)
|
|||||||
case 7: //IndicatorCreate
|
case 7: //IndicatorCreate
|
||||||
response = ExecuteRequest_IndicatorCreate(jo);
|
response = ExecuteRequest_IndicatorCreate(jo);
|
||||||
break;
|
break;
|
||||||
|
case 8: //SymbolInfoString
|
||||||
|
response = ExecuteRequest_SymbolInfoString(jo);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
PrintFormat("%s [WARNING]: Unknown request type %d", __FUNCTION__, requestType);
|
PrintFormat("%s [WARNING]: Unknown request type %d", __FUNCTION__, requestType);
|
||||||
response = CreateErrorResponse(-1, "Unknown request type");
|
response = CreateErrorResponse(-1, "Unknown request type");
|
||||||
@@ -6072,211 +6264,6 @@ string ExecuteRequest_MarketBookGet(JSONObject *jo)
|
|||||||
return CreateSuccessResponse("Value", book_ja);
|
return CreateSuccessResponse("Value", book_ja);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Execute_ChartOpen()
|
|
||||||
{
|
|
||||||
string symbol;
|
|
||||||
int timeframe;
|
|
||||||
StringInit(symbol, 100, 0);
|
|
||||||
|
|
||||||
if (!getStringValue(ExpertHandle, 0, symbol, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartOpen", "symbol", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!getIntValue(ExpertHandle, 1, timeframe, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartOpen", "timeframe", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!sendLongResponse(ExpertHandle, ChartOpen(symbol, (ENUM_TIMEFRAMES)timeframe), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartOpen", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_ChartFirst()
|
|
||||||
{
|
|
||||||
if (!sendLongResponse(ExpertHandle, ChartFirst(), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartFirst", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_ChartNext()
|
|
||||||
{
|
|
||||||
long ChartId;
|
|
||||||
|
|
||||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartFirst", "ChartId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendLongResponse(ExpertHandle, ChartNext(ChartId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartFirst", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_ChartSymbol()
|
|
||||||
{
|
|
||||||
long ChartId;
|
|
||||||
|
|
||||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartSymbol", "ChartId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendStringResponse(ExpertHandle, ChartSymbol(ChartId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartSymbol", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Execute_ChartApplyTemplate()
|
|
||||||
{
|
|
||||||
long ChartId;
|
|
||||||
string TemplateFileName;
|
|
||||||
StringInit(TemplateFileName, 100, 0);
|
|
||||||
|
|
||||||
|
|
||||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartApplyTemplate", "ChartId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!getStringValue(ExpertHandle, 1, TemplateFileName, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartApplyTemplate", "TemplateFileName", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
|
||||||
|
|
||||||
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartApplyTemplate", _response_error);
|
|
||||||
}
|
|
||||||
ChartRedraw(ChartId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_ChartSaveTemplate()
|
|
||||||
{
|
|
||||||
long ChartId;
|
|
||||||
string TemplateFileName;
|
|
||||||
StringInit(TemplateFileName, 100, 0);
|
|
||||||
|
|
||||||
|
|
||||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartSaveTemplate", "ChartId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!getStringValue(ExpertHandle, 1, TemplateFileName, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartSaveTemplate", "TemplateFileName", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
|
||||||
|
|
||||||
if (!sendBooleanResponse(ExpertHandle, ChartSaveTemplate(ChartId, TemplateFileName), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartSaveTemplate", _response_error);
|
|
||||||
}
|
|
||||||
ChartRedraw(ChartId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Execute_ChartGetString()
|
|
||||||
{
|
|
||||||
long ChartId;
|
|
||||||
int PropId;
|
|
||||||
|
|
||||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartGetString", "ChartId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!getIntValue(ExpertHandle, 1, PropId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("ChartGetString", "PropId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendStringResponse(ExpertHandle, ChartGetString(ChartId, (ENUM_CHART_PROPERTY_STRING)PropId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("ChartGetString", _response_error);
|
|
||||||
}
|
|
||||||
ChartRedraw(ChartId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_TerminalInfoString()
|
|
||||||
{
|
|
||||||
int propertyId;
|
|
||||||
|
|
||||||
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("TerminalInfoString", "propertyId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendStringResponse(ExpertHandle, TerminalInfoString((ENUM_TERMINAL_INFO_STRING)propertyId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("TerminalInfoString", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Execute_TerminalInfoInteger()
|
|
||||||
{
|
|
||||||
int propertyId;
|
|
||||||
|
|
||||||
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("TerminalInfoInteger", "propertyId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendIntResponse(ExpertHandle, TerminalInfoInteger((ENUM_TERMINAL_INFO_INTEGER)propertyId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("TerminalInfoInteger", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute_TerminalInfoDouble()
|
|
||||||
{
|
|
||||||
int propertyId;
|
|
||||||
|
|
||||||
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
|
||||||
{
|
|
||||||
PrintParamError("TerminalInfoDouble", "propertyId", _error);
|
|
||||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendDoubleResponse(ExpertHandle, TerminalInfoDouble((ENUM_TERMINAL_INFO_DOUBLE)propertyId), _response_error))
|
|
||||||
{
|
|
||||||
PrintResponseError("TerminalInfoDouble", _response_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string ExecuteRequest_IndicatorCreate(JSONObject *jo)
|
string ExecuteRequest_IndicatorCreate(JSONObject *jo)
|
||||||
{
|
{
|
||||||
//Symbol
|
//Symbol
|
||||||
@@ -6344,6 +6331,32 @@ string ExecuteRequest_IndicatorCreate(JSONObject *jo)
|
|||||||
return CreateSuccessResponse("Value", new JSONNumber(indicator_handle));
|
return CreateSuccessResponse("Value", new JSONNumber(indicator_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string ExecuteRequest_SymbolInfoString(JSONObject *jo)
|
||||||
|
{
|
||||||
|
CHECK_JSON_VALUE(jo, "SymbolName", CreateErrorResponse(-1, "Undefinded mandatory parameter SymbolName"));
|
||||||
|
string symbol_name = jo.getString("SymbolName");
|
||||||
|
|
||||||
|
CHECK_JSON_VALUE(jo, "PropId", CreateErrorResponse(-1, "Undefinded mandatory parameter PropId"));
|
||||||
|
ENUM_SYMBOL_INFO_STRING prop_id = (ENUM_SYMBOL_INFO_STRING) jo.getInt("PropId");
|
||||||
|
|
||||||
|
#ifdef __DEBUG_LOG__
|
||||||
|
PrintFormat("%s: symbol_name = %s, prop_id = %s", __FUNCTION__, symbol_name, EnumToString(prop_id));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
string string_var;
|
||||||
|
bool ok = SymbolInfoString(symbol_name, prop_id, string_var);
|
||||||
|
|
||||||
|
#ifdef __DEBUG_LOG__
|
||||||
|
PrintFormat("%s: ok = %s, string_var = %s", __FUNCTION__, BoolToString(ok), string_var);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
JSONObject* result_value_jo = new JSONObject();
|
||||||
|
result_value_jo.put("RetVal", new JSONBool(ok));
|
||||||
|
result_value_jo.put("StringVar", new JSONString(string_var));
|
||||||
|
|
||||||
|
return CreateSuccessResponse("Value", result_value_jo);
|
||||||
|
}
|
||||||
|
|
||||||
//------------ Events -------------------------------------------------------
|
//------------ Events -------------------------------------------------------
|
||||||
|
|
||||||
enum MtEventTypes
|
enum MtEventTypes
|
||||||
|
|||||||
Reference in New Issue
Block a user