@@ -44,6 +44,11 @@ public class ViewModel : INotifyPropertyChanged
44
44
public DelegateCommand CopyCloseCommand { get ; private set ; }
45
45
public DelegateCommand IndicatorCreateCommand { get ; private set ; }
46
46
public DelegateCommand IndicatorReleaseCommand { get ; private set ; }
47
+ public DelegateCommand iCustomCommand { get ; private set ; }
48
+ public DelegateCommand iBullsPowerCommand { get ; private set ; }
49
+ public DelegateCommand iBearsPowerCommand { get ; private set ; }
50
+ public DelegateCommand BarsCalculatedCommand { get ; private set ; }
51
+ public DelegateCommand CopyBufferCommand { get ; private set ; }
47
52
48
53
public DelegateCommand CopyTickVolumeCommand { get ; private set ; }
49
54
public DelegateCommand CopyRealVolumeCommand { get ; private set ; }
@@ -75,8 +80,6 @@ public class ViewModel : INotifyPropertyChanged
75
80
public DelegateCommand AlertCommand { get ; private set ; }
76
81
public DelegateCommand TesterStopCommand { get ; private set ; }
77
82
78
- public DelegateCommand iCustomCommand { get ; private set ; }
79
-
80
83
public DelegateCommand TimeCurrentCommand { get ; private set ; }
81
84
82
85
public DelegateCommand ChartOpenCommand { get ; private set ; }
@@ -354,6 +357,11 @@ private void InitCommands()
354
357
CopyCloseCommand = new DelegateCommand ( ExecuteCopyClose ) ;
355
358
IndicatorCreateCommand = new DelegateCommand ( ExecuteIndicatorCreate ) ;
356
359
IndicatorReleaseCommand = new DelegateCommand ( ExecuteIndicatorRelease ) ;
360
+ iCustomCommand = new DelegateCommand ( ExecuteICustom ) ;
361
+ iBullsPowerCommand = new DelegateCommand ( ExecuteIBullsPowerCommand ) ;
362
+ iBearsPowerCommand = new DelegateCommand ( ExecuteIBearsPowerCommand ) ;
363
+ BarsCalculatedCommand = new DelegateCommand ( ExecuteBarsCalculatedCommand ) ;
364
+ CopyBufferCommand = new DelegateCommand ( ExecuteCopyBufferCommand ) ;
357
365
358
366
CopyTickVolumeCommand = new DelegateCommand ( ExecuteCopyTickVolume ) ;
359
367
CopyRealVolumeCommand = new DelegateCommand ( ExecuteCopyRealVolume ) ;
@@ -385,8 +393,6 @@ private void InitCommands()
385
393
ResetLastErrorCommand = new DelegateCommand ( ExecuteResetLastError ) ;
386
394
TesterStopCommand = new DelegateCommand ( ExecuteTesterStop ) ;
387
395
388
- iCustomCommand = new DelegateCommand ( ExecuteICustom ) ;
389
-
390
396
ChartOpenCommand = new DelegateCommand ( ExecuteChartOpen ) ;
391
397
ChartTimePriceToXYCommand = new DelegateCommand ( ExecuteChartTimePriceToXY ) ;
392
398
ChartXYToTimePriceCommand = new DelegateCommand ( ExecuteChartXYToTimePrice ) ;
@@ -806,6 +812,68 @@ private async void ExecuteIndicatorRelease(object o)
806
812
AddLog ( $ "IndicatorRelease [{ indicatorHandle } ]: result - { retVal } ") ;
807
813
}
808
814
815
+ private async void ExecuteICustom ( object o )
816
+ {
817
+ const string name = @"Examples\Custom Moving Average" ;
818
+ int [ ] parameters = { 0 , 21 , ( int ) ENUM_APPLIED_PRICE . PRICE_CLOSE } ;
819
+
820
+ var retVal = await Execute ( ( ) => _mtApiClient . iCustom ( TimeSeriesValues . SymbolValue , TimeSeriesValues . TimeFrame , name , parameters ) ) ;
821
+ TimeSeriesValues . IndicatorHandle = retVal ;
822
+ AddLog ( $ "Custom Moving Average: result - { retVal } ") ;
823
+ }
824
+
825
+ private async void ExecuteIBullsPowerCommand ( object o )
826
+ {
827
+ const int maPeriod = 13 ;
828
+ var retVal = await Execute ( ( ) => _mtApiClient . iBullsPower ( TimeSeriesValues . SymbolValue , TimeSeriesValues . TimeFrame , maPeriod ) ) ;
829
+ TimeSeriesValues . IndicatorHandle = retVal ;
830
+
831
+ AddLog ( $ "iBullPower: result - { retVal } ") ;
832
+ }
833
+
834
+ private async void ExecuteIBearsPowerCommand ( object o )
835
+ {
836
+ const int maPeriod = 13 ;
837
+ var retVal = await Execute ( ( ) => _mtApiClient . iBearsPower ( TimeSeriesValues . SymbolValue , TimeSeriesValues . TimeFrame , maPeriod ) ) ;
838
+ TimeSeriesValues . IndicatorHandle = retVal ;
839
+
840
+ AddLog ( $ "iBearsPower: result - { retVal } ") ;
841
+ }
842
+
843
+ private async void ExecuteBarsCalculatedCommand ( object o )
844
+ {
845
+ var retVal = await Execute ( ( ) => _mtApiClient . BarsCalculated ( TimeSeriesValues . IndicatorHandle ) ) ;
846
+
847
+ AddLog ( $ "BarsCalculated: result - { retVal } ") ;
848
+ }
849
+
850
+ private async void ExecuteCopyBufferCommand ( object o )
851
+ {
852
+ TimeSeriesResults . Clear ( ) ;
853
+
854
+ var result = await Execute ( ( ) =>
855
+ {
856
+ var count = _mtApiClient . CopyBuffer ( TimeSeriesValues . IndicatorHandle , 0 , TimeSeriesValues . StartPos , TimeSeriesValues . Count , out var values ) ;
857
+ return count > 0 ? values : null ;
858
+ } ) ;
859
+
860
+ if ( result == null )
861
+ {
862
+ AddLog ( "CopyRates: result is null" ) ;
863
+ return ;
864
+ }
865
+
866
+ RunOnUiThread ( ( ) =>
867
+ {
868
+ foreach ( var value in result )
869
+ {
870
+ TimeSeriesResults . Add ( $ "{ value : F6} ") ;
871
+ }
872
+ } ) ;
873
+
874
+ AddLog ( "CopyRates: success" ) ;
875
+ }
876
+
809
877
private async void ExecuteCopyRates ( object o )
810
878
{
811
879
if ( string . IsNullOrEmpty ( TimeSeriesValues ? . SymbolValue ) ) return ;
@@ -1177,17 +1245,6 @@ private void ExecuteTesterStop(object obj)
1177
1245
AddLog ( "TesterStop: executed." ) ;
1178
1246
}
1179
1247
1180
- private async void ExecuteICustom ( object o )
1181
- {
1182
- const string symbol = "EURUSD" ;
1183
- const ENUM_TIMEFRAMES timeframe = ENUM_TIMEFRAMES . PERIOD_H1 ;
1184
- const string name = @"Examples\Custom Moving Average" ;
1185
- int [ ] parameters = { 0 , 21 , ( int ) ENUM_APPLIED_PRICE . PRICE_CLOSE } ;
1186
-
1187
- var retVal = await Execute ( ( ) => _mtApiClient . iCustom ( symbol , timeframe , name , parameters ) ) ;
1188
- AddLog ( $ "Custom Moving Average: result - { retVal } ") ;
1189
- }
1190
-
1191
1248
private async void ExecuteTimeCurrent ( object o )
1192
1249
{
1193
1250
var retVal = await Execute ( ( ) => _mtApiClient . TimeCurrent ( ) ) ;
0 commit comments