mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-16 20:28:09 +00:00
Fixed Issue #4: Changed function iCustom to use request/respons pattern.
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
<Compile Include="OrderSelectSource.cs" />
|
||||
<Compile Include="Requests\GetOrderRequest.cs" />
|
||||
<Compile Include="Requests\GetOrdersRequest.cs" />
|
||||
<Compile Include="Requests\ICustomRequest.cs" />
|
||||
<Compile Include="Requests\OrderCloseByRequest.cs" />
|
||||
<Compile Include="Requests\OrderCloseRequest.cs" />
|
||||
<Compile Include="Requests\OrderDeleteRequest.cs" />
|
||||
@@ -87,6 +88,7 @@
|
||||
<Compile Include="Requests\RequestType.cs" />
|
||||
<Compile Include="Responses\GetOrderResponse.cs" />
|
||||
<Compile Include="Responses\GetOrdersResponse.cs" />
|
||||
<Compile Include="Responses\ICustomResponse.cs" />
|
||||
<Compile Include="Responses\OrderSendResponse.cs" />
|
||||
<Compile Include="Responses\ResponseBase.cs" />
|
||||
<Compile Include="SeriesIdentifier.cs" />
|
||||
|
||||
+42
-17
@@ -995,29 +995,54 @@ namespace MtApi
|
||||
|
||||
public double iCustom(string symbol, int timeframe, string name, int[] parameters, int mode, int shift)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbol, timeframe, name };
|
||||
int arraySize = parameters != null ? parameters.Length : 0;
|
||||
commandParameters.Add(arraySize);
|
||||
if (arraySize > 0)
|
||||
var response = SendRequest<ICustomResponse>(new ICustomRequest
|
||||
{
|
||||
commandParameters.AddRange(parameters);
|
||||
}
|
||||
commandParameters.Add(mode);
|
||||
commandParameters.Add(shift);
|
||||
|
||||
return SendCommand<double>(MtCommandType.iCustom, commandParameters);
|
||||
Symbol = symbol,
|
||||
Timeframe = timeframe,
|
||||
Name = name,
|
||||
Mode = mode,
|
||||
Shift = shift,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Int
|
||||
});
|
||||
return response != null ? response.Value : double.NaN;
|
||||
}
|
||||
|
||||
public double iCustom(string symbol, int timeframe, string name, double[] parameters, int mode, int shift)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbol, timeframe, name };
|
||||
int arraySize = parameters != null ? parameters.Length : 0;
|
||||
commandParameters.Add(arraySize);
|
||||
commandParameters.AddRange(parameters);
|
||||
commandParameters.Add(mode);
|
||||
commandParameters.Add(shift);
|
||||
//var commandParameters = new ArrayList { symbol, timeframe, name };
|
||||
//int arraySize = parameters != null ? parameters.Length : 0;
|
||||
//commandParameters.Add(arraySize);
|
||||
//commandParameters.AddRange(parameters);
|
||||
//commandParameters.Add(mode);
|
||||
//commandParameters.Add(shift);
|
||||
|
||||
return SendCommand<double>(MtCommandType.iCustom_d, commandParameters);
|
||||
//return SendCommand<double>(MtCommandType.iCustom_d, commandParameters);
|
||||
|
||||
var response = SendRequest<ICustomResponse>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = timeframe,
|
||||
Name = name,
|
||||
Mode = mode,
|
||||
Shift = shift,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Double
|
||||
});
|
||||
return response != null ? response.Value : double.NaN;
|
||||
}
|
||||
|
||||
public double iCustom(string symbol, int timeframe, string name, int mode, int shift)
|
||||
{
|
||||
var response = SendRequest<ICustomResponse>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = timeframe,
|
||||
Name = name,
|
||||
Mode = mode,
|
||||
Shift = shift
|
||||
});
|
||||
return response != null ? response.Value : double.NaN;
|
||||
}
|
||||
|
||||
public double iDeMarker(string symbol, int timeframe, int period, int shift)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace MtApi.Requests
|
||||
{
|
||||
public class ICustomRequest : RequestBase
|
||||
{
|
||||
public enum ParametersType
|
||||
{
|
||||
Int = 0,
|
||||
Double = 1,
|
||||
String = 2,
|
||||
Boolean = 3
|
||||
}
|
||||
|
||||
public string Symbol { get; set; }
|
||||
public int Timeframe { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Mode { get; set; }
|
||||
public int Shift { get; set; }
|
||||
public ArrayList Params { get; set; }
|
||||
public ParametersType ParamsType { get; set; }
|
||||
|
||||
public override RequestType RequestType
|
||||
{
|
||||
get { return RequestType.iCustom; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
OrderClose = 4,
|
||||
OrderCloseBy = 5,
|
||||
OrderDelete = 6,
|
||||
OrderModify = 7
|
||||
OrderModify = 7,
|
||||
iCustom = 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MtApi.Responses
|
||||
{
|
||||
public class ICustomResponse: ResponseBase
|
||||
{
|
||||
public double Value { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user