mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-16 12:18:09 +00:00
Issue #92: Added functions IndicatorCreate and IndicatorRelease
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlParam
|
||||
{
|
||||
public ENUM_DATATYPE DataType { get; set; }
|
||||
public long? IntegerValue { get; set; }
|
||||
public double? DoubleValue { get; set; }
|
||||
public string StringValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,8 @@ namespace MtApi5
|
||||
TimeCurrent = 127,
|
||||
TimeTradeServer = 128,
|
||||
TimeLocal = 129,
|
||||
TimeGMT = 130
|
||||
TimeGMT = 130,
|
||||
|
||||
IndicatorRelease = 131
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,4 +784,68 @@ namespace MtApi5
|
||||
}
|
||||
|
||||
#endregion //Smoothing Methods
|
||||
|
||||
#region Indicator constants
|
||||
|
||||
public enum ENUM_INDICATOR
|
||||
{
|
||||
IND_AC = 5, // Accelerator Oscillator
|
||||
IND_AD = 6, // Accumulation/Distribution
|
||||
IND_ADX = 8, // Average Directional Index
|
||||
IND_ADXW = 9, // ADX by Welles Wilder
|
||||
IND_ALLIGATOR = 7, // Alligator
|
||||
IND_AMA = 40, // Adaptive Moving Average
|
||||
IND_AO = 11, // Awesome Oscillator
|
||||
IND_ATR = 10, // Average True Range
|
||||
IND_BANDS = 13, // Bollinger Bands®
|
||||
IND_BEARS = 12, // Bears Power
|
||||
IND_BULLS = 14, // Bulls Power
|
||||
IND_BWMFI = 22, // Market Facilitation Index
|
||||
IND_CCI = 15, // Commodity Channel Index
|
||||
IND_CHAIKIN = 41, // Chaikin Oscillator
|
||||
IND_CUSTOM = 43, // Custom indicator
|
||||
IND_DEMA = 36, // Double Exponential Moving Average
|
||||
IND_DEMARKER = 16, // DeMarker
|
||||
IND_ENVELOPES = 17, // Envelopes
|
||||
IND_FORCE = 18, // Force Index
|
||||
IND_FRACTALS = 19, // Fractals
|
||||
IND_FRAMA = 39, // Fractal Adaptive Moving Average
|
||||
IND_GATOR = 20, // Gator Oscillator
|
||||
IND_ICHIMOKU = 21, // Ichimoku Kinko Hyo
|
||||
IND_MA = 26, // Moving Average
|
||||
IND_MACD = 23, // MACD
|
||||
IND_MFI = 25, // Money Flow Index
|
||||
IND_MOMENTUM = 24, // Momentum
|
||||
IND_OBV = 28, // On Balance Volume
|
||||
IND_OSMA = 27, // OsMA
|
||||
IND_RSI = 30, // Relative Strength Index
|
||||
IND_RVI = 31, // Relative Vigor Index
|
||||
IND_SAR = 29, // Parabolic SAR
|
||||
IND_STDDEV = 32, // Standard Deviation
|
||||
IND_STOCHASTIC = 33, // Stochastic Oscillator
|
||||
IND_TEMA = 37, // Triple Exponential Moving Average
|
||||
IND_TRIX = 38, // Triple Exponential Moving Averages Oscillator
|
||||
IND_VIDYA = 42, // Variable Index Dynamic Average
|
||||
IND_VOLUMES = 34, // Volumes
|
||||
IND_WPR = 35 // Williams' Percent Ranges
|
||||
}
|
||||
|
||||
public enum ENUM_DATATYPE
|
||||
{
|
||||
TYPE_BOOL = 1,
|
||||
TYPE_CHAR = 2,
|
||||
TYPE_UCHAR = 3,
|
||||
TYPE_SHORT = 4,
|
||||
TYPE_USHORT = 5,
|
||||
TYPE_COLOR = 6,
|
||||
TYPE_INT = 7,
|
||||
TYPE_UINT = 8,
|
||||
TYPE_DATETIME = 9,
|
||||
TYPE_LONG = 10,
|
||||
TYPE_ULONG = 11,
|
||||
TYPE_FLOAT = 12,
|
||||
TYPE_DOUBLE = 13,
|
||||
TYPE_STRING = 14
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CopyTicksFlag.cs" />
|
||||
<Compile Include="MqlBookInfo.cs" />
|
||||
<Compile Include="MqlParam.cs" />
|
||||
<Compile Include="MqlRates.cs" />
|
||||
<Compile Include="MqlTick.cs" />
|
||||
<Compile Include="MqlTradeCheckResult.cs" />
|
||||
@@ -68,6 +69,7 @@
|
||||
<Compile Include="Mt5Quote.cs" />
|
||||
<Compile Include="Requests\CopyTicksRequest.cs" />
|
||||
<Compile Include="Requests\ICustomRequest.cs" />
|
||||
<Compile Include="Requests\IndicatorCreateRequest.cs" />
|
||||
<Compile Include="Requests\MarketBookGetRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckResult.cs" />
|
||||
|
||||
@@ -1262,6 +1262,32 @@ namespace MtApi5
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the handle of a specified technical indicator created based on the array of parameters of MqlParam type.
|
||||
///</summary>
|
||||
///<param name="symbol">Name of a symbol, on data of which the indicator is calculated. NULL means the current symbol.</param>
|
||||
///<param name="period">The value of the timeframe can be one of values of the ENUM_TIMEFRAMES enumeration, 0 means the current timeframe.</param>
|
||||
///<param name="indicatorType">Indicator type, can be one of values of the ENUM_INDICATOR enumeration.</param>
|
||||
///<param name="parameters">An array of MqlParam type, whose elements contain the type and value of each input parameter of a technical indicator.</param>
|
||||
public int IndicatorCreate(string symbol, ENUM_TIMEFRAMES period, ENUM_INDICATOR indicatorType, List<MqlParam> parameters = null)
|
||||
{
|
||||
var response = SendRequest<int>(new IndicatorCreateRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Period = period,
|
||||
IndicatorType = indicatorType,
|
||||
Parameters = parameters
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
public bool IndicatorRelease(int indicatorHandle)
|
||||
{
|
||||
var commandParameters = new ArrayList { indicatorHandle };
|
||||
|
||||
return SendCommand<bool>(Mt5CommandType.IndicatorRelease, commandParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Market Info
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class IndicatorCreateRequest: RequestBase
|
||||
{
|
||||
public override RequestType RequestType => RequestType.IndicatorCreate;
|
||||
|
||||
public string Symbol { get; set; }
|
||||
public ENUM_TIMEFRAMES Period { get; set; }
|
||||
public ENUM_INDICATOR IndicatorType { get; set; }
|
||||
public List<MqlParam> Parameters { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace MtApi5.Requests
|
||||
OrderSend = 3,
|
||||
PositionOpen = 4,
|
||||
OrderCheck = 5,
|
||||
MarketBookGet = 6
|
||||
MarketBookGet = 6,
|
||||
IndicatorCreate = 7
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user