├── README.md
├── ExpertModify
├── Expert_NET.mq4
├── MyExpertAdvisor.mq4
└── include
│ ├── System_NET.mqh
│ └── System_NET_MQL.mqh
├── packages
├── HtmlAgilityPack.1.4.6
│ ├── HAPIcon.png
│ ├── HtmlAgilityPack.1.4.6.nupkg
│ ├── lib
│ │ ├── sl4
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── sl5
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── Net20
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── Net40
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── Net45
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── sl3-wp
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ ├── winrt45
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ ├── HtmlAgilityPack.pdb
│ │ │ └── HtmlAgilityPack.pri
│ │ ├── Net40-client
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ │ └── sl4-windowsphone71
│ │ │ ├── HtmlAgilityPack.dll
│ │ │ └── HtmlAgilityPack.pdb
│ ├── readme.txt
│ └── HtmlAgilityPack.1.4.6.nuspec
├── Quartz.2.1.1
│ ├── Quartz.2.1.1.nupkg
│ ├── lib
│ │ ├── net35
│ │ │ ├── Quartz.dll
│ │ │ └── Quartz.pdb
│ │ ├── net40
│ │ │ ├── Quartz.dll
│ │ │ └── Quartz.pdb
│ │ ├── net35-client
│ │ │ ├── Quartz.dll
│ │ │ └── Quartz.pdb
│ │ └── net40-client
│ │ │ ├── Quartz.dll
│ │ │ └── Quartz.pdb
│ └── Quartz.2.1.1.nuspec
├── Common.Logging.2.1.2
│ ├── Common.Logging.2.1.2.nupkg
│ ├── lib
│ │ ├── net35
│ │ │ ├── Common.Logging.dll
│ │ │ └── Common.Logging.pdb
│ │ └── net40
│ │ │ ├── Common.Logging.dll
│ │ │ └── Common.Logging.pdb
│ └── Common.Logging.2.1.2.nuspec
└── repositories.config
├── TradePlatform.NET 2.0.0.0 Beta
├── Shell_Backup
│ ├── Shell.exe
│ ├── MyFirstExpert.dll
│ ├── TradePlatform.MT4.Core.dll
│ ├── TradePlatform.MT4.Data.dll
│ ├── TradePlatform.MT4.SDK.API.dll
│ └── TradePlatform.MT4.SDK.Library.dll
└── Terminal
│ └── experts
│ ├── Expert_NET.ex4
│ ├── Expert_NET.mq4
│ ├── include
│ ├── Core_stdlib.mqh
│ ├── System_NET.mqh
│ ├── Core_WinUser32.mqh
│ ├── Core_stderror.mqh
│ ├── System_NET_API.mqh
│ ├── System_NET_MQL.mqh
│ └── System_NET_API_System.mqh
│ ├── scripts
│ ├── Script_NET.ex4
│ └── Script_NET.mq4
│ ├── libraries
│ └── Core_stdlib.ex4
│ └── indicators
│ ├── Indicator_NET.ex4
│ └── Indicator_NET.mq4
├── TradePlatform.MT4.CoreReferences
├── TradePlatform.MT4.Data.dll
└── Microsoft.Data.Services.dll
├── FXSharp.EA.NewsBox.Specs
├── packages.config
├── When_creating_magic_box.cs
├── When_generated_currency_pair.cs
├── OrderDetail.cs
├── When_calculate_lot_size.cs
├── When_trail_buy_profit.cs
├── When_trail_sell_profit.cs
├── Properties
│ └── AssemblyInfo.cs
├── When_decide_the_order_detail.cs
├── When_receive_economic_event_with_the_same_time_and_currency.cs
└── When_receive_all_economic_event_with_different_time.cs
├── FXSharp.EA.NewsBox
├── IOrderState.cs
├── EconomicCalendar
│ ├── IEconomicCalendar.cs
│ ├── EconomicCalendar.cs
│ ├── EconomicCalendarPool.cs
│ └── EconomicEvent.cs
├── packages.config
├── ICurrencyRepository.cs
├── Currency
│ ├── SpreadInfo.cs
│ ├── MajorRelatedPairsRepository.cs
│ ├── LowestSpreadsRelatedPairsRepository.cs
│ └── CurrencyRegistry.cs
├── MagicBoxConfig.cs
├── Scheduler
│ ├── DailyEconomicCalendarUpdateJob.cs
│ ├── MagicBoxOrderJob.cs
│ ├── DailyEconomicScheduler.cs
│ └── MagicBoxScheduler.cs
├── ExpiracyTimer.cs
├── OrderDecisionProcessor.cs
├── OrderState
│ ├── OrderAlreadyRunning.cs
│ └── MagicBoxCreated.cs
├── OrderWatcherPool.cs
├── Trailing
│ └── TrailingMethod.cs
├── Properties
│ └── AssemblyInfo.cs
├── MagicBoxOrder.cs
├── NewsReminder.cs
├── OrderWatcher.cs
└── OrderCreator.cs
├── FXSharp.EA.OrderManagements
├── IProfitProtector.cs
├── MoneyManagement.cs
├── ThreeLevelProfitProtector.cs
├── Properties
│ └── AssemblyInfo.cs
└── FXSharp.EA.OrderManagements.csproj
├── TradePlatform.MT4
├── TradePlatform.MT4.SDK
│ ├── TradePlatform.MT4.SDK.Win
│ │ ├── tradeplatform_favicon.ico
│ │ ├── Program.cs
│ │ └── Form1.cs
│ ├── TradePlatform.MT4.SDK.API
│ │ ├── Constants
│ │ │ ├── BAND_MODE.cs
│ │ │ ├── MACD_MODE.cs
│ │ │ ├── POOL_MODES.cs
│ │ │ ├── SELECT_BY.cs
│ │ │ ├── ADX_MODE.cs
│ │ │ ├── GATOR_MODE.cs
│ │ │ ├── MA_METHOD.cs
│ │ │ ├── ICHIMOKU_MODE.cs
│ │ │ ├── ORDER_TYPE.cs
│ │ │ ├── APPLY_PRICE.cs
│ │ │ ├── TIME_FRAME.cs
│ │ │ ├── SYMBOLS.cs
│ │ │ └── MARKER_INFO_MODE.cs
│ │ └── ObjectsFunction.cs
│ ├── TradePlatform.MT4.SDK.Shell
│ │ ├── tradeplatform_favicon.ico
│ │ └── Program.cs
│ ├── SharedAssemblyInfo.cs
│ ├── TradePlatform.MT4.SDK.Library
│ │ ├── Common
│ │ │ └── TickCounter.cs
│ │ ├── Handlers
│ │ │ ├── PerformanceCounterBase.cs
│ │ │ └── ExtendedExpertAdvisor.cs
│ │ ├── Scripts
│ │ │ ├── SendEmailScript.cs
│ │ │ ├── SmokeTestScript.cs
│ │ │ └── UnitTestScript.cs
│ │ ├── UnitTests
│ │ │ ├── CommonFunctionsTests.cs
│ │ │ ├── PredefinedVariablesTests.cs
│ │ │ ├── AccountInformationTests.cs
│ │ │ └── WindowFunctionsTests.cs
│ │ ├── Experts
│ │ │ └── MACrossExpert.cs
│ │ └── Indicators
│ │ │ └── PrevDayHighLowIndicator.cs
│ └── TradePlatform.MT4.SDK.sln
├── TradePlatform.MT4.Core
│ ├── MT4.Core
│ │ ├── Utils
│ │ │ ├── BridgeTraceErrorType.cs
│ │ │ ├── ExpertInfo.cs
│ │ │ ├── TraceInfo.cs
│ │ │ ├── MethodCallInfo.cs
│ │ │ ├── Convertor.cs
│ │ │ ├── ConsoleBridgeTraceListener.cs
│ │ │ └── BridgeTraceListener.cs
│ │ ├── Exceptions
│ │ │ ├── ConsoleTraceListenerException.cs
│ │ │ ├── HandlerLoadException.cs
│ │ │ ├── MqlErrorException.cs
│ │ │ ├── HandlerExecutionException.cs
│ │ │ └── MessageException.cs
│ │ ├── QuoterExtensions.cs
│ │ ├── Config
│ │ │ ├── ParameterElement.cs
│ │ │ ├── BridgeConfiguration.cs
│ │ │ ├── HandlerElement.cs
│ │ │ ├── HostElement.cs
│ │ │ ├── ParameterElementCollection.cs
│ │ │ ├── HostElementCollection.cs
│ │ │ └── HandlerElementCollection.cs
│ │ ├── Container_T_.cs
│ │ ├── QuoteListener.cs
│ │ ├── ExpertAdvisor.cs
│ │ ├── MqlHandler.cs
│ │ ├── Bridge.cs
│ │ └── MetaTrader4.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
└── TradePlatform.MT4.sln
├── MyFirstExpert
├── packages.config
└── Properties
│ └── AssemblyInfo.cs
├── FXSharp.EA.PinBar
├── IOrderManager.cs
├── StateManager
│ ├── NoOrderCreatedManager.cs
│ ├── PendingOrderCreatedManager.cs
│ └── OrderRunningManager.cs
├── Properties
│ └── AssemblyInfo.cs
├── FXSharp.EA.PinBar.csproj
└── PinBarEA.cs
├── FXSharp.EA.HappyDay
├── IOrderManager.cs
├── StateManager
│ ├── NoOrderCreatedManager.cs
│ ├── SecondOrderPendingManager.cs
│ ├── SecondOrderRunningManager.cs
│ ├── FirstOrderRunningManager.cs
│ └── BoxAlreadyCreatedManager.cs
└── Properties
│ └── AssemblyInfo.cs
├── FXSharp.TradingPlatform.Exts
├── MQLException.cs
├── PredefinedVariable
│ ├── Highs.cs
│ ├── Lows.cs
│ ├── Opens.cs
│ ├── Closes.cs
│ └── Times.cs
├── CheckupFunctions.cs
└── Properties
│ └── AssemblyInfo.cs
├── FXSharp.EA.FirstTest
├── SpreadInfo.cs
├── Quote.cs
├── Test
│ ├── ModifyStopTest.cs
│ ├── PendingBuyTest.cs
│ ├── BuyFunctionTest.cs
│ └── SellFunctionTest.cs
├── QuoteBeat.cs
├── Properties
│ └── AssemblyInfo.cs
├── CurrencyPairRegistry.cs
├── FXSharp.EA.FirstTest.csproj
└── MyExpertAdvisor.cs
├── FXSharp.EA.MagicBox
├── Properties
│ └── AssemblyInfo.cs
└── FXSharp.EA.MagicBox.csproj
└── .gitignore
/README.md:
--------------------------------------------------------------------------------
1 | forexsharp
2 | ==========
3 |
4 | object oriented mql with c#
--------------------------------------------------------------------------------
/ExpertModify/Expert_NET.mq4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/ExpertModify/Expert_NET.mq4
--------------------------------------------------------------------------------
/ExpertModify/MyExpertAdvisor.mq4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/ExpertModify/MyExpertAdvisor.mq4
--------------------------------------------------------------------------------
/ExpertModify/include/System_NET.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/ExpertModify/include/System_NET.mqh
--------------------------------------------------------------------------------
/ExpertModify/include/System_NET_MQL.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/ExpertModify/include/System_NET_MQL.mqh
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/HAPIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/HAPIcon.png
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/Quartz.2.1.1.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/Quartz.2.1.1.nupkg
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net35/Quartz.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net35/Quartz.dll
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net35/Quartz.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net35/Quartz.pdb
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net40/Quartz.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net40/Quartz.dll
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net40/Quartz.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net40/Quartz.pdb
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net35-client/Quartz.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net35-client/Quartz.dll
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net35-client/Quartz.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net35-client/Quartz.pdb
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net40-client/Quartz.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net40-client/Quartz.dll
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/lib/net40-client/Quartz.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Quartz.2.1.1/lib/net40-client/Quartz.pdb
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/Shell.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/Shell.exe
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/Common.Logging.2.1.2.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Common.Logging.2.1.2/Common.Logging.2.1.2.nupkg
--------------------------------------------------------------------------------
/TradePlatform.MT4.CoreReferences/TradePlatform.MT4.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.MT4.CoreReferences/TradePlatform.MT4.Data.dll
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/lib/net35/Common.Logging.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Common.Logging.2.1.2/lib/net35/Common.Logging.dll
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/lib/net35/Common.Logging.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Common.Logging.2.1.2/lib/net35/Common.Logging.pdb
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/lib/net40/Common.Logging.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Common.Logging.2.1.2/lib/net40/Common.Logging.dll
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/lib/net40/Common.Logging.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/Common.Logging.2.1.2/lib/net40/Common.Logging.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/HtmlAgilityPack.1.4.6.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/HtmlAgilityPack.1.4.6.nupkg
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl4/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl4/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl4/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl4/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl5/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl5/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl5/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl5/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/TradePlatform.MT4.CoreReferences/Microsoft.Data.Services.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.MT4.CoreReferences/Microsoft.Data.Services.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/MyFirstExpert.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/MyFirstExpert.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/Expert_NET.ex4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/Expert_NET.ex4
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/Expert_NET.mq4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/Expert_NET.mq4
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net20/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net20/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net20/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net20/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net40/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net40/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net40/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net40/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net45/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net45/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net45/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net45/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl3-wp/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl3-wp/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl3-wp/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl3-wp/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.pri:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/winrt45/HtmlAgilityPack.pri
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/IOrderState.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.NewsBox
2 | {
3 | public interface IOrderState
4 | {
5 | void Manage();
6 | void Cancel();
7 | }
8 | }
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net40-client/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net40-client/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/Net40-client/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/Net40-client/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/FXSharp.EA.OrderManagements/IProfitProtector.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.OrderManagements
2 | {
3 | public interface IProfitProtector
4 | {
5 | void TryProtectProfit();
6 | }
7 | }
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.Core.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.Data.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_stdlib.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_stdlib.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/scripts/Script_NET.ex4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/scripts/Script_NET.ex4
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/scripts/Script_NET.mq4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/scripts/Script_NET.mq4
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.SDK.API.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.SDK.API.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_WinUser32.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_WinUser32.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_stderror.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/Core_stderror.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_API.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_API.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_MQL.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_MQL.mqh
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/libraries/Core_stdlib.ex4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/libraries/Core_stdlib.ex4
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl4-windowsphone71/HtmlAgilityPack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl4-windowsphone71/HtmlAgilityPack.dll
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/lib/sl4-windowsphone71/HtmlAgilityPack.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/packages/HtmlAgilityPack.1.4.6/lib/sl4-windowsphone71/HtmlAgilityPack.pdb
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.SDK.Library.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Shell_Backup/TradePlatform.MT4.SDK.Library.dll
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/indicators/Indicator_NET.ex4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/indicators/Indicator_NET.ex4
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/indicators/Indicator_NET.mq4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/indicators/Indicator_NET.mq4
--------------------------------------------------------------------------------
/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_API_System.mqh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.NET 2.0.0.0 Beta/Terminal/experts/include/System_NET_API_System.mqh
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Win/tradeplatform_favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Win/tradeplatform_favicon.ico
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/BAND_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum BAND_MODE
4 | {
5 | MODE_UPPER = 1,
6 | MODE_LOWER = 2
7 | }
8 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/MACD_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum MACD_MODE
4 | {
5 | MODE_MAIN = 0,
6 | MODE_SIGNAL = 1,
7 | }
8 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Shell/tradeplatform_favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YifengL/forexsharp/HEAD/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Shell/tradeplatform_favicon.ico
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/POOL_MODES.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum POOL_MODES
4 | {
5 | MODE_TRADES = 0,
6 | MODE_HISTORY = 1,
7 | }
8 | }
--------------------------------------------------------------------------------
/MyFirstExpert/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/SELECT_BY.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum SELECT_BY
4 | {
5 | SELECT_BY_POS = 0,
6 | SELECT_BY_TICKET = 1,
7 | }
8 | }
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/IOrderManager.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.PinBar
2 | {
3 | internal interface IOrderManager
4 | {
5 | void OnNewBullishPinBar();
6 |
7 | void OnNewBearishPinBar();
8 |
9 | void OnTick();
10 | }
11 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/ADX_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum ADX_MODE
4 | {
5 | MODE_MAIN = 0,
6 | MODE_PLUSDI = 1,
7 | MODE_MINUSDI = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/GATOR_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum GATOR_MODE
4 | {
5 | MODE_GATORJAW = 0,
6 | MODE_GATORTEETH = 1,
7 | MODE_GATORLIPS = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/IOrderManager.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.HappyDay
2 | {
3 | public interface IOrderManager
4 | {
5 | //void OnNewBar();
6 |
7 | void OnTick();
8 |
9 | void OnLondonOpen();
10 |
11 | void OnNewYorkClose();
12 | }
13 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/MQLException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FXSharp.TradingPlatform.Exts
4 | {
5 | public class MQLException : ApplicationException
6 | {
7 | public MQLException(string message) : base(message)
8 | {
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/MA_METHOD.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum MA_METHOD
4 | {
5 | MODE_SMA = 0,
6 | MODE_EMA = 1,
7 | MODE_SMMA = 2,
8 | MODE_LWMA = 3
9 | }
10 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/EconomicCalendar/IEconomicCalendar.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | public interface IEconomicCalendar
7 | {
8 | Task> GetTodaysNextCriticalEventsAsync();
9 | }
10 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/ICurrencyRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | internal interface ICurrencyRepository
7 | {
8 | IEnumerable GetRelatedCurrencyPairs(EExpertAdvisor newsShooterEA, string currency);
9 | }
10 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/ICHIMOKU_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum ICHIMOKU_MODE
4 | {
5 | MODE_TENKANSEN = 1,
6 | MODE_KIJUNSEN = 2,
7 | MODE_SENKOUSPANA = 3,
8 | MODE_SENKOUSPANB = 4,
9 | MODE_CHINKOUSPAN = 5
10 | }
11 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/SpreadInfo.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.NewsBox
2 | {
3 | internal class SpreadInfo
4 | {
5 | public string Symbol { get; set; }
6 | public double Spread { get; set; }
7 |
8 | public override string ToString()
9 | {
10 | return string.Format("{0} : {1}", Symbol, Spread);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/BridgeTraceErrorType.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.Core.Utils
2 | {
3 | public enum BridgeTraceErrorType
4 | {
5 | Execption,
6 | HandlerExecutionError,
7 | MqlError,
8 | HostInfo,
9 | CommunicationWorkflow,
10 | Service,
11 | Debug
12 | }
13 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Currency/SpreadInfo.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.NewsBox
2 | {
3 | internal class SpreadInfo
4 | {
5 | public string Symbol { get; set; }
6 | public double Spread { get; set; }
7 |
8 | public override string ToString()
9 | {
10 | return string.Format("{0} : {1}", Symbol, Spread);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/ORDER_TYPE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum ORDER_TYPE
4 | {
5 | OP_BUY = 0,
6 | OP_SELL = 1,
7 | OP_BUYLIMIT = 2,
8 | OP_SELLLIMIT = 3,
9 | OP_BUYSTOP = 4,
10 | OP_SELLSTOP = 5,
11 | OP_DEPOSIT = 6,
12 | }
13 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/APPLY_PRICE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum APPLY_PRICE
4 | {
5 | PRICE_CLOSE = 0,
6 | PRICE_OPEN = 1,
7 | PRICE_HIGH = 2,
8 | PRICE_LOW = 3,
9 | PRICE_MEDIAN = 4,
10 | PRICE_TYPICAL = 5,
11 | PRICE_WEIGHTED = 6
12 | }
13 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/MagicBoxConfig.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.NewsBox
2 | {
3 | public class MagicBoxConfig
4 | {
5 | public double Range { get; set; }
6 |
7 | public double TakeProfit { get; set; }
8 |
9 | public double StopLoss { get; set; }
10 |
11 | public int MinuteExpiracy { get; set; }
12 |
13 | public int MinutePendingExecution { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Exceptions/ConsoleTraceListenerException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TradePlatform.MT4.Core.Exceptions
4 | {
5 | public class ConsoleTraceListenerException : Exception
6 | {
7 | public ConsoleTraceListenerException(object value, string message)
8 | : base(string.Format("{0} [Passed Value={1}", value, message))
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Quote.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.FirstTest
2 | {
3 | internal class Quote
4 | {
5 | public Quote(double bid, double ask)
6 | {
7 | Bid = bid;
8 | Ask = ask;
9 | Spread = (Ask - Bid)*10000;
10 | }
11 |
12 | public double Bid { get; set; }
13 |
14 | public double Ask { get; set; }
15 |
16 | public double Spread { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/PredefinedVariable/Highs.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.SDK.API;
2 |
3 | namespace FXSharp.TradingPlatform.Exts
4 | {
5 | public class Highs
6 | {
7 | private readonly EExpertAdvisor ea;
8 |
9 | public Highs(EExpertAdvisor ea)
10 | {
11 | this.ea = ea;
12 | }
13 |
14 | public double this[int i]
15 | {
16 | get { return ea.High(i); }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/PredefinedVariable/Lows.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.SDK.API;
2 |
3 | namespace FXSharp.TradingPlatform.Exts
4 | {
5 | public class Lows
6 | {
7 | private readonly EExpertAdvisor ea;
8 |
9 | public Lows(EExpertAdvisor ea)
10 | {
11 | this.ea = ea;
12 | }
13 |
14 | public double this[int i]
15 | {
16 | get { return ea.Low(i); }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/PredefinedVariable/Opens.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.SDK.API;
2 |
3 | namespace FXSharp.TradingPlatform.Exts
4 | {
5 | public class Opens
6 | {
7 | private readonly EExpertAdvisor ea;
8 |
9 | public Opens(EExpertAdvisor ea)
10 | {
11 | this.ea = ea;
12 | }
13 |
14 | public double this[int i]
15 | {
16 | get { return ea.Open(i); }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/PredefinedVariable/Closes.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.SDK.API;
2 |
3 | namespace FXSharp.TradingPlatform.Exts
4 | {
5 | public class Closes
6 | {
7 | private readonly EExpertAdvisor ea;
8 |
9 | public Closes(EExpertAdvisor ea)
10 | {
11 | this.ea = ea;
12 | }
13 |
14 | public double this[int i]
15 | {
16 | get { return ea.Close(i); }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/TIME_FRAME.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum TIME_FRAME
4 | {
5 | UserByChart = 0,
6 | PERIOD_M1 = 1,
7 | PERIOD_M5 = 5,
8 | PERIOD_M15 = 15,
9 | PERIOD_M30 = 30,
10 | PERIOD_H1 = 60,
11 | PERIOD_H4 = 240,
12 | PERIOD_D1 = 1440,
13 | PERIOD_W1 = 10080,
14 | PERIOD_MN1 = 43200,
15 | }
16 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Scheduler/DailyEconomicCalendarUpdateJob.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Quartz;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | public class DailyEconomicCalendarUpdateJob : IJob
7 | {
8 | public void Execute(IJobExecutionContext context)
9 | {
10 | var scheduler = (DailyEconomicScheduler) context.JobDetail.JobDataMap["scheduler"];
11 | Task task = scheduler.PrepareDailyReminder();
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/PredefinedVariable/Times.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.SDK.API;
3 |
4 | namespace FXSharp.TradingPlatform.Exts
5 | {
6 | public class Times
7 | {
8 | private readonly EExpertAdvisor ea;
9 |
10 | public Times(EExpertAdvisor ea)
11 | {
12 | this.ea = ea;
13 | }
14 |
15 | public DateTime this[int i]
16 | {
17 | get { return ea.Time(i); }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_creating_magic_box.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using NUnit.Framework;
3 |
4 | namespace FXSharp.EA.NewsBox.Specs
5 | {
6 | [TestFixture]
7 | public class When_creating_magic_box
8 | {
9 | [Test]
10 | public void Should_eliminate_duplicate_currency()
11 | {
12 | var decisionProcessor = new OrderDecisionProcessor();
13 | List result = decisionProcessor.GetTodayMagicBoxOrders().Result;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Currency/MajorRelatedPairsRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class MajorRelatedPairsRepository : ICurrencyRepository
8 | {
9 | public IEnumerable GetRelatedCurrencyPairs(EExpertAdvisor ea, string currency)
10 | {
11 | return CurrencyPairRegistry.RelatedMajorCurrencyPairsForMinimalSpread(ea, currency).Take(4);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Exceptions/HandlerLoadException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.Core.Utils;
3 |
4 | namespace TradePlatform.MT4.Core.Exceptions
5 | {
6 | internal class HandlerLoadException : Exception
7 | {
8 | public HandlerLoadException(ExpertInfo expertInfo, string reason, Exception innerException)
9 | : base(string.Format("Can't load handler: {0}. Failure Context: {1}", reason, expertInfo), innerException)
10 | {
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Scheduler/MagicBoxOrderJob.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using Quartz;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | public class MagicBoxOrderJob : IJob
7 | {
8 | public void Execute(IJobExecutionContext context)
9 | {
10 | var queues = (ConcurrentQueue) context.JobDetail.JobDataMap["queue"];
11 | var mbox = (MagicBoxOrder) context.JobDetail.JobDataMap["orders"];
12 |
13 | queues.Enqueue(mbox);
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Currency/LowestSpreadsRelatedPairsRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class LowestSpreadsRelatedPairsRepository : ICurrencyRepository
8 | {
9 | public IEnumerable GetRelatedCurrencyPairs(EExpertAdvisor ea, string currency)
10 | {
11 | return CurrencyPairRegistry.RelatedCurrencyPairsForMinimalSpread(ea, currency).Take(4);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/SharedAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region
2 |
3 | using System.Reflection;
4 |
5 | #endregion
6 |
7 | [assembly: AssemblyVersion("2.2.1.0")]
8 | [assembly: AssemblyFileVersion("2.2.1.0")]
9 | [assembly: AssemblyTitle("TradePlatform.MT4")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("TradePlatform.MT4")]
14 | [assembly: AssemblyCopyright("Copyright © 2012")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_generated_currency_pair.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using NUnit.Framework;
4 |
5 | namespace FXSharp.EA.NewsBox.Specs
6 | {
7 | [TestFixture]
8 | public class When_generated_currency_pair
9 | {
10 | [Test]
11 | public void Should_retrieve_all_currency_for_code()
12 | {
13 | //CurrencyPairRegistry a = new CurrencyPairRegistry();
14 |
15 | IEnumerable lists = CurrencyPairRegistry.RelatedCurrencyPairs("USD").Take(100);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Exceptions/MqlErrorException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.Core.Utils;
3 |
4 | namespace TradePlatform.MT4.Core.Exceptions
5 | {
6 | public class MqlErrorException : Exception
7 | {
8 | public MqlErrorException(ExpertInfo expertInfo, MethodCallInfo clientMethodInfo)
9 | : base(
10 | string.Format("MQL returned error: '{0}' for method {1}. Failure Context: {2}",
11 | clientMethodInfo.ErrorMessage, clientMethodInfo, expertInfo))
12 | {
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Exceptions/HandlerExecutionException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.Core.Utils;
3 |
4 | namespace TradePlatform.MT4.Core.Exceptions
5 | {
6 | internal class HandlerExecutionException : Exception
7 | {
8 | public HandlerExecutionException(ExpertInfo expertInfo, Exception innerException)
9 | : base(
10 | string.Format("Handler execution failed with error '{0}'. Failure Context: {1}", innerException.Message,
11 | expertInfo), innerException)
12 | {
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/QuoterExtensions.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.Core.Utils;
2 |
3 | namespace TradePlatform.MT4.Core
4 | {
5 | internal static class QuoterExtensions
6 | {
7 | internal static int AccountNumber(this QuoteListener nandler)
8 | {
9 | string str = nandler.CallMqlMethod("AccountNumber", null);
10 | return Convertor.ToInt(str);
11 | }
12 |
13 | internal static string Symbol(this QuoteListener handler)
14 | {
15 | string str = handler.CallMqlMethod("Symbol", null);
16 | return str;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/OrderDetail.cs:
--------------------------------------------------------------------------------
1 | //namespace FXSharp.EA.NewsBox.Specs
2 | //{
3 | // public class OrderDetail : IOrderDetail
4 | // {
5 | // //public double Bid { get; set; }
6 |
7 | // public double OpenPrice { get; set; }
8 |
9 | // public double StopLoss { get; set; }
10 |
11 | // public double Point { get; set; }
12 |
13 | // public void ModifyStopLoss(double lastProtectedPoint)
14 | // {
15 | // StopLoss = lastProtectedPoint;
16 | // }
17 |
18 | // //public double Ask { get; set; }
19 |
20 | // public double ProfitPoints { get; set; }
21 |
22 |
23 | // public int Digits { get; set; }
24 | // }
25 | //}
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Win/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace TradePlatform.MT4.SDK.Win
8 | {
9 | internal static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | private static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run( new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/Quartz.2.1.1/Quartz.2.1.1.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Quartz
5 | 2.1.1
6 | Marko Lahma
7 | Marko Lahma
8 | http://www.quartz-scheduler.net/
9 | false
10 | Quartz.NET Scheduling Framework for .NET Platform
11 | en-US
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/ParameterElement.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace TradePlatform.MT4.Core.Config
4 | {
5 | public class ParameterElement : ConfigurationElement
6 | {
7 | [ConfigurationProperty("propertyName", IsRequired = true, IsKey = true)]
8 | public string PropertyName
9 | {
10 | get { return base["propertyName"] as string; }
11 | set { base["propertyName"] = value; }
12 | }
13 |
14 | [ConfigurationProperty("propertyValue", IsRequired = true, IsKey = false)]
15 | public string PropertyValue
16 | {
17 | get { return base["propertyValue"] as string; }
18 | set { base["propertyValue"] = value; }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_calculate_lot_size.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using NUnit.Framework;
3 |
4 | namespace FXSharp.EA.NewsBox.Specs
5 | {
6 | [TestFixture]
7 | public class When_calculate_lot_size
8 | {
9 | [Test]
10 | public void Should_contain_risk_one_percent()
11 | {
12 | var moneyManagement = new MoneyManagement(1, 10000);
13 | double lot = moneyManagement.CalculateLotSize(400);
14 | Assert.AreEqual(0.25, lot);
15 | }
16 |
17 | [Test]
18 | public void Should_contain_risk_one_percent_smaller()
19 | {
20 | var moneyManagement = new MoneyManagement(1, 2000);
21 | double lot = moneyManagement.CalculateLotSize(200);
22 |
23 | Assert.AreEqual(0.1, lot);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/StateManager/NoOrderCreatedManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | namespace FXSharp.EA.PinBar
4 | {
5 | internal class NoOrderCreatedManager : IOrderManager
6 | {
7 | private readonly PinBarEA _ea;
8 |
9 | public NoOrderCreatedManager(PinBarEA pinBarEA)
10 | {
11 | _ea = pinBarEA;
12 | }
13 |
14 | public void OnNewBullishPinBar()
15 | {
16 | Order order = _ea.CreatePendingBuyOrder();
17 | _ea.MoveToPendingOrderCreatedState(order);
18 | }
19 |
20 | public void OnNewBearishPinBar()
21 | {
22 | Order order = _ea.CreatePendingSellOrder();
23 | _ea.MoveToPendingOrderCreatedState(order);
24 | }
25 |
26 | public void OnTick()
27 | {
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/packages/Common.Logging.2.1.2/Common.Logging.2.1.2.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Common.Logging
5 | 2.1.2
6 | Aleksandar Seovic, Mark Pollack, Erich Eichinger, Stephen Bohlen
7 | Aleksandar Seovic, Mark Pollack, Erich Eichinger, Stephen Bohlen
8 | http://netcommon.sourceforge.net/
9 | false
10 | Common.Logging library introduces a simple abstraction to allow you to select a specific logging implementation at runtime.
11 | en-US
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Common/TickCounter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using TradePlatform.MT4.Core.Utils;
4 | using TradePlatform.MT4.SDK.Library.Handlers;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.Common
7 | {
8 | public class TickCounter : PerformanceCounterBase
9 | {
10 | private DateTime _beginTime;
11 | private DateTime _endTime;
12 |
13 | protected override void Begin()
14 | {
15 | _beginTime = DateTime.Now;
16 | }
17 |
18 | protected override void End()
19 | {
20 | _endTime = DateTime.Now;
21 |
22 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Service,
23 | message: "Last tick time: " + (_endTime - _beginTime).TotalMilliseconds + " ms."));
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/ObjectsFunction.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.Core;
2 | using TradePlatform.MT4.Core.Utils;
3 |
4 | namespace TradePlatform.MT4.SDK.API
5 | {
6 | ///
7 | /// General-purpose functions not included into any specialized groups.
8 | ///
9 | public static class ObjectsFunction
10 | {
11 | ///
12 | /// Removes all objects of the specified type and in the specified sub-window of the chart.
13 | ///
14 | ///
15 | ///
16 | public static bool ObjectsDeleteAll(this MqlHandler handler)
17 | {
18 | string retrunValue = handler.CallMqlMethod("ObjectsDeleteAll", null);
19 |
20 | return Convertor.ToBoolean(retrunValue);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/ExpertInfo.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.Core.Utils
2 | {
3 | public sealed class ExpertInfo
4 | {
5 | public readonly string Discriminator;
6 | public readonly string HandlerName;
7 |
8 | public readonly MethodCallInfo MethodCallInfo;
9 |
10 | public ExpertInfo(string discriminator, string handlerName, MethodCallInfo methodCallInfo)
11 | {
12 | Discriminator = discriminator;
13 | HandlerName = handlerName;
14 | MethodCallInfo = methodCallInfo;
15 | }
16 |
17 | public override string ToString()
18 | {
19 | var handlerName = new object[]
20 | {"[HandlerName=", HandlerName, ", Discriminator=", Discriminator, "].", MethodCallInfo};
21 | return string.Concat(handlerName);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Handlers/PerformanceCounterBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using TradePlatform.MT4.Core;
4 |
5 | namespace TradePlatform.MT4.SDK.Library.Handlers
6 | {
7 | public abstract class PerformanceCounterBase : MqlHandler
8 | {
9 | protected abstract void Begin();
10 | protected abstract void End();
11 |
12 | protected override string ResolveMethod(string methodName, List parameters)
13 | {
14 | switch (methodName)
15 | {
16 | case "Begin":
17 | Begin();
18 | return "";
19 | case "End":
20 | End();
21 | return "";
22 | default:
23 | throw new Exception("No method found");
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/readme.txt:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | ---------- Html Agility Pack Nuget Readme ----------
3 | ----------------------------------------------------
4 |
5 | ----Silverlight 4 and Windows Phone 7.1+ projects-----
6 | To use XPATH features: System.Xml.Xpath.dll from the Silverlight 4 SDK must be referenced.
7 | This is normally found at
8 | %ProgramFiles(x86)%\Microsoft SDKs\Microsoft SDKs\Silverlight\v4.0\Libraries\Client
9 | or
10 | %ProgramFiles%\Microsoft SDKs\Microsoft SDKs\Silverlight\v4.0\Libraries\Client
11 |
12 | ----Silverlight 5 projects-----
13 | To use XPATH features: System.Xml.Xpath.dll from the Silverlight 5 SDK must be referenced.
14 | This is normally found at
15 | %ProgramFiles(x86)%\Microsoft SDKs\Microsoft SDKs\Silverlight\v5.0\Libraries\Client
16 | or
17 | %ProgramFiles%\Microsoft SDKs\Microsoft SDKs\Silverlight\v5.0\Libraries\Client
18 |
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/StateManager/NoOrderCreatedManager.cs:
--------------------------------------------------------------------------------
1 | namespace FXSharp.EA.HappyDay
2 | {
3 | internal class NoOrderCreatedManager : IOrderManager
4 | {
5 | private readonly HappyDayEA _ea;
6 |
7 | public NoOrderCreatedManager(HappyDayEA ea)
8 | {
9 | _ea = ea;
10 | }
11 |
12 | //public void OnNewBar()
13 | //{
14 | // _ea.CreatedMagicBoxFromPreviousCandle();
15 | // _ea.ChangeStateToBoxAlreadyCreated();
16 | //}
17 |
18 | public void OnTick()
19 | {
20 | //throw new NotImplementedException();
21 | }
22 |
23 | public void OnLondonOpen()
24 | {
25 | _ea.CreatedMagicBoxFromPreviousCandle();
26 | _ea.ChangeStateToBoxAlreadyCreated();
27 | }
28 |
29 | public void OnNewYorkClose()
30 | {
31 | //throw new System.NotImplementedException();
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Exceptions/MessageException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace TradePlatform.MT4.Core.Exceptions
6 | {
7 | internal class MessageException : Exception
8 | {
9 | public MessageException(string[] message, int minLenght, string formatSample)
10 | : base(
11 | string.Format(
12 | "Wrong message length. Expected minimum lenght: {0}, but actual lenght: {1}. Message was: '{2}', expected format: '{3}'",
13 | new object[] {minLenght, message.Length, ComputeArray(message), formatSample}))
14 | {
15 | }
16 |
17 | private static string ComputeArray(IEnumerable message)
18 | {
19 | string str = "";
20 | message.ToList().ForEach((string x) => str = string.Concat(str, x, "|"));
21 | return str;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/BridgeConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace TradePlatform.MT4.Core.Config
4 | {
5 | public class BridgeConfiguration : ConfigurationSection
6 | {
7 | [ConfigurationProperty("Hosts")]
8 | public HostElementCollection Hosts
9 | {
10 | get { return base["Hosts"] as HostElementCollection; }
11 | }
12 |
13 | [ConfigurationProperty("useEventLog", IsRequired = true, IsKey = true)]
14 | public bool UseEventLog
15 | {
16 | get { return (bool) base["useEventLog"]; }
17 | set { base["useEventLog"] = value; }
18 | }
19 |
20 | [ConfigurationProperty("wcfBaseAddress", IsRequired = true, IsKey = true)]
21 | public string WcfBaseAddress
22 | {
23 | get { return (string) base["wcfBaseAddress"]; }
24 | set { base["wcfBaseAddress"] = value; }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Test/ModifyStopTest.cs:
--------------------------------------------------------------------------------
1 | //using TradePlatform.MT4.Data;
2 |
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.FirstTest
6 | {
7 | public class ModifyStopTest : EExpertAdvisor
8 | {
9 | private int count;
10 | private Order order;
11 |
12 | protected override int Init()
13 | {
14 | order = Buy(0.1, Bid - 100*Point, Bid + 500*Point);
15 |
16 | return 1;
17 | }
18 |
19 | protected override int DeInit()
20 | {
21 | return 1;
22 | }
23 |
24 | protected override int Start()
25 | {
26 | count++;
27 |
28 | if (order == null)
29 | {
30 | Init();
31 | }
32 | else
33 | {
34 | order.ModifyStopLoss(Ask - (count*100*Point));
35 | }
36 |
37 | if (order.CloseInProfit())
38 | order = null;
39 | return 1;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Test/PendingBuyTest.cs:
--------------------------------------------------------------------------------
1 | //using TradePlatform.MT4.Data;
2 |
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.FirstTest
6 | {
7 | public class PendingBuyTest : EExpertAdvisor
8 | {
9 | private int count;
10 | private Order order;
11 |
12 | protected override int Init()
13 | {
14 | order = PendingBuy(0.1, Bid + 100*Point, Bid - 500*Point, Bid + 500*Point);
15 |
16 | return 1;
17 | }
18 |
19 | protected override int DeInit()
20 | {
21 | return 1;
22 | }
23 |
24 | protected override int Start()
25 | {
26 | count++;
27 |
28 | if (order == null)
29 | {
30 | Init();
31 | }
32 | else
33 | {
34 | order.ModifyStopLoss(Ask - (count*100*Point));
35 | }
36 |
37 | //if (order.CloseInProfit())
38 | // order = null;
39 | return 1;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Scripts/SendEmailScript.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 | using System.Net.Mail;
3 | using TradePlatform.MT4.Core;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.Scripts
7 | {
8 | public class SendEmailScript : ExpertAdvisor
9 | {
10 | protected override int Init()
11 | {
12 | return 1;
13 | }
14 |
15 | protected override int Start()
16 | {
17 | var mailMessage = new MailMessage();
18 | mailMessage.To.Add(new MailAddress(ConfigurationManager.AppSettings["NotifyToEmail"]));
19 | mailMessage.Subject = this.AccountName();
20 | mailMessage.Body = this.AccountProfit().ToString();
21 |
22 | var smtpClient = new SmtpClient();
23 | smtpClient.EnableSsl = true;
24 | smtpClient.Send(mailMessage);
25 |
26 | return 2;
27 | }
28 |
29 | protected override int DeInit()
30 | {
31 | return 3;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Test/BuyFunctionTest.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | //using TradePlatform.MT4.Data;
4 |
5 | namespace FXSharp.EA.FirstTest
6 | {
7 | public class BuyFunctionTest : EExpertAdvisor
8 | {
9 | private Order order;
10 | private int tickCount;
11 |
12 | protected override int Init()
13 | {
14 | order = Buy(0.1, Bid - 100*Point, Bid + 500*Point);
15 |
16 | return 1;
17 | }
18 |
19 | protected override int DeInit()
20 | {
21 | return 1;
22 | }
23 |
24 | protected override int Start()
25 | {
26 | tickCount++;
27 |
28 | if (tickCount != 10) return 1;
29 |
30 | if (order == null)
31 | {
32 | order = Buy(0.1, Bid - 100*Point, Bid + 500*Point);
33 | }
34 | else
35 | {
36 | order.Close();
37 | order = null;
38 | }
39 |
40 | tickCount = 0;
41 |
42 | return 1;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/FXSharp.EA.OrderManagements/MoneyManagement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FXSharp.EA.OrderManagements
4 | {
5 | // should be careful about margin level and margin call
6 | public class MoneyManagement
7 | {
8 | private readonly double balance;
9 | private readonly double riskExposure;
10 |
11 | public MoneyManagement(double riskExposure, double balance)
12 | {
13 | this.riskExposure = riskExposure;
14 | this.balance = balance;
15 | }
16 |
17 | private double RiskValue
18 | {
19 | get { return (riskExposure*balance)/100; }
20 | }
21 |
22 | private double ValuePerPips
23 | {
24 | get { return 10; }
25 | }
26 |
27 | // should check to pips calculator
28 |
29 | public double CalculateLotSize(double stopLoss)
30 | {
31 | return Math.Round(RiskValue/(ValuePerPips*Pips(stopLoss)), 2);
32 | }
33 |
34 | private double Pips(double point)
35 | {
36 | return point/10;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/SYMBOLS.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public static class SYMBOLS
4 | {
5 | public static string EURUSD
6 | {
7 | get { return "EURUSD"; }
8 | }
9 |
10 | public static string GBPUSD
11 | {
12 | get { return "GBPUSD"; }
13 | }
14 |
15 | public static string USDCHF
16 | {
17 | get { return "USDCHF"; }
18 | }
19 |
20 | public static string USDJPY
21 | {
22 | get { return "USDJPY"; }
23 | }
24 |
25 | public static string EURGBP
26 | {
27 | get { return "EURGBP"; }
28 | }
29 |
30 | public static string USDCAD
31 | {
32 | get { return "USDCAD"; }
33 | }
34 |
35 | public static string EURJPY
36 | {
37 | get { return "EURJPY"; }
38 | }
39 |
40 | public static string GBPJPY
41 | {
42 | get { return "GBPJPY"; }
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Test/SellFunctionTest.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | //using TradePlatform.MT4.Data;
4 |
5 | namespace FXSharp.EA.FirstTest
6 | {
7 | public class SellFunctionTest : EExpertAdvisor
8 | {
9 | private Order order;
10 | private int tickCount;
11 |
12 | protected override int Init()
13 | {
14 | order = Sell(0.1, Bid + 100*Point, Bid - 500*Point);
15 |
16 | return 1;
17 | }
18 |
19 |
20 | protected override int DeInit()
21 | {
22 | return 1;
23 | }
24 |
25 | protected override int Start()
26 | {
27 | tickCount++;
28 |
29 | if (tickCount != 10) return 1;
30 |
31 | if (order == null)
32 | {
33 | order = Sell(0.1, Bid + 100*Point, Bid - 500*Point);
34 | }
35 | else
36 | {
37 | order.Close();
38 | order = null;
39 | }
40 |
41 | tickCount = 0;
42 |
43 | return 1;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Currency/CurrencyRegistry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace FXSharp.EA.NewsBox
4 | {
5 | public static class CurrencyRegistry
6 | {
7 | private static readonly Dictionary countryToCurrency = new Dictionary
8 | {
9 | {"New Zealand", "NZD"},
10 | {"Australia", "AUD"},
11 | {"China", "CNY"},
12 | {"Japan", "JPY"},
13 | {"Switzerland", "CHF"},
14 | {"France", "EUR"},
15 | {"Spain", "EUR"},
16 | {"Italy", "EUR"},
17 | {"Portugal", "EUR"},
18 | {"Germany", "EUR"},
19 | {"Greece", "EUR"},
20 | {"United Kingdom", "GBP"},
21 | {"European Monetary Union", "EUR"},
22 | {"Canada", "CAD"},
23 | {"United States", "USD"}
24 | };
25 |
26 | internal static string ForCountry(string country)
27 | {
28 | return countryToCurrency[country];
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.API/Constants/MARKER_INFO_MODE.cs:
--------------------------------------------------------------------------------
1 | namespace TradePlatform.MT4.SDK.API
2 | {
3 | public enum MARKER_INFO_MODE
4 | {
5 | MODE_LOW = 1,
6 | MODE_HIGH = 2,
7 | MODE_TIME = 5,
8 | MODE_BID = 9,
9 | MODE_ASK = 10,
10 | MODE_POINT = 11,
11 | MODE_DIGITS = 12,
12 | MODE_SPREAD = 13,
13 | MODE_STOPLEVEL = 14,
14 | MODE_LOTSIZE = 15,
15 | MODE_TICKVALUE = 16,
16 | MODE_TICKSIZE = 17,
17 | MODE_SWAPLONG = 18,
18 | MODE_SWAPSHORT = 19,
19 | MODE_STARTING = 20,
20 | MODE_EXPIRATION = 21,
21 | MODE_TRADEALLOWED = 22,
22 | MODE_MINLOT = 23,
23 | MODE_LOTSTEP = 24,
24 | MODE_MAXLOT = 25,
25 | MODE_SWAPTYPE = 26,
26 | MODE_PROFITCALCMODE = 27,
27 | MODE_MARGINCALCMODE = 28,
28 | MODE_MARGININIT = 29,
29 | MODE_MARGINMAINTENANCE = 30,
30 | MODE_MARGINHEDGED = 31,
31 | MODE_MARGINREQUIRED = 32,
32 | MODE_FREEZELEVEL = 33,
33 | }
34 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/QuoteBeat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FXSharp.EA.FirstTest
4 | {
5 | internal class QuoteBeat
6 | {
7 | private Quote prev;
8 |
9 | public QuoteBeat()
10 | {
11 | MaxDown = 1;
12 | MaxUp = -1;
13 | }
14 |
15 | public double DeltaAsk { get; set; }
16 |
17 | public double DeltaBid { get; set; }
18 |
19 | public double MaxDown { get; set; }
20 |
21 | public double MaxUp { get; set; }
22 |
23 | public double LastDelta { get; set; }
24 |
25 | internal void Add(Quote quote)
26 | {
27 | if (prev == null)
28 | {
29 | prev = quote;
30 | return;
31 | }
32 |
33 | DeltaAsk = (quote.Ask*100000 - prev.Ask*100000)/10;
34 | DeltaBid = (quote.Bid*100000 - prev.Bid*100000)/10;
35 |
36 | LastDelta = Math.Max(DeltaAsk, DeltaBid);
37 |
38 | MaxUp = Math.Max(LastDelta, MaxUp);
39 | MaxDown = Math.Min(LastDelta, MaxDown);
40 |
41 | prev = quote;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/ExpiracyTimer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Timers;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | internal class ExpiracyTimer
7 | {
8 | private readonly Timer timers = new Timer();
9 |
10 | public ExpiracyTimer(double expiredTime)
11 | {
12 | timers = new Timer();
13 | timers.AutoReset = false;
14 | timers.Interval = expiredTime*MINUTE;
15 | timers.Elapsed += timers_Elapsed;
16 | timers.Start();
17 | }
18 |
19 | private int MINUTE
20 | {
21 | get { return 60*SECONDS; }
22 | }
23 |
24 | private int SECONDS
25 | {
26 | get { return 1000; }
27 | }
28 |
29 | public event EventHandler Expired;
30 |
31 | private void timers_Elapsed(object sender, ElapsedEventArgs e)
32 | {
33 | if (Expired == null) return;
34 | Expired(this, EventArgs.Empty);
35 | }
36 |
37 | internal void Finish()
38 | {
39 | timers.Stop();
40 | timers.Dispose();
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Scheduler/DailyEconomicScheduler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 | using Quartz;
6 |
7 | namespace FXSharp.EA.NewsBox
8 | {
9 | public class DailyEconomicScheduler
10 | {
11 | private readonly OrderDecisionProcessor _decisionProcessor = new OrderDecisionProcessor();
12 | // currently using polling model, next publish
13 |
14 | private readonly MagicBoxScheduler _scheduler;
15 |
16 | public DailyEconomicScheduler(IScheduler scheduler, ConcurrentQueue queues)
17 | {
18 | this._scheduler = new MagicBoxScheduler(scheduler, queues);
19 | }
20 |
21 | public async Task PrepareDailyReminder()
22 | {
23 | var magicBoxes = await _decisionProcessor.GetTodayMagicBoxOrders();
24 |
25 | foreach (var order in magicBoxes)
26 | {
27 | Console.WriteLine("Scheduled : {0} @ {1}", order.Symbol, order.ExecutingTime);
28 | _scheduler.Schedule(order);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Container_T_.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace TradePlatform.MT4.Core
5 | {
6 | public abstract class Container
7 | where T : new()
8 | {
9 | private static Dictionary _storage;
10 |
11 | static Container()
12 | {
13 | _storage = new Dictionary();
14 | }
15 |
16 | public static T GetOrCreate(string key)
17 | {
18 | T t;
19 | if (!_storage.ContainsKey(key))
20 | {
21 | T t1 = default(T);
22 | if (t1 == null)
23 | {
24 | t = Activator.CreateInstance();
25 | }
26 | else
27 | {
28 | T t2 = default(T);
29 | t = t2;
30 | }
31 | T t3 = t;
32 | _storage.Add(key, t3);
33 | return t3;
34 | }
35 | else
36 | {
37 | return _storage[key];
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/TraceInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace TradePlatform.MT4.Core.Utils
5 | {
6 | public class TraceInfo
7 | {
8 | public Exception Exception;
9 |
10 | public string Message;
11 | public BridgeTraceErrorType Type;
12 |
13 | public TraceInfo(BridgeTraceErrorType type, Exception exception = null, string message = "")
14 | {
15 | object obj;
16 | Type = type;
17 | Exception = exception;
18 | TraceInfo traceInfo = this;
19 | string str = " {0} @ {1} : {2}";
20 | object now = DateTime.Now;
21 | string name = Thread.CurrentThread.Name;
22 | object obj1 = name;
23 | if (name == null)
24 | {
25 | obj1 = "";
26 | }
27 | obj = (exception == null ? message : exception.Message);
28 | traceInfo.Message = string.Format(str, now, obj1, obj);
29 | }
30 |
31 | public override string ToString()
32 | {
33 | return Message;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/CheckupFunctions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Utils;
4 |
5 | namespace FXSharp.TradingPlatform.Exts
6 | {
7 | public static class CheckupFunctions
8 | {
9 | public static bool IsTradeContextBusy(this MqlHandler handler)
10 | {
11 | string returnValue = handler.CallMqlMethod("IsTradeContextBusy", null);
12 |
13 | return Convertor.ToBoolean(returnValue);
14 | }
15 |
16 | public static int GetLastError(this MqlHandler handler)
17 | {
18 | string returnValue = handler.CallMqlMethod("GetLastError", null);
19 |
20 | return Convertor.ToInt(returnValue);
21 | }
22 |
23 | public static int OrderReliableLastErr(this MqlHandler handler)
24 | {
25 | string returnValue = handler.CallMqlMethod("OrderReliableLastErr", null);
26 |
27 | try
28 | {
29 | return Convertor.ToInt(returnValue);
30 | }
31 | catch (Exception)
32 | {
33 | return 0;
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/EconomicCalendar/EconomicCalendar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace FXSharp.EA.NewsBox
7 | {
8 | public abstract class EconomicCalendar : IEconomicCalendar
9 | {
10 | public async Task> GetTodaysNextCriticalEventsAsync()
11 | {
12 | IList incomingNews = await GetTodaysCriticalEventsAsync().ConfigureAwait(false);
13 |
14 | return
15 | incomingNews.Where(x => x.DateTime > DateTime.Now && x.DateTime.Date == DateTime.Now.Date)
16 | .ToList();
17 | }
18 |
19 | private async Task> GetTodaysCriticalEventsAsync()
20 | {
21 | string rawData = await RequestRawDataToServerAsync().ConfigureAwait(false);
22 |
23 | return await ParseEconomicEventsAsync(rawData).ConfigureAwait(false);
24 | }
25 |
26 | protected abstract Task> ParseEconomicEventsAsync(string rawData);
27 | protected abstract Task RequestRawDataToServerAsync();
28 | }
29 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderDecisionProcessor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class OrderDecisionProcessor
8 | {
9 | private readonly EconomicCalendarPool calendarPool = new EconomicCalendarPool();
10 |
11 | private readonly OrderCreator orderCreator = new OrderCreator();
12 | private CurrencyPairRegistry analyzer = new CurrencyPairRegistry();
13 |
14 | public OrderDecisionProcessor()
15 | {
16 | calendarPool.Add(new ForexFactoryEconomicCalendar());
17 | //calendarPool.Add(new FxStreetEconomicCalendar());
18 | }
19 |
20 | public async Task> GetTodayMagicBoxOrders()
21 | {
22 | IList finalResult = await calendarPool.AllResultsAsync();
23 |
24 | return orderCreator.CreateOrdersFromEvents(finalResult).ToList();
25 |
26 | // should contain logic how the order will be processed, tied event, speech
27 |
28 | // if tied with another currency pair USDCAD => US news and CAD news at the same time
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/HandlerElement.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace TradePlatform.MT4.Core.Config
4 | {
5 | public class HandlerElement : ConfigurationElement
6 | {
7 | [ConfigurationProperty("assemblyName", IsRequired = true, IsKey = false)]
8 | public string AssemblyName
9 | {
10 | get { return base["assemblyName"] as string; }
11 | set { base["assemblyName"] = value; }
12 | }
13 |
14 | [ConfigurationProperty("Parameters")]
15 | public ParameterElementCollection InputParameters
16 | {
17 | get { return base["Parameters"] as ParameterElementCollection; }
18 | }
19 |
20 | [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
21 | public string Name
22 | {
23 | get { return base["name"] as string; }
24 | set { base["name"] = value; }
25 | }
26 |
27 | [ConfigurationProperty("typeName", IsRequired = true, IsKey = false)]
28 | public string TypeName
29 | {
30 | get { return base["typeName"] as string; }
31 | set { base["typeName"] = value; }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/QuoteListener.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.Core.Exceptions;
2 |
3 | namespace TradePlatform.MT4.Core
4 | {
5 | public class QuoteListener : ExpertAdvisor
6 | {
7 | public QuoteListener()
8 | {
9 | QuoteListener quoteListener = this;
10 | quoteListener.MqlError += OnMqlError;
11 | }
12 |
13 | protected override int DeInit()
14 | {
15 | return 0;
16 | }
17 |
18 | protected override int Init()
19 | {
20 | return 0;
21 | }
22 |
23 | private void OnMqlError(MqlErrorException mqlErrorException)
24 | {
25 | int num = this.AccountNumber();
26 | string str = this.Symbol();
27 | MetaTrader4 metaTrader4 = MetaTrader4.For(num, str);
28 | metaTrader4.OnMqlError(mqlErrorException);
29 | }
30 |
31 | protected override int Start()
32 | {
33 | int num = this.AccountNumber();
34 | string str = this.Symbol();
35 | MetaTrader4 metaTrader4 = MetaTrader4.For(num, str);
36 | metaTrader4.OnQuote(this);
37 | return 1;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/StateManager/SecondOrderPendingManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.HappyDay
5 | {
6 | internal class SecondOrderPendingManager : IOrderManager
7 | {
8 | private readonly HappyDayEA _ea;
9 | private readonly Order _pendingOrder;
10 | private readonly IProfitProtector _profitProtector;
11 |
12 | public SecondOrderPendingManager(Order pendingOrder, HappyDayEA happyDayEA)
13 | {
14 | _pendingOrder = pendingOrder;
15 | _ea = happyDayEA;
16 | _profitProtector = new ThreeLevelProfitProtector(pendingOrder);
17 | }
18 |
19 | public void OnTick()
20 | {
21 | if (_pendingOrder.IsRunning)
22 | {
23 | _ea.ChangeStateToSecondOrderRunning(_pendingOrder);
24 | }
25 | }
26 |
27 | private void CloseRunningOrder()
28 | {
29 | _pendingOrder.Close();
30 | }
31 |
32 |
33 | public void OnLondonOpen()
34 | {
35 |
36 | }
37 |
38 | public void OnNewYorkClose()
39 | {
40 | CloseRunningOrder();
41 | _ea.OrderCompleted();
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderState/OrderAlreadyRunning.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.NewsBox
5 | {
6 | public class OrderAlreadyRunning : IOrderState
7 | {
8 | private readonly Order order;
9 | private readonly OrderWatcher orderManager;
10 | private readonly IProfitProtector trailing;
11 | private bool cancel;
12 |
13 | public OrderAlreadyRunning(OrderWatcher orderManager, Order order, IProfitProtector trailing)
14 | {
15 | this.orderManager = orderManager;
16 | this.order = order;
17 | this.trailing = trailing;
18 | }
19 |
20 | public void Manage()
21 | {
22 | if (cancel)
23 | {
24 | order.Close();
25 | orderManager.MagicBoxCompleted();
26 | }
27 | else if (!order.IsOpen)
28 | {
29 | orderManager.MagicBoxCompleted();
30 | }
31 | else
32 | {
33 | //trailing.Trail();
34 | trailing.TryProtectProfit();
35 | }
36 | }
37 |
38 | public void Cancel()
39 | {
40 | cancel = true;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Handlers/ExtendedExpertAdvisor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Configuration;
3 | using System.Net.Mail;
4 | using TradePlatform.MT4.Core;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.Handlers
7 | {
8 | public abstract class ExtendedExpertAdvisor : ExpertAdvisor
9 | {
10 | protected override string ResolveMethod(string methodName, List parameters)
11 | {
12 | switch (methodName)
13 | {
14 | case "SendMail":
15 | SendMail(parameters[0], parameters[1]);
16 | return "";
17 | default:
18 | return base.ResolveMethod(methodName, parameters);
19 | }
20 | }
21 |
22 | protected void SendMail(string subject, string body)
23 | {
24 | var mailMessage = new MailMessage();
25 | mailMessage.To.Add(new MailAddress(ConfigurationManager.AppSettings["NotifyToEmail"]));
26 | mailMessage.Subject = subject;
27 | mailMessage.Body = body;
28 |
29 | var smtpClient = new SmtpClient();
30 | smtpClient.EnableSsl = true;
31 | smtpClient.Send(mailMessage);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_trail_buy_profit.cs:
--------------------------------------------------------------------------------
1 | //using NUnit.Framework;
2 |
3 | //namespace FXSharp.EA.NewsBox.Specs
4 | //{
5 | // [TestFixture]
6 | // public class When_trail_buy_profit
7 | // {
8 | // [Test]
9 | // public void Should_trail_when_reach_20_pips()
10 | // {
11 | // var orderDetail = new OrderDetail
12 | // {
13 | // //Bid = 0.0001,
14 | // OpenPrice = 0.0001,
15 | // Point = 0.00001,
16 | // StopLoss = 0.0005,
17 | // Digits = 5
18 | // };
19 |
20 | // var trailing = new BuyTrailingMethod(orderDetail);
21 | // orderDetail.ProfitPoints = 6*0.0001;
22 |
23 | // trailing.Trail();
24 |
25 | // orderDetail.ProfitPoints = 7*0.0001;
26 |
27 | // trailing.Trail();
28 |
29 | // Assert.AreEqual(0.0003, orderDetail.StopLoss);
30 |
31 | // orderDetail.ProfitPoints = 9*0.0001;
32 |
33 | // trailing.Trail();
34 |
35 | // Assert.AreEqual(0.0005, orderDetail.StopLoss);
36 |
37 | // orderDetail.ProfitPoints = 7*0.0001;
38 |
39 | // trailing.Trail();
40 |
41 | // Assert.AreEqual(0.0005, orderDetail.StopLoss);
42 | // }
43 | // }
44 | //}
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/EconomicCalendar/EconomicCalendarPool.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class EconomicCalendarPool
8 | {
9 | private readonly IList calendars = new List();
10 |
11 | public void Add(IEconomicCalendar calendar)
12 | {
13 | calendars.Add(calendar);
14 | }
15 |
16 | public async Task> AllResultsAsync()
17 | {
18 | IEnumerable>> tasks = from cal in calendars
19 | select cal.GetTodaysNextCriticalEventsAsync();
20 |
21 | IList[] result = await Task.WhenAll(tasks);
22 |
23 | return MergeResult(result).ToList();
24 | }
25 |
26 | private IEnumerable MergeResult(IList[] results)
27 | {
28 | IEnumerable allEvents = new List();
29 |
30 | foreach (var rs in results)
31 | {
32 | allEvents = allEvents.Concat(rs);
33 | }
34 |
35 | return allEvents.Distinct().OrderBy(x => x.DateTime);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderWatcherPool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | internal class OrderWatcherPool
8 | {
9 | private readonly IList orderWatchers = new List();
10 | // be careful race condition and deadlock
11 |
12 | internal void ManageAllOrder()
13 | {
14 | List cloned = orderWatchers.ToList(); // clone to avoid race condition
15 |
16 | foreach (OrderWatcher order in cloned)
17 | {
18 | order.ManageOrder();
19 | }
20 | }
21 |
22 | internal void Add(OrderWatcher watcher)
23 | {
24 | watcher.OrderClosed += watcher_OrderClosed;
25 |
26 | orderWatchers.Add(watcher);
27 | }
28 |
29 | private void watcher_OrderClosed(object sender, EventArgs e)
30 | {
31 | var watcher = (OrderWatcher) sender;
32 | orderWatchers.Remove(watcher);
33 | watcher.OrderClosed -= watcher_OrderClosed;
34 | }
35 |
36 | internal bool ContainsOrderForSymbol(string currencyPairs)
37 | {
38 | return orderWatchers.FirstOrDefault(x => x.Symbol == currencyPairs) != null;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("TradePlatform")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TradePlatform")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("b0150233-0fef-4f9e-837e-d4d92e657f6c")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 |
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_trail_sell_profit.cs:
--------------------------------------------------------------------------------
1 | //using NUnit.Framework;
2 |
3 | //namespace FXSharp.EA.NewsBox.Specs
4 | //{
5 | // [TestFixture]
6 | // public class When_trail_sell_profit
7 | // {
8 | // [Test]
9 | // public void Should_trail_when_reach_20_pips()
10 | // {
11 | // var orderDetail = new OrderDetail
12 | // {
13 | // //Bid = 0.0010,
14 | // OpenPrice = 0.0020,
15 | // Point = 0.00001,
16 | // StopLoss = 0.0025,
17 | // Digits = 5
18 | // };
19 |
20 | // var trailing = new TrailingMethod(orderDetail);
21 | // orderDetail.ProfitPoints = 6*0.0001;
22 |
23 | // trailing.Trail();
24 |
25 | // Assert.AreEqual(0.0019, orderDetail.StopLoss);
26 |
27 | // orderDetail.ProfitPoints = 7*0.0001;
28 |
29 | // trailing.Trail();
30 |
31 | // Assert.AreEqual(0.0018, orderDetail.StopLoss);
32 |
33 | // orderDetail.ProfitPoints = 9*0.0001;
34 |
35 | // trailing.Trail();
36 |
37 | // Assert.AreEqual(0.0016, orderDetail.StopLoss);
38 |
39 | // orderDetail.ProfitPoints = 7*0.0001;
40 |
41 | // trailing.Trail();
42 |
43 | // Assert.AreEqual(0.0016, orderDetail.StopLoss);
44 | // }
45 | // }
46 | //}
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/HostElement.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 | using System.Net;
3 |
4 | namespace TradePlatform.MT4.Core.Config
5 | {
6 | public class HostElement : ConfigurationElement
7 | {
8 | [ConfigurationProperty("Handlers")]
9 | public HandlerElementCollection Handlers
10 | {
11 | get { return base["Handlers"] as HandlerElementCollection; }
12 | }
13 |
14 | [ConfigurationProperty("ipAddress", IsRequired = true, IsKey = false)]
15 | public string ipAddress
16 | {
17 | get { return base["ipAddress"] as string; }
18 | set { base["ipAddress"] = value; }
19 | }
20 |
21 | public IPAddress IPAddress
22 | {
23 | get { return IPAddress.Parse(ipAddress); }
24 | }
25 |
26 | [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
27 | public string Name
28 | {
29 | get { return base["name"] as string; }
30 | set { base["name"] = value; }
31 | }
32 |
33 | [ConfigurationProperty("port", IsRequired = true, IsKey = false, DefaultValue = 2007)]
34 | [IntegerValidator(MinValue = 2000, MaxValue = 3000)]
35 | public int Port
36 | {
37 | get { return (int) base["port"]; }
38 | set { base["port"] = value; }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/UnitTests/CommonFunctionsTests.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Utils;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.UnitTests
7 | {
8 | public static class CommonFunctionsTests
9 | {
10 | public static void RunTests(MqlHandler script)
11 | {
12 | script.Alert("Test Alert");
13 | script.Comment("Test Comment");
14 |
15 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
16 | message: "Test 'GetTickCount: " + script.GetTickCount() + "'"));
17 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
18 | message:
19 | "Test 'MarketInfo: " +
20 | script.MarketInfo(SYMBOLS.EURUSD, MARKER_INFO_MODE.MODE_POINT) + "'"));
21 |
22 | script.PlaySound("connect.wav");
23 | script.Print("Test Print");
24 |
25 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
26 | message:
27 | "Test 'SendNotification: " + script.SendNotification("Test Notification") +
28 | "'"));
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/StateManager/SecondOrderRunningManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.HappyDay
5 | {
6 | internal class SecondOrderRunningManager : IOrderManager
7 | {
8 | private readonly HappyDayEA _ea;
9 | private readonly Order _runningOrder;
10 | private readonly IProfitProtector _profitProtector;
11 |
12 | public SecondOrderRunningManager(Order runningOrder, HappyDayEA happyDayEA)
13 | {
14 | _runningOrder = runningOrder;
15 | _ea = happyDayEA;
16 | _profitProtector = new ThreeLevelProfitProtector(_runningOrder);
17 | }
18 |
19 | public void OnTick()
20 | {
21 | if (_runningOrder.IsRunning && _runningOrder.IsOpen)
22 | {
23 | //_profitProtector.TryProtectProfit();
24 | }
25 | else
26 | {
27 | _ea.OrderCompleted();
28 | }
29 | }
30 |
31 | private void CloseRunningOrder()
32 | {
33 | _runningOrder.Close();
34 | }
35 |
36 |
37 | public void OnLondonOpen()
38 | {
39 | //throw new System.NotImplementedException();
40 | }
41 |
42 | public void OnNewYorkClose()
43 | {
44 | CloseRunningOrder();
45 | _ea.OrderCompleted();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/EconomicCalendar/EconomicEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FXSharp.EA.NewsBox
4 | {
5 | public class EconomicEvent
6 | {
7 | public DateTime DateTime { get; set; }
8 | public string Name { get; set; }
9 | public string Country { get; set; }
10 | public string Currency { get; set; }
11 | public string Volatility { get; set; }
12 | public string Actual { get; set; }
13 | public string Previous { get; set; }
14 | public string Consensus { get; set; }
15 |
16 | public bool IsSpeechOrMeeting
17 | {
18 | get { return string.IsNullOrEmpty(Previous); }
19 | }
20 |
21 | public override bool Equals(object obj)
22 | {
23 | if (ReferenceEquals(obj, null)) return false;
24 |
25 | if (ReferenceEquals(this, obj)) return true;
26 |
27 | if (GetType() != obj.GetType()) return false;
28 |
29 | var another = (EconomicEvent) obj;
30 |
31 | return another.DateTime == DateTime
32 | && another.Currency == Currency
33 | && another.Actual == Actual
34 | && another.Previous == Previous
35 | && another.Consensus == Consensus;
36 | }
37 |
38 | public override int GetHashCode()
39 | {
40 | return Currency.GetHashCode() + Previous.GetHashCode();
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/ExpertAdvisor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace TradePlatform.MT4.Core
5 | {
6 | public abstract class ExpertAdvisor : MqlHandler
7 | {
8 | protected abstract int DeInit();
9 |
10 | protected abstract int Init();
11 |
12 | protected internal override string ResolveMethod(string methodName, List parameters)
13 | {
14 | string str = methodName;
15 | string str1 = str;
16 | if (str != null)
17 | {
18 | if (str1 == "Init")
19 | {
20 | int num = Init();
21 | return num.ToString();
22 | }
23 | else
24 | {
25 | if (str1 == "Start")
26 | {
27 | int num1 = Start();
28 | return num1.ToString();
29 | }
30 | else
31 | {
32 | if (str1 == "DeInit")
33 | {
34 | int num2 = DeInit();
35 | return num2.ToString();
36 | }
37 | }
38 | }
39 | }
40 | throw new Exception("No method found");
41 | }
42 |
43 | protected abstract int Start();
44 | }
45 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Trailing/TrailingMethod.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using FXSharp.EA.OrderManagements;
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class TrailingMethod : IProfitProtector
8 | {
9 | private readonly Order _order;
10 |
11 | private readonly double[] _protectLevel = new double[] {100, 200, 300, 10000};
12 | private readonly double[] _protectValue = new double[] {20, 100, 200, 10000};
13 |
14 | private int _currentProtectedIdx;
15 |
16 | public TrailingMethod(Order order)
17 | {
18 | _order = order;
19 | }
20 |
21 | public double NextProtectedLevel
22 | {
23 | get { return _protectLevel[_currentProtectedIdx]; }
24 | }
25 |
26 | public double NextProtectedValue
27 | {
28 | get { return _protectValue[_currentProtectedIdx]; }
29 | }
30 |
31 | public void TryProtectProfit()
32 | {
33 | Console.WriteLine(_order.ProfitPoints);
34 |
35 | if (_order.ProfitPoints >= NextProtectedLevel)
36 | {
37 | Console.WriteLine("Try locking profit : next level {0}", NextProtectedLevel);
38 | _order.ProtectProfit(NextProtectedValue);
39 | NextLevel();
40 | }
41 | }
42 |
43 | private void NextLevel()
44 | {
45 | _currentProtectedIdx++;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/FXSharp.EA.OrderManagements/ThreeLevelProfitProtector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using FXSharp.EA.OrderManagements;
3 | using FXSharp.TradingPlatform.Exts;
4 |
5 | namespace FXSharp.EA.OrderManagements
6 | {
7 | public class ThreeLevelProfitProtector : IProfitProtector
8 | {
9 | private readonly Order _order;
10 |
11 | private readonly double[] _protectLevel = new double[] {300, 600, 800, 10000};
12 | private readonly double[] _protectValue = new double[] {10, 200, 500, 10000};
13 |
14 | private int _currentProtectedIdx;
15 |
16 | public ThreeLevelProfitProtector(Order order)
17 | {
18 | _order = order;
19 | }
20 |
21 | public double NextProtectedLevel
22 | {
23 | get { return _protectLevel[_currentProtectedIdx]; }
24 | }
25 |
26 | public double NextProtectedValue
27 | {
28 | get { return _protectValue[_currentProtectedIdx]; }
29 | }
30 |
31 | public void TryProtectProfit()
32 | {
33 | Console.WriteLine(_order.ProfitPoints);
34 |
35 | if (_order.ProfitPoints >= NextProtectedLevel)
36 | {
37 | Console.WriteLine("Try locking profit : next level {0}", NextProtectedLevel);
38 | _order.ProtectProfit(NextProtectedValue);
39 | NextLevel();
40 | }
41 | }
42 |
43 | private void NextLevel()
44 | {
45 | _currentProtectedIdx++;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MyFirstExpert/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("MyFirstExpert")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyFirstExpert")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("01eff938-d8b3-4920-bc9e-1a741802cf8e")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.NewsBox")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.NewsBox")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("dffc0496-f733-49b7-ba90-debc81201471")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.PinBar")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.PinBar")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("37401706-9c93-4649-befc-cb6999a3f9c6")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.HappyDay")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.HappyDay")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("4aaabad6-7946-4a35-ac6a-626ac6d86637")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.MagicBox/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.MagicBox")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.MagicBox")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("d27a870d-09d9-49a8-8253-0b71f3dbf35f")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.FirstTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.FirstTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("588de52c-07d0-4eb2-9f8d-a3c2b6dd7e54")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.NewsBox.Specs")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.NewsBox.Specs")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("32ca4b51-d919-46d6-b109-9743621049af")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.EA.OrderManagements/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.EA.OrderManagements")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.EA.OrderManagements")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("2f9e9c0c-6a90-4b4b-a6fa-03a2bb55d801")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/FXSharp.TradingPlatform.Exts/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("FXSharp.TradingPlatform.Exts")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FXSharp.TradingPlatform.Exts")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("777dc246-b7ab-4907-b71a-0ca61a91a3be")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Scripts/SmokeTestScript.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Exceptions;
4 | using TradePlatform.MT4.Core.Utils;
5 | using TradePlatform.MT4.SDK.API;
6 |
7 | namespace TradePlatform.MT4.SDK.Library.Scripts
8 | {
9 | public class SmokeTestScript : ExpertAdvisor
10 | {
11 | public SmokeTestScript()
12 | {
13 | MqlError += OnMqlError;
14 | }
15 |
16 | public int TestProperty { get; set; }
17 |
18 | private void OnMqlError(MqlErrorException mqlErrorException)
19 | {
20 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "MQL Error: " + mqlErrorException.Message));
21 | }
22 |
23 | protected override int Init()
24 | {
25 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Init()"));
26 |
27 | return 1;
28 | }
29 |
30 | protected override int Start()
31 | {
32 | double bid = this.Bid();
33 | double ask = this.Ask();
34 |
35 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Bid: " + bid));
36 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Ask: " + ask));
37 |
38 | return 2;
39 | }
40 |
41 | protected override int DeInit()
42 | {
43 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "DeInit()"));
44 |
45 | return 3;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/StateManager/FirstOrderRunningManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.HappyDay
5 | {
6 | internal class FirstOrderRunningManager : IOrderManager
7 | {
8 | private readonly HappyDayEA _ea;
9 | private readonly Order _runningOrder;
10 | private readonly Order _pendingOrder;
11 | private readonly IProfitProtector _profitProtector;
12 |
13 | public FirstOrderRunningManager(Order runningOrder, Order pendingOrder, HappyDayEA happyDayEA)
14 | {
15 | _runningOrder = runningOrder;
16 | _pendingOrder = pendingOrder;
17 | _ea = happyDayEA;
18 | _profitProtector = new ThreeLevelProfitProtector(_runningOrder);
19 | }
20 |
21 | public void OnTick()
22 | {
23 | if (_runningOrder.IsRunning && _runningOrder.IsOpen)
24 | {
25 | //_profitProtector.TryProtectProfit();
26 | }
27 | else
28 | {
29 | _ea.FirstOrderCompleted(_pendingOrder);
30 | }
31 | }
32 |
33 | public void OnLondonOpen()
34 | {
35 |
36 | }
37 |
38 | public void OnNewYorkClose()
39 | {
40 | _runningOrder.Close();
41 | _pendingOrder.Close();
42 | _ea.OrderCompleted();
43 | //CloseRunningOrder();
44 | //_ea.CreatedMagicBoxFromPreviousCandle();
45 | //_ea.ChangeStateToBoxAlreadyCreated();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/MethodCallInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace TradePlatform.MT4.Core.Utils
5 | {
6 | public sealed class MethodCallInfo
7 | {
8 | public readonly string MethodName;
9 |
10 | public readonly List Parameters;
11 |
12 | public MethodCallInfo(string methodName, IEnumerable parameters)
13 | {
14 | MethodName = methodName;
15 | Parameters = new List(parameters);
16 | //MethodCallInfo strs = this;
17 | //IEnumerable strs1 = parameters;
18 | //IEnumerable u00210s = strs1;
19 | //if (strs1 == null)
20 | //{
21 | // u00210s = (IEnumerable)(new string[0]);
22 | //}
23 | //strs.Parameters = new List(u00210s);
24 | ReturnValue = null;
25 | ErrorMessage = null;
26 | }
27 |
28 | public string ErrorMessage { get; set; }
29 |
30 | public string ReturnValue { get; set; }
31 |
32 | public override string ToString()
33 | {
34 | string str = string.Concat(MethodName, "(");
35 | List parameters = Parameters;
36 | string str1 = str;
37 | str = parameters.Aggregate(str1, (string current, string prm) => string.Concat(current, prm, ", "));
38 | var chrArray = new[] {',', ' '};
39 | str = str.TrimEnd(chrArray);
40 | return string.Concat(str, ")");
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/StateManager/PendingOrderCreatedManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | namespace FXSharp.EA.PinBar
4 | {
5 | internal class PendingOrderCreatedManager : IOrderManager
6 | {
7 | private readonly PinBarEA _ea;
8 | private readonly Order _order;
9 |
10 | public PendingOrderCreatedManager(PinBarEA pinBarEA, Order order)
11 | {
12 | _ea = pinBarEA;
13 | _order = order;
14 | }
15 |
16 | public void OnNewBullishPinBar()
17 | {
18 | //if (_order.OrderType == ORDER_TYPE.OP_BUY) return;
19 | //CloseOrder(); // or lock profit ?
20 |
21 | //var order = _ea.CreatePendingBuyOrder();
22 | //_ea.MoveToPendingOrderCreatedState(order);
23 | }
24 |
25 | public void OnNewBearishPinBar()
26 | {
27 | //if (_order.OrderType == ORDER_TYPE.OP_SELL) return;
28 | //CloseOrder(); // or lock profit ?
29 |
30 | //var order = _ea.CreatePendingSellOrder();
31 | //_ea.MoveToPendingOrderCreatedState(order);
32 | }
33 |
34 | public void OnTick()
35 | {
36 | if (_order.IsRunning)
37 | {
38 | _ea.MoveToOrderRunningState(_order);
39 | }
40 | else if (!_order.IsValid)
41 | {
42 | CloseOrder();
43 | _ea.OrderCompleted();
44 | }
45 | }
46 |
47 | private void CloseOrder()
48 | {
49 | _order.Close();
50 | //_ea.OrderCompleted();
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/Scheduler/MagicBoxScheduler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using Quartz;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | internal class MagicBoxScheduler
8 | {
9 | private readonly ConcurrentQueue orderQueue;
10 | private readonly IScheduler scheduler;
11 |
12 | public MagicBoxScheduler(IScheduler scheduler, ConcurrentQueue orderQueue)
13 | {
14 | this.scheduler = scheduler;
15 | this.orderQueue = orderQueue;
16 | }
17 |
18 | public void Schedule(MagicBoxOrder magicBox)
19 | {
20 | DateTime nexttime = magicBox.ExecutingTime;
21 |
22 | IJobDetail jobDetail = JobBuilder.Create()
23 | .WithIdentity(magicBox.Id, "group1")
24 | .Build();
25 |
26 | ITrigger trigger = TriggerBuilder.Create()
27 | .WithIdentity(magicBox.Id, "group1")
28 | .StartAt(DateBuilder.TodayAt(nexttime.Hour, nexttime.Minute,
29 | nexttime.Second))
30 | .Build();
31 |
32 | // should group this together in one command. just execute when arrived there
33 |
34 | jobDetail.JobDataMap.Add("queue", orderQueue);
35 | jobDetail.JobDataMap.Add("orders", magicBox);
36 |
37 | scheduler.ScheduleJob(jobDetail, trigger);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_decide_the_order_detail.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using NUnit.Framework;
5 |
6 | namespace FXSharp.EA.NewsBox.Specs
7 | {
8 | [TestFixture]
9 | public class When_decide_the_order_detail
10 | {
11 | [Test]
12 | public void Should_detect_collided_news()
13 | {
14 | DateTime time = DateTime.Now;
15 |
16 | var evtList = new List
17 | {
18 | new EconomicEvent {Currency = "USD", DateTime = time},
19 | new EconomicEvent {Currency = "USD", DateTime = time}
20 | };
21 |
22 | IEnumerable> groups = evtList.GroupBy(x => x.DateTime);
23 |
24 | Assert.AreEqual(1, groups.Count());
25 | groups.First();
26 |
27 | foreach (var grp in groups)
28 | {
29 | Console.WriteLine(grp.Key);
30 | foreach (EconomicEvent item in grp)
31 | {
32 | Console.WriteLine(item.Currency);
33 | }
34 | }
35 | }
36 |
37 | [Test]
38 | public void Should_detect_nominal_news()
39 | {
40 | var eEvnt = new EconomicEvent {Previous = "293"};
41 |
42 | Assert.IsFalse(eEvnt.IsSpeechOrMeeting);
43 | }
44 |
45 | [Test]
46 | public void Should_detect_speech_and_conf()
47 | {
48 | var eEvnt = new EconomicEvent {};
49 |
50 | Assert.IsTrue(eEvnt.IsSpeechOrMeeting);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/FXSharp.EA.HappyDay/StateManager/BoxAlreadyCreatedManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | namespace FXSharp.EA.HappyDay
4 | {
5 | internal class BoxAlreadyCreatedManager : IOrderManager
6 | {
7 | private readonly Order _buyOrder;
8 | private readonly HappyDayEA _ea;
9 | private readonly Order _sellOrder;
10 |
11 | public BoxAlreadyCreatedManager(Order buyOrder, Order sellOrder, HappyDayEA happyDayEA)
12 | {
13 | _buyOrder = buyOrder;
14 | _sellOrder = sellOrder;
15 | _ea = happyDayEA;
16 | }
17 |
18 | public void OnTick()
19 | {
20 | if (_buyOrder.IsRunning)
21 | {
22 | //_sellOrder.Close();
23 | _ea.ChangeStateToOrderRunning(_buyOrder, _sellOrder);
24 | }
25 | else if (_sellOrder.IsRunning)
26 | {
27 | //_buyOrder.Close();
28 | _ea.ChangeStateToOrderRunning(_sellOrder, _buyOrder);
29 | }
30 | }
31 |
32 | private void DeletePreviousMagicBox()
33 | {
34 | _ea.Print("Delete previous magic box");
35 | _buyOrder.Close();
36 | _sellOrder.Close();
37 | }
38 |
39 |
40 | public void OnLondonOpen()
41 | {
42 | //throw new System.NotImplementedException();
43 | }
44 |
45 | public void OnNewYorkClose()
46 | {
47 | DeletePreviousMagicBox();
48 | _ea.OrderCompleted();
49 | //_ea.CreatedMagicBoxFromPreviousCandle();
50 | //_ea.ChangeStateToBoxAlreadyCreated();
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/packages/HtmlAgilityPack.1.4.6/HtmlAgilityPack.1.4.6.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | HtmlAgilityPack
5 | 1.4.6
6 | Simon Mourrier, Jeff Klawiter
7 | Simon Mourrier, Jeff Klawiter
8 | http://htmlagilitypack.codeplex.com/license
9 | http://htmlagilitypack.codeplex.com/
10 | http://blog.j-maxx.net/HAPIcon.png
11 | false
12 | This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).
13 | This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).
14 | HTML parse crawler spider linq
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Scripts/UnitTestScript.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Exceptions;
4 | using TradePlatform.MT4.Core.Utils;
5 | using TradePlatform.MT4.SDK.Library.UnitTests;
6 |
7 | namespace TradePlatform.MT4.SDK.Library.Scripts
8 | {
9 | public class UnitTestScript : ExpertAdvisor
10 | {
11 | public UnitTestScript()
12 | {
13 | MqlError += OnMqlError;
14 | }
15 |
16 | private void OnMqlError(MqlErrorException mqlErrorException)
17 | {
18 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "MQL Error: " + mqlErrorException.Message));
19 | }
20 |
21 | protected override int Init()
22 | {
23 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Init()"));
24 |
25 | // AccountInformationTests.RunTests(this);
26 | CommonFunctionsTests.RunTests(this);
27 | //PredefinedVariablesTests.RunTests(this);
28 | // TechnicalIndicatorsTests.RunTests(this);
29 | //TradingFunctionsTests.RunTests(this);
30 | // WindowFunctionsTests.RunTests(this);
31 |
32 | return 1;
33 | }
34 |
35 | protected override int Start()
36 | {
37 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Start()"));
38 |
39 | return 2;
40 | }
41 |
42 | protected override int DeInit()
43 | {
44 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "DeInit()"));
45 |
46 | return 3;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/MqlHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using TradePlatform.MT4.Core.Exceptions;
6 | using TradePlatform.MT4.Core.Utils;
7 |
8 | namespace TradePlatform.MT4.Core
9 | {
10 | public abstract class MqlHandler
11 | {
12 | internal Func, string> CallMqlInternal;
13 |
14 | public Action MqlError;
15 |
16 | public string CallMqlMethod(string methodName, params object[] parameters)
17 | {
18 | IEnumerable strs;
19 | try
20 | {
21 | if (parameters == null)
22 | {
23 | strs = new string[0];
24 | }
25 | else
26 | {
27 | object[] objArray = parameters;
28 | strs = objArray.Select((object x) => x.ToString());
29 | }
30 | IEnumerable strs1 = strs;
31 | if (CallMqlInternal != null)
32 | {
33 | string str = CallMqlInternal(methodName, new List(strs1));
34 | return str;
35 | }
36 | }
37 | catch (Exception exception1)
38 | {
39 | Exception exception = exception1;
40 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
41 | }
42 | return null;
43 | }
44 |
45 | protected internal abstract string ResolveMethod(string methodName, List parameters);
46 | }
47 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/ParameterElementCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 | using System.Linq;
3 |
4 | namespace TradePlatform.MT4.Core.Config
5 | {
6 | public class ParameterElementCollection : ConfigurationElementCollection
7 | {
8 | public override ConfigurationElementCollectionType CollectionType
9 | {
10 | get { return ConfigurationElementCollectionType.BasicMap; }
11 | }
12 |
13 | protected override string ElementName
14 | {
15 | get { return "Parameter"; }
16 | }
17 |
18 | public ParameterElement this[int index]
19 | {
20 | get { return (ParameterElement) base.BaseGet(index); }
21 | set
22 | {
23 | if (base.BaseGet(index) != null)
24 | {
25 | base.BaseRemoveAt(index);
26 | }
27 | BaseAdd(index, value);
28 | }
29 | }
30 |
31 | public ParameterElement this[string propertyName]
32 | {
33 | get { return (ParameterElement) base.BaseGet(propertyName); }
34 | }
35 |
36 | public bool ContainsKey(string propertyName)
37 | {
38 | object[] objArray = base.BaseGetAllKeys();
39 | return objArray.Any((object obj) => (string) obj == propertyName);
40 | }
41 |
42 | protected override ConfigurationElement CreateNewElement()
43 | {
44 | return new ParameterElement();
45 | }
46 |
47 | protected override object GetElementKey(ConfigurationElement element)
48 | {
49 | return ((ParameterElement) element).PropertyName;
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/UnitTests/PredefinedVariablesTests.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Utils;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.UnitTests
7 | {
8 | public static class PredefinedVariablesTests
9 | {
10 | public static void RunTests(MqlHandler script)
11 | {
12 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Ask: " + script.Ask() + "'"));
13 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Bars: " + script.Bars() + "'"));
14 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Bid: " + script.Bid() + "'"));
15 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Close: " + script.Close(0) + "'"));
16 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Digits: " + script.Digits() + "'"));
17 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'High: " + script.High(0) + "'"));
18 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Low: " + script.Low(0) + "'"));
19 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Open: " + script.Open(0) + "'"));
20 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Point: " + script.Point() + "'"));
21 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Time: " + script.Time(0) + "'"));
22 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Volume: " + script.Volume() + "'"));
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/StateManager/OrderRunningManager.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.EA.OrderManagements;
2 | using FXSharp.TradingPlatform.Exts;
3 |
4 | namespace FXSharp.EA.PinBar
5 | {
6 | internal class OrderRunningManager : IOrderManager
7 | {
8 | private readonly PinBarEA _ea;
9 | private readonly Order _order;
10 | private readonly IProfitProtector _profitProtector;
11 |
12 | public OrderRunningManager(PinBarEA pinBarEA, Order order)
13 | {
14 | _ea = pinBarEA;
15 | _order = order;
16 | _profitProtector = new ThreeLevelProfitProtector(order);
17 | }
18 |
19 | public void OnNewBullishPinBar()
20 | {
21 | //if (_order.OrderType == ORDER_TYPE.OP_BUY) return;
22 | //CloseOrder(); // or lock profit ?
23 |
24 | //var order = _ea.CreatePendingBuyOrder();
25 | //_ea.MoveToPendingOrderCreatedState(order);
26 | }
27 |
28 | public void OnNewBearishPinBar()
29 | {
30 | //if (_order.OrderType == ORDER_TYPE.OP_SELL) return;
31 | //CloseOrder(); // or lock profit ?
32 |
33 | //var order = _ea.CreatePendingSellOrder();
34 | //_ea.MoveToPendingOrderCreatedState(order);
35 | }
36 |
37 | public void OnTick()
38 | {
39 | if (_order.IsRunning && _order.IsOpen)
40 | {
41 | //_profitProtector.TryProtectProfit();
42 | }
43 | else
44 | {
45 | _ea.OrderCompleted();
46 | }
47 | // should trail and lock profit ?
48 | }
49 |
50 | private void CloseOrder()
51 | {
52 | _order.Close();
53 | //_ea.OrderCompleted();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Shell/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Reflection;
4 | using TradePlatform.MT4.Core;
5 |
6 | namespace TradePlatform.MT4.SDK.Shell
7 | {
8 | //using TradePlatform.MT4.Data;
9 |
10 |
11 | internal class Program
12 | {
13 | private static void Main(string[] args)
14 | {
15 | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
16 |
17 | //SetupConsole();
18 |
19 | Bridge.InitializeHosts();
20 | }
21 |
22 | private static void SetupConsole()
23 | {
24 | Console.ForegroundColor = ConsoleColor.Green;
25 | Console.Title = string.Format(".NET Bridge Shell {0}", Assembly.GetExecutingAssembly().GetName().Version);
26 |
27 | Console.SetWindowPosition(0, 0);
28 | Console.WindowTop = 0;
29 | Console.WindowLeft = 0;
30 |
31 | Console.WindowWidth = 130;
32 | Console.SetWindowSize(130, 15);
33 | Console.WindowHeight = 15;
34 |
35 | Console.BufferHeight = Int16.MaxValue - 1;
36 | }
37 |
38 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
39 | {
40 | if (!Debugger.IsAttached)
41 | {
42 | Console.BackgroundColor = ConsoleColor.Red;
43 | Console.ForegroundColor = ConsoleColor.White;
44 | Console.WriteLine(((Exception) e.ExceptionObject).Message);
45 | Console.ForegroundColor = ConsoleColor.Green;
46 | Console.BackgroundColor = ConsoleColor.Black;
47 | Console.WriteLine("Press any key to exit");
48 | Console.ReadKey();
49 |
50 | Environment.Exit(1);
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/MagicBoxOrder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FXSharp.EA.NewsBox
4 | {
5 | public class MagicBoxOrder
6 | {
7 | private Guid _unique;
8 |
9 | public MagicBoxOrder()
10 | {
11 | _unique = Guid.NewGuid();
12 | Config = new MagicBoxConfig();
13 | }
14 |
15 | public string Id
16 | {
17 | get { return string.Format("{0}-{1}", Symbol, _unique.ToString()); }
18 | }
19 |
20 | public string Symbol { get; set; }
21 |
22 | public double LotSize { get; set; }
23 |
24 | public double Range
25 | {
26 | get { return Config.Range; }
27 | }
28 |
29 | public double TakeProfit
30 | {
31 | get { return Config.TakeProfit; }
32 | }
33 |
34 | public double StopLoss
35 | {
36 | get { return Config.StopLoss; }
37 | set { Config.StopLoss = value; }
38 | }
39 |
40 | public int MinuteExpiracy
41 | {
42 | get { return Config.MinuteExpiracy; }
43 | }
44 |
45 | public DateTime ExecutingTime
46 | {
47 | get { return NewsTime.AddMinutes(Config.MinutePendingExecution); }
48 | }
49 |
50 | public DateTime NewsTime { get; set; }
51 |
52 | public MagicBoxConfig Config { get; set; }
53 |
54 | public override bool Equals(object obj)
55 | {
56 | if (ReferenceEquals(obj, null)) return false;
57 |
58 | if (ReferenceEquals(this, obj)) return true;
59 |
60 | if (GetType() != obj.GetType()) return false;
61 |
62 | var another = (MagicBoxOrder) obj;
63 |
64 | return another.Symbol == Symbol && another.ExecutingTime == ExecutingTime;
65 | }
66 |
67 | public override int GetHashCode()
68 | {
69 | return Symbol.Length + ExecutingTime.Hour;
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Experts/MACrossExpert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TradePlatform.MT4.SDK.API;
3 | using TradePlatform.MT4.SDK.Library.Handlers;
4 |
5 | namespace TradePlatform.MT4.SDK.Library.Experts
6 | {
7 | public class MACrossExpert : ExtendedExpertAdvisor
8 | {
9 | private bool fastUnderSlow;
10 |
11 | protected override int Init()
12 | {
13 | return 1;
14 | }
15 |
16 | protected override int Start()
17 | {
18 | double fastMA = this.iMA(this.Symbol(), TIME_FRAME.PERIOD_H1, 3, 0, MA_METHOD.MODE_EMA,
19 | APPLY_PRICE.PRICE_CLOSE, 0);
20 | double slowMA = this.iMA(this.Symbol(), TIME_FRAME.PERIOD_H1, 5, 0, MA_METHOD.MODE_EMA,
21 | APPLY_PRICE.PRICE_CLOSE, 0);
22 |
23 | fastMA = Math.Round(fastMA, this.Digits());
24 | slowMA = Math.Round(slowMA, this.Digits());
25 |
26 | if (fastMA < slowMA)
27 | {
28 | fastUnderSlow = true;
29 | }
30 | else
31 | {
32 | fastUnderSlow = false;
33 | }
34 |
35 | if (fastMA == slowMA)
36 | {
37 | if (fastUnderSlow)
38 | {
39 | this.OrderSend(this.Symbol(), ORDER_TYPE.OP_BUY, 0.1, this.Ask(), 3, this.Bid() - 100*this.Point(),
40 | this.Bid() + 100*this.Point());
41 | }
42 | else
43 | {
44 | this.OrderSend(this.Symbol(), ORDER_TYPE.OP_SELL, 0.1, this.Bid(), 3, this.Ask() + 100*this.Point(),
45 | this.Ask() - 100*this.Point());
46 | }
47 | }
48 |
49 | return 1;
50 | }
51 |
52 | protected override int DeInit()
53 | {
54 | return 1;
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Bridge.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Configuration;
3 | using TradePlatform.MT4.Core.Config;
4 | using TradePlatform.MT4.Core.Internals;
5 |
6 | //using TradePlatform.MT4.Data;
7 |
8 | namespace TradePlatform.MT4.Core
9 | {
10 | public class Bridge
11 | {
12 | public static BridgeConfiguration Configuration
13 | {
14 | get
15 | {
16 | var section = (BridgeConfiguration) ConfigurationManager.GetSection("BridgeConfiguration");
17 | return section;
18 | }
19 | }
20 |
21 | public static MetaTrader4 GetTerminal(int accountNumber, string symbol)
22 | {
23 | return MetaTrader4.For(accountNumber, symbol);
24 | }
25 |
26 | public static List GetTerminals()
27 | {
28 | return MetaTrader4.All();
29 | }
30 |
31 | public static void InitializeHosts(bool isBackground = false)
32 | {
33 | foreach (HostElement host in Configuration.Hosts)
34 | {
35 | var handlerHost = new HandlerHost(host.Name, host.IPAddress, host.Port, isBackground);
36 | handlerHost.Run();
37 | }
38 | //try
39 | //{
40 | // Uri[] uri = new Uri[] { new Uri(Bridge.Configuration.WcfBaseAddress) };
41 | // WebServiceHost webServiceHost = new WebServiceHost(typeof(TradePlatformDataService), uri);
42 | // webServiceHost.Open();
43 | // Trace.Write(new TraceInfo(BridgeTraceErrorType.HostInfo, null, string.Concat("TradePlatform Data Service is serving at ", Bridge.Configuration.WcfBaseAddress, "\n")));
44 | //}
45 | //catch (Exception exception1)
46 | //{
47 | // Exception exception = exception1;
48 | // Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
49 | //}
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_receive_economic_event_with_the_same_time_and_currency.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using NUnit.Framework;
5 |
6 | namespace FXSharp.EA.NewsBox.Specs
7 | {
8 | [TestFixture]
9 | public class When_receive_economic_event_with_the_same_time_and_currency
10 | {
11 | private IList mboxList;
12 |
13 | [TestFixtureSetUp]
14 | public void PrepareEconomicEvents()
15 | {
16 | DateTime time = DateTime.Now;
17 |
18 | var evtList = new List
19 | {
20 | new EconomicEvent {Currency = "USD", DateTime = time.AddMinutes(20), Previous = "33"},
21 | new EconomicEvent {Currency = "CHF", DateTime = time.AddMinutes(30), Previous = "33"},
22 | new EconomicEvent {Currency = "USD", DateTime = time.AddMinutes(40), Previous = "33"},
23 | new EconomicEvent {Currency = "USD", DateTime = time.AddMinutes(40), Previous = "33"}
24 | };
25 |
26 | var creator = new OrderCreator();
27 | mboxList = creator.CreateOrdersFromEvents(evtList);
28 | }
29 |
30 | [Test]
31 | public void Should_create_single_order_for_the_same_currency()
32 | {
33 | Assert.AreEqual(3, mboxList.Count);
34 | }
35 |
36 | [Test]
37 | public void Should_create_speech_config_for_duplicate_currency()
38 | {
39 | MagicBoxOrder lastEvent = mboxList.Last();
40 | MagicBoxConfig config = lastEvent.Config;
41 |
42 | Assert.AreEqual("EURUSD", lastEvent.Symbol);
43 |
44 | Assert.AreEqual(-1, config.MinutePendingExecution);
45 | Assert.AreEqual(30, config.MinuteExpiracy);
46 | Assert.AreEqual(250, config.Range);
47 | Assert.AreEqual(200, config.StopLoss);
48 | Assert.AreEqual(150, config.TakeProfit);
49 | }
50 |
51 | // create_speech_config_for_magic_box
52 | }
53 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/HostElementCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace TradePlatform.MT4.Core.Config
4 | {
5 | public class HostElementCollection : ConfigurationElementCollection
6 | {
7 | public override ConfigurationElementCollectionType CollectionType
8 | {
9 | get { return ConfigurationElementCollectionType.BasicMap; }
10 | }
11 |
12 | protected override string ElementName
13 | {
14 | get { return "Host"; }
15 | }
16 |
17 | public HostElement this[int index]
18 | {
19 | get { return (HostElement) base.BaseGet(index); }
20 | set
21 | {
22 | if (base.BaseGet(index) != null)
23 | {
24 | base.BaseRemoveAt(index);
25 | }
26 | BaseAdd(index, value);
27 | }
28 | }
29 |
30 | public HostElement this[string name]
31 | {
32 | get { return (HostElement) base.BaseGet(name); }
33 | }
34 |
35 | public bool ContainsKey(string name)
36 | {
37 | bool flag = false;
38 | object[] objArray = base.BaseGetAllKeys();
39 | object[] objArray1 = objArray;
40 | int num = 0;
41 | while (num < objArray1.Length)
42 | {
43 | object obj = objArray1[num];
44 | if ((string) obj != name)
45 | {
46 | num++;
47 | }
48 | else
49 | {
50 | flag = true;
51 | break;
52 | }
53 | }
54 | return flag;
55 | }
56 |
57 | protected override ConfigurationElement CreateNewElement()
58 | {
59 | return new HostElement();
60 | }
61 |
62 | protected override object GetElementKey(ConfigurationElement element)
63 | {
64 | return ((HostElement) element).Name;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderState/MagicBoxCreated.cs:
--------------------------------------------------------------------------------
1 | using FXSharp.TradingPlatform.Exts;
2 |
3 | namespace FXSharp.EA.NewsBox
4 | {
5 | public class MagicBoxCreated : IOrderState
6 | {
7 | private readonly Order buyOrder;
8 | private readonly MagicBoxConfig mbConfig;
9 | private readonly OrderWatcher orderManager;
10 | private readonly Order sellOrder;
11 | private bool cancel;
12 |
13 | public MagicBoxCreated(OrderWatcher orderManager, Order buyOrder, Order sellOrder, MagicBoxConfig config)
14 | {
15 | this.orderManager = orderManager;
16 | this.buyOrder = buyOrder;
17 | this.sellOrder = sellOrder;
18 | mbConfig = config;
19 | }
20 |
21 | public void Manage()
22 | {
23 | // also expired by timer => should attached expired the pending order.. not do it manually.
24 | // i think we should make sure the order dissapear
25 |
26 | if (buyOrder.IsRunning)
27 | {
28 | buyOrder.ChangeTakeProfitInPoints(mbConfig.TakeProfit);
29 | buyOrder.ChangeStopLossInPoints(mbConfig.StopLoss);
30 | sellOrder.Close();
31 | orderManager.OrderRunning(buyOrder, new TrailingMethod(buyOrder));
32 | }
33 | else if (sellOrder.IsRunning)
34 | {
35 | sellOrder.ChangeTakeProfitInPoints(mbConfig.TakeProfit);
36 | sellOrder.ChangeStopLossInPoints(mbConfig.StopLoss);
37 | buyOrder.Close();
38 | orderManager.OrderRunning(sellOrder, new TrailingMethod(sellOrder));
39 | }
40 | else if (cancel)
41 | {
42 | buyOrder.Close();
43 | sellOrder.Close();
44 | orderManager.MagicBoxCompleted();
45 | // should describe event better, so we can publish it to different endpoint
46 | }
47 | }
48 |
49 |
50 | public void Cancel()
51 | {
52 | cancel = true;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | # Click-Once directory
76 | publish
77 |
78 | # Publish Web Output
79 | *.Publish.xml
80 |
81 | # NuGet Packages Directory
82 | packages
83 |
84 | # Windows Azure Build Output
85 | csx
86 | *.build.csdef
87 |
88 | # Windows Store app package directory
89 | AppPackages/
90 |
91 | # Others
92 | [Bb]in
93 | [Oo]bj
94 | sql
95 | TestResults
96 | [Tt]est[Rr]esult*
97 | *.Cache
98 | ClientBin
99 | [Ss]tyle[Cc]op.*
100 | ~$*
101 | *.dbmdl
102 | Generated_Code #added for RIA/Silverlight projects
103 |
104 | # Backup & report files from converting an old project file to a newer
105 | # Visual Studio version. Backup files are not needed, because we have git ;-)
106 | _UpgradeReport_Files/
107 | Backup*/
108 | UpgradeLog*.XML
109 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Config/HandlerElementCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace TradePlatform.MT4.Core.Config
4 | {
5 | public class HandlerElementCollection : ConfigurationElementCollection
6 | {
7 | public override ConfigurationElementCollectionType CollectionType
8 | {
9 | get { return ConfigurationElementCollectionType.BasicMap; }
10 | }
11 |
12 | protected override string ElementName
13 | {
14 | get { return "Handler"; }
15 | }
16 |
17 | public HandlerElement this[int index]
18 | {
19 | get { return (HandlerElement) base.BaseGet(index); }
20 | set
21 | {
22 | if (base.BaseGet(index) != null)
23 | {
24 | base.BaseRemoveAt(index);
25 | }
26 | BaseAdd(index, value);
27 | }
28 | }
29 |
30 | public HandlerElement this[string name]
31 | {
32 | get { return (HandlerElement) base.BaseGet(name); }
33 | }
34 |
35 | public bool ContainsKey(string name)
36 | {
37 | bool flag = false;
38 | object[] objArray = base.BaseGetAllKeys();
39 | object[] objArray1 = objArray;
40 | int num = 0;
41 | while (num < objArray1.Length)
42 | {
43 | object obj = objArray1[num];
44 | if ((string) obj != name)
45 | {
46 | num++;
47 | }
48 | else
49 | {
50 | flag = true;
51 | break;
52 | }
53 | }
54 | return flag;
55 | }
56 |
57 | protected override ConfigurationElement CreateNewElement()
58 | {
59 | return new HandlerElement();
60 | }
61 |
62 | protected override object GetElementKey(ConfigurationElement element)
63 | {
64 | return ((HandlerElement) element).Name;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/Indicators/PrevDayHighLowIndicator.cs:
--------------------------------------------------------------------------------
1 | using TradePlatform.MT4.Core;
2 | using TradePlatform.MT4.SDK.API;
3 |
4 | namespace TradePlatform.MT4.SDK.Library.Indicators
5 | {
6 | public class PrevDayHighLowIndicator : ExpertAdvisor
7 | {
8 | private double _dayHigh;
9 | private double _dayHigh1;
10 | private double _dayLow;
11 | private double _dayLow1;
12 |
13 | protected override int Init()
14 | {
15 | return 1;
16 | }
17 |
18 | protected override int Start()
19 | {
20 | int counted_bars = this.IndicatorCounted();
21 | if (counted_bars < 0) return (-1);
22 | if (counted_bars > 0) counted_bars--;
23 |
24 | int limit = this.Bars() - counted_bars;
25 |
26 | for (int i = limit; i >= 0; i--)
27 | {
28 | this.ExtMapBuffer1(i, _dayHigh1);
29 | this.ExtMapBuffer2(i, _dayLow1);
30 |
31 | if (this.High(i + 1) > _dayHigh) _dayHigh = this.High(i + 1);
32 | if (this.Low(i + 1) < _dayLow) _dayLow = this.Low(i + 1);
33 |
34 |
35 | if (this.Time(i).Day != this.Time(i + 1).Day && this.Time(i + 1).DayOfWeek != 0)
36 | {
37 | _dayHigh1 = _dayHigh;
38 | _dayLow1 = _dayLow;
39 | _dayHigh = this.Open(i);
40 | _dayLow = this.Open(i);
41 | }
42 | }
43 |
44 | return 1;
45 | }
46 |
47 | protected override int DeInit()
48 | {
49 | return 1;
50 | }
51 | }
52 |
53 | public static class PrevDayHightIndicatorExtensions
54 | {
55 | public static void ExtMapBuffer1(this MqlHandler handler, int index, double value)
56 | {
57 | string retrunValue = handler.CallMqlMethod("ExtMapBuffer1", index, value);
58 | }
59 |
60 | public static void ExtMapBuffer2(this MqlHandler handler, int index, double value)
61 | {
62 | string retrunValue = handler.CallMqlMethod("ExtMapBuffer2", index, value);
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/Convertor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 |
4 | namespace TradePlatform.MT4.Core.Utils
5 | {
6 | public static class Convertor
7 | {
8 | public static bool ToBoolean(string value)
9 | {
10 | bool flag;
11 | try
12 | {
13 | flag = value == "1";
14 | }
15 | catch (Exception exception1)
16 | {
17 | Exception exception = exception1;
18 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
19 | throw;
20 | }
21 | return flag;
22 | }
23 |
24 | public static DateTime ToDateTime(string value)
25 | {
26 | DateTime dateTime;
27 | try
28 | {
29 | dateTime = DateTime.Parse(value);
30 | }
31 | catch (Exception exception1)
32 | {
33 | Exception exception = exception1;
34 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
35 | throw;
36 | }
37 | return dateTime;
38 | }
39 |
40 | public static double ToDouble(string value)
41 | {
42 | double num;
43 | try
44 | {
45 | num = double.Parse(value);
46 | }
47 | catch (Exception exception1)
48 | {
49 | Exception exception = exception1;
50 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
51 | throw;
52 | }
53 | return num;
54 | }
55 |
56 | public static int ToInt(string value)
57 | {
58 | int num;
59 | try
60 | {
61 | num = int.Parse(value);
62 | }
63 | catch (Exception exception1)
64 | {
65 | Exception exception = exception1;
66 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Execption, exception, ""));
67 | throw;
68 | }
69 | return num;
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox.Specs/When_receive_all_economic_event_with_different_time.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using NUnit.Framework;
5 |
6 | namespace FXSharp.EA.NewsBox.Specs
7 | {
8 | [TestFixture]
9 | public class When_receive_all_economic_event_with_different_time
10 | {
11 | [Test]
12 | public void Should_Create_speech_trade()
13 | {
14 | DateTime time = DateTime.Now;
15 |
16 | var evtList = new List
17 | {
18 | new EconomicEvent {Currency = "USD", DateTime = time.AddMinutes(20)},
19 | new EconomicEvent {Currency = "CHF", DateTime = time.AddMinutes(30)}
20 | };
21 |
22 | var creator = new OrderCreator();
23 | IList lst = creator.CreateOrdersFromEvents(evtList);
24 |
25 | Assert.IsTrue(evtList.First().IsSpeechOrMeeting);
26 |
27 | MagicBoxConfig config = lst.First().Config;
28 |
29 | Assert.AreEqual(-1, config.MinutePendingExecution);
30 | Assert.AreEqual(30, config.MinuteExpiracy);
31 | Assert.AreEqual(250, config.Range);
32 | Assert.AreEqual(200, config.StopLoss);
33 | Assert.AreEqual(150, config.TakeProfit);
34 | }
35 |
36 | [Test]
37 | public void Should_create_different_order()
38 | {
39 | DateTime time = DateTime.Now;
40 |
41 | var evtList = new List
42 | {
43 | new EconomicEvent {Currency = "USD", DateTime = time.AddMinutes(20), Previous = "123"},
44 | new EconomicEvent {Currency = "CHF", DateTime = time.AddMinutes(30), Previous = "123"}
45 | };
46 |
47 | var creator = new OrderCreator();
48 | IList lst = creator.CreateOrdersFromEvents(evtList);
49 |
50 | Assert.AreEqual(2, lst.Count);
51 |
52 | MagicBoxConfig config = lst.First().Config;
53 |
54 | Assert.AreEqual(-1, config.MinutePendingExecution);
55 | Assert.AreEqual(10, config.MinuteExpiracy);
56 | Assert.AreEqual(50, config.Range);
57 | Assert.AreEqual(200, config.StopLoss);
58 | Assert.AreEqual(150, config.TakeProfit);
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/NewsReminder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Threading.Tasks;
4 | using Quartz;
5 | using Quartz.Impl;
6 |
7 | namespace FXSharp.EA.NewsBox
8 | {
9 | public class NewsReminder
10 | {
11 | private readonly DailyEconomicScheduler _economicScheduler;
12 | private readonly ConcurrentQueue _orderQueue = new ConcurrentQueue();
13 | private readonly IScheduler _sched;
14 | private readonly ISchedulerFactory _schedFact = new StdSchedulerFactory();
15 |
16 | public NewsReminder()
17 | {
18 | _sched = _schedFact.GetScheduler();
19 | _economicScheduler = new DailyEconomicScheduler(_sched, _orderQueue);
20 | }
21 |
22 | public ConcurrentQueue OrderQueue
23 | {
24 | get { return _orderQueue; }
25 | }
26 |
27 | public bool IsAvailable
28 | {
29 | get { return _orderQueue.Count > 0; }
30 | }
31 |
32 | internal void Start()
33 | {
34 | _sched.Start();
35 |
36 | LoadDailyEconomicCalendar();
37 |
38 | StartDailyEconomicCalendar();
39 | }
40 |
41 | private void LoadDailyEconomicCalendar()
42 | {
43 | Task task = _economicScheduler.PrepareDailyReminder();
44 | }
45 |
46 | private void StartDailyEconomicCalendar()
47 | {
48 | IJobDetail jobDetail = JobBuilder.Create()
49 | .WithIdentity(DateTime.Now.ToString(), "group1")
50 | .Build();
51 |
52 | DateTime nexttime = DateTime.Now.AddSeconds(2);
53 |
54 | ITrigger trigger = TriggerBuilder.Create()
55 | .WithIdentity(DateTime.Now.ToString(), "group1")
56 | .StartNow()
57 | .WithCronSchedule("0 01 00 * * ?") // everyday at 00 01
58 | .Build();
59 |
60 | jobDetail.JobDataMap.Add("scheduler", _economicScheduler);
61 |
62 | _sched.ScheduleJob(jobDetail, trigger);
63 | }
64 |
65 | internal void Stop()
66 | {
67 | _sched.Shutdown();
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderWatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using FXSharp.TradingPlatform.Exts;
3 | using FXSharp.EA.OrderManagements;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class OrderWatcher
8 | {
9 | private readonly double expiredTime;
10 | private readonly MagicBoxConfig mbConfig;
11 | private ExpiracyTimer expiracyTimer;
12 | private IOrderState state;
13 |
14 | public OrderWatcher(Order buyOrder, Order sellOrder, double expiredTime, MagicBoxConfig config)
15 | {
16 | mbConfig = config;
17 | AddOneCancelAnother(buyOrder, sellOrder);
18 | Symbol = buyOrder.Symbol;
19 |
20 | this.expiredTime = expiredTime;
21 |
22 | expiracyTimer = new ExpiracyTimer(expiredTime/2);
23 | expiracyTimer.Expired += expiracyTimer_Expired;
24 | }
25 |
26 | public string Symbol { get; set; }
27 | public event EventHandler OrderClosed;
28 |
29 | private void expiracyTimer_Expired(object sender, EventArgs e)
30 | {
31 | if (state == null) return;
32 |
33 | state.Cancel();
34 | expiracyTimer.Expired -= expiracyTimer_Expired;
35 | }
36 |
37 | internal void ManageOrder()
38 | {
39 | if (state == null) return;
40 |
41 | state.Manage();
42 | }
43 |
44 | private void AddOneCancelAnother(Order buyOrder, Order sellOrder)
45 | {
46 | state = new MagicBoxCreated(this, buyOrder, sellOrder, mbConfig);
47 | }
48 |
49 | // we should use event based for this
50 | internal void OrderRunning(Order order, IProfitProtector trailing)
51 | {
52 | ResetExpiracy();
53 |
54 | state = new OrderAlreadyRunning(this, order, trailing);
55 | }
56 |
57 | private void ResetExpiracy()
58 | {
59 | expiracyTimer.Finish();
60 | expiracyTimer.Expired -= expiracyTimer_Expired;
61 | expiracyTimer = new ExpiracyTimer(expiredTime);
62 | expiracyTimer.Expired += expiracyTimer_Expired;
63 | }
64 |
65 | // we should use event based for this
66 | internal void MagicBoxCompleted()
67 | {
68 | // should create default state
69 | expiracyTimer.Finish();
70 | expiracyTimer.Expired -= expiracyTimer_Expired;
71 |
72 | state = null;
73 | OnOrderClosed();
74 | }
75 |
76 | private void OnOrderClosed()
77 | {
78 | if (OrderClosed == null) return;
79 | OrderClosed(this, EventArgs.Empty);
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/ConsoleBridgeTraceListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TradePlatform.MT4.Core.Utils
4 | {
5 | public class ConsoleBridgeTraceListener : BridgeTraceListener
6 | {
7 | public override void Output(TraceInfo info)
8 | {
9 | BridgeTraceErrorType type = info.Type;
10 | switch (type)
11 | {
12 | case BridgeTraceErrorType.Execption:
13 | {
14 | Console.BackgroundColor = ConsoleColor.Red;
15 | Console.ForegroundColor = ConsoleColor.White;
16 | Console.WriteLine(info.Message);
17 | return;
18 | }
19 | case BridgeTraceErrorType.HandlerExecutionError:
20 | {
21 | Console.BackgroundColor = ConsoleColor.Blue;
22 | Console.ForegroundColor = ConsoleColor.Yellow;
23 | Console.WriteLine(info.Message);
24 | return;
25 | }
26 | case BridgeTraceErrorType.MqlError:
27 | {
28 | Console.BackgroundColor = ConsoleColor.Yellow;
29 | Console.ForegroundColor = ConsoleColor.Black;
30 | Console.WriteLine(info.Message);
31 | return;
32 | }
33 | case BridgeTraceErrorType.HostInfo:
34 | {
35 | Console.BackgroundColor = ConsoleColor.Black;
36 | Console.ForegroundColor = ConsoleColor.Green;
37 | Console.WriteLine(info.Message);
38 | return;
39 | }
40 | case BridgeTraceErrorType.CommunicationWorkflow:
41 | {
42 | Console.BackgroundColor = ConsoleColor.Black;
43 | Console.ForegroundColor = ConsoleColor.Gray;
44 | Console.WriteLine(info.Message);
45 | return;
46 | }
47 | case BridgeTraceErrorType.Service:
48 | {
49 | Console.BackgroundColor = ConsoleColor.Black;
50 | Console.ForegroundColor = ConsoleColor.Cyan;
51 | Console.WriteLine(info.Message);
52 | return;
53 | }
54 | case BridgeTraceErrorType.Debug:
55 | {
56 | Console.BackgroundColor = ConsoleColor.Black;
57 | Console.ForegroundColor = ConsoleColor.Yellow;
58 | Console.WriteLine(info.Message);
59 | return;
60 | }
61 | }
62 | throw new ArgumentOutOfRangeException("Type");
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/Utils/BridgeTraceListener.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core.Exceptions;
3 |
4 | namespace TradePlatform.MT4.Core.Utils
5 | {
6 | public abstract class BridgeTraceListener : TraceListener
7 | {
8 | public abstract void Output(TraceInfo info);
9 |
10 | public override void Write(object TraceInfo)
11 | {
12 | try
13 | {
14 | if (TraceInfo is TraceInfo)
15 | {
16 | var traceInfo = TraceInfo as TraceInfo;
17 | Output(traceInfo);
18 | if ((traceInfo.Type == BridgeTraceErrorType.Execption ||
19 | traceInfo.Type == BridgeTraceErrorType.HandlerExecutionError) &&
20 | Bridge.Configuration.UseEventLog)
21 | {
22 | if (!EventLog.SourceExists(traceInfo.Type.ToString()))
23 | {
24 | EventLog.CreateEventSource(traceInfo.Type.ToString(), "TradePlatform.MT4");
25 | }
26 | var eventLog = new EventLog();
27 | eventLog.Source = traceInfo.Type.ToString();
28 | if (traceInfo.Exception == null)
29 | {
30 | eventLog.WriteEntry(traceInfo.Message, EventLogEntryType.Error);
31 | }
32 | else
33 | {
34 | string empty = string.Empty;
35 | while (traceInfo.Exception != null)
36 | {
37 | empty = string.Concat(empty, traceInfo.Exception, "\n\n");
38 | traceInfo.Exception = traceInfo.Exception.InnerException;
39 | }
40 | eventLog.WriteEntry(empty, EventLogEntryType.Error);
41 | }
42 | }
43 | }
44 | else
45 | {
46 | throw new ConsoleTraceListenerException(TraceInfo,
47 | "Use 'Write(object)' override and pass 'TraceInfo' instance");
48 | }
49 | }
50 | catch
51 | {
52 | }
53 | }
54 |
55 | public override void Write(string message)
56 | {
57 | throw new ConsoleTraceListenerException(message,
58 | "Use 'Write(object)' override and pass 'TraceInfo' instance");
59 | }
60 |
61 | public override void WriteLine(string message)
62 | {
63 | throw new ConsoleTraceListenerException(message,
64 | "Use 'Write(object)' override and pass 'TraceInfo' instance");
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/FXSharp.EA.OrderManagements/FXSharp.EA.OrderManagements.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F864A993-0025-44A7-8517-9D216B93B29F}
8 | Library
9 | Properties
10 | FXSharp.EA.OrderManagements
11 | FXSharp.EA.OrderManagements
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {e33f0f2b-6fbd-4e1c-9981-510dd229c58e}
50 | FXSharp.TradingPlatform.Exts
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.Core/MT4.Core/MetaTrader4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using TradePlatform.MT4.Core.Exceptions;
5 |
6 | namespace TradePlatform.MT4.Core
7 | {
8 | public class MetaTrader4
9 | {
10 | private static readonly Dictionary _listeners;
11 |
12 | private static readonly object _listernerLock;
13 |
14 | private readonly Queue> _functionsBuffer = new Queue>();
15 |
16 | static MetaTrader4()
17 | {
18 | _listeners = new Dictionary();
19 | _listernerLock = new object();
20 | }
21 |
22 | private MetaTrader4(int accountNumber, string symbol)
23 | {
24 | AccountNumber = accountNumber;
25 | Symbol = symbol;
26 | }
27 |
28 | public int AccountNumber { get; private set; }
29 |
30 | public string Symbol { get; private set; }
31 |
32 | internal static List All()
33 | {
34 | List list;
35 | lock (_listernerLock)
36 | {
37 | Dictionary strs = _listeners;
38 | list = strs.Select((KeyValuePair x) => x.Value).ToList();
39 | }
40 | return list;
41 | }
42 |
43 | internal static MetaTrader4 For(int accountNumber, string symbol)
44 | {
45 | MetaTrader4 item;
46 | lock (_listernerLock)
47 | {
48 | string str = string.Concat(accountNumber, symbol);
49 | if (!_listeners.ContainsKey(str))
50 | {
51 | var metaTrader4 = new MetaTrader4(accountNumber, symbol);
52 | _listeners.Add(str, metaTrader4);
53 | item = metaTrader4;
54 | }
55 | else
56 | {
57 | item = _listeners[str];
58 | }
59 | }
60 | return item;
61 | }
62 |
63 | public void MqlScope(Action mqlScope)
64 | {
65 | _functionsBuffer.Enqueue(mqlScope);
66 | }
67 |
68 | public void OnMqlError(MqlErrorException mqlErrorException)
69 | {
70 | if (MqlError != null)
71 | {
72 | MqlError(mqlErrorException);
73 | }
74 | }
75 |
76 | internal void OnQuote(QuoteListener quoteListener)
77 | {
78 | while (_functionsBuffer.Count > 0)
79 | {
80 | Action action = _functionsBuffer.Dequeue();
81 | action(quoteListener);
82 | }
83 | if (QuoteRecieved != null)
84 | {
85 | QuoteRecieved(quoteListener);
86 | }
87 | }
88 |
89 | public event Action MqlError;
90 |
91 | public event Action QuoteRecieved;
92 | }
93 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.Core", "TradePlatform.MT4.Core\TradePlatform.MT4.Core.csproj", "{65AA3653-CE56-4029-A9AD-46D5CAA45829}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Library", "TradePlatform.MT4.SDK\TradePlatform.MT4.SDK.Library\TradePlatform.MT4.SDK.Library.csproj", "{6B024C9D-EAE3-4450-981B-625D7A56A3ED}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.API", "TradePlatform.MT4.SDK\TradePlatform.MT4.SDK.API\TradePlatform.MT4.SDK.API.csproj", "{44136017-54EE-4868-9557-ACB70B85BD7C}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Shell", "TradePlatform.MT4.SDK\TradePlatform.MT4.SDK.Shell\TradePlatform.MT4.SDK.Shell.csproj", "{7DA7D09D-4069-4009-B97A-9B196BD40C16}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Win", "TradePlatform.MT4.SDK\TradePlatform.MT4.SDK.Win\TradePlatform.MT4.SDK.Win.csproj", "{CE148CA3-0464-445B-9807-EE471462DD5A}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {65AA3653-CE56-4029-A9AD-46D5CAA45829}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {65AA3653-CE56-4029-A9AD-46D5CAA45829}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {65AA3653-CE56-4029-A9AD-46D5CAA45829}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {65AA3653-CE56-4029-A9AD-46D5CAA45829}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Release|Any CPU.Build.0 = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(SolutionProperties) = preSolution
42 | HideSolutionNode = FALSE
43 | EndGlobalSection
44 | EndGlobal
45 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.API", "TradePlatform.MT4.SDK.API\TradePlatform.MT4.SDK.API.csproj", "{44136017-54EE-4868-9557-ACB70B85BD7C}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Shell", "TradePlatform.MT4.SDK.Shell\TradePlatform.MT4.SDK.Shell.csproj", "{7DA7D09D-4069-4009-B97A-9B196BD40C16}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Win", "TradePlatform.MT4.SDK.Win\TradePlatform.MT4.SDK.Win.csproj", "{CE148CA3-0464-445B-9807-EE471462DD5A}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradePlatform.MT4.SDK.Library", "TradePlatform.MT4.SDK.Library\TradePlatform.MT4.SDK.Library.csproj", "{6B024C9D-EAE3-4450-981B-625D7A56A3ED}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{BFC4BFA4-F852-46B6-9528-061FA0FF7E2C}"
13 | ProjectSection(SolutionItems) = preProject
14 | Components\TradePlatform.MT4.Core.dll = Components\TradePlatform.MT4.Core.dll
15 | Components\TradePlatform.MT4.Data.dll = Components\TradePlatform.MT4.Data.dll
16 | EndProjectSection
17 | EndProject
18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{F6017EC5-EC61-47E4-80D6-BF0339854D0E}"
19 | ProjectSection(SolutionItems) = preProject
20 | SharedAssemblyInfo.cs = SharedAssemblyInfo.cs
21 | EndProjectSection
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Release|Any CPU = Release|Any CPU
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {44136017-54EE-4868-9557-ACB70B85BD7C}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {7DA7D09D-4069-4009-B97A-9B196BD40C16}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {CE148CA3-0464-445B-9807-EE471462DD5A}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {6B024C9D-EAE3-4450-981B-625D7A56A3ED}.Release|Any CPU.Build.0 = Release|Any CPU
45 | EndGlobalSection
46 | GlobalSection(SolutionProperties) = preSolution
47 | HideSolutionNode = FALSE
48 | EndGlobalSection
49 | EndGlobal
50 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Win/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace TradePlatform.MT4.SDK.Win
5 | {
6 | using TradePlatform.MT4.Core;
7 | using TradePlatform.MT4.Core.Exceptions;
8 | using TradePlatform.MT4.SDK.API;
9 |
10 | public partial class Form1 : Form
11 | {
12 | private MetaTrader4 metaTrader4;
13 |
14 | public Form1()
15 | {
16 | InitializeComponent();
17 |
18 | Bridge.InitializeHosts(true);
19 |
20 | //metaTrader4 = Bridge.GetTerminal(126728, "EURUSD");
21 | //metaTrader4.QuoteRecieved += metaTrader4_QuoteRecieved;
22 | //metaTrader4.MqlError += metaTrader4_MqlError;
23 | }
24 |
25 | private void metaTrader4_MqlError(MqlErrorException mql)
26 | {
27 | // handler mql error
28 | }
29 |
30 | private void metaTrader4_QuoteRecieved(QuoteListener mql)
31 | {
32 | this.BeginInvoke((MethodInvoker) (() => dataGridView1.Rows.Clear()));
33 |
34 | for (int i = mql.OrdersTotal() - 1; i >= 0; i--)
35 | {
36 | if (mql.OrderSelect(i, SELECT_BY.SELECT_BY_POS))
37 | {
38 | int orderTicket = mql.OrderTicket();
39 | string orderSymbol = mql.OrderSymbol();
40 | double orderLots = mql.OrderLots();
41 | double orderProfit = mql.OrderProfit();
42 |
43 | this.BeginInvoke((MethodInvoker) (() => dataGridView1.Rows.Add(orderTicket, orderSymbol, orderLots, orderProfit, "Close")));
44 | }
45 | }
46 |
47 | double bid = mql.Bid();
48 | double ask = mql.Ask();
49 |
50 | this.BeginInvoke((MethodInvoker) (() => BidPrice.Text = bid.ToString()));
51 | this.BeginInvoke((MethodInvoker) (() => AskPrice.Text = ask.ToString()));
52 | }
53 |
54 | private void buttonBuy_Click(object sender, EventArgs e)
55 | {
56 | metaTrader4.MqlScope(mql => mql.OrderSend("EURUSD", ORDER_TYPE.OP_BUY, 1, mql.Ask(), 10, 0, 0));
57 | }
58 |
59 | private void buttonSell_Click(object sender, EventArgs e)
60 | {
61 | metaTrader4.MqlScope(mql => mql.OrderSend("EURUSD", ORDER_TYPE.OP_SELL, 1, mql.Bid(), 10, 0, 0));
62 | }
63 |
64 | private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
65 | {
66 | if (e.ColumnIndex == 4)
67 | {
68 | DataGridViewRow dataGridViewRow = dataGridView1.Rows[e.RowIndex];
69 | int value = (int) dataGridViewRow.Cells[0].Value;
70 | metaTrader4.MqlScope(mql =>
71 | {
72 | mql.OrderSelect(value, SELECT_BY.SELECT_BY_TICKET);
73 | if (mql.OrderType() == ORDER_TYPE.OP_BUY)
74 | {
75 | mql.OrderClose(value, mql.OrderLots(), mql.Bid(), 3);
76 | }
77 | else
78 | {
79 | mql.OrderClose(value, mql.OrderLots(), mql.Ask(), 3);
80 | }
81 | });
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/FXSharp.EA.MagicBox/FXSharp.EA.MagicBox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {8D51979F-FD94-4D4E-AEE3-C185CA37D9E3}
8 | Library
9 | Properties
10 | FXSharp.EA.MagicBox
11 | FXSharp.EA.MagicBox
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | {e33f0f2b-6fbd-4e1c-9981-510dd229c58e}
49 | FXSharp.TradingPlatform.Exts
50 |
51 |
52 | {65aa3653-ce56-4029-a9ad-46d5caa45829}
53 | TradePlatform.MT4.Core
54 |
55 |
56 | {44136017-54ee-4868-9557-acb70b85bd7c}
57 | TradePlatform.MT4.SDK.API
58 |
59 |
60 |
61 |
68 |
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/UnitTests/AccountInformationTests.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Utils;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.UnitTests
7 | {
8 | public static class AccountInformationTests
9 | {
10 | public static void RunTests(MqlHandler script)
11 | {
12 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
13 | message: "Test 'AccountBalance: " + script.AccountBalance() + "'"));
14 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
15 | message: "Test 'AccountCredit: " + script.AccountCredit() + "'"));
16 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
17 | message: "Test 'AccountCompany: " + script.AccountCompany() + "'"));
18 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
19 | message: "Test 'AccountCurrency: " + script.AccountCurrency() + "'"));
20 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
21 | message: "Test 'AccountEquity: " + script.AccountEquity() + "'"));
22 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
23 | message: "Test 'AccountFreeMargin: " + script.AccountFreeMargin() + "'"));
24 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
25 | message:
26 | "Test 'AccountFreeMarginCheck: " +
27 | script.AccountFreeMarginCheck("EURUSD", ORDER_TYPE.OP_BUY, 1) + "'"));
28 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
29 | message: "Test 'AccountFreeMarginMode: " + script.AccountFreeMarginMode() + "'"));
30 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
31 | message: "Test 'AccountLeverage: " + script.AccountLeverage() + "'"));
32 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
33 | message: "Test 'AccountMargin: " + script.AccountMargin() + "'"));
34 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
35 | message: "Test 'AccountName: " + script.AccountName() + "'"));
36 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
37 | message: "Test 'AccountNumber: " + script.AccountNumber() + "'"));
38 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
39 | message: "Test 'AccountProfit: " + script.AccountProfit() + "'"));
40 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
41 | message: "Test 'AccountServer: " + script.AccountServer() + "'"));
42 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
43 | message: "Test 'AccountStopoutLevel: " + script.AccountStopoutLevel() + "'"));
44 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
45 | message: "Test 'AccountStopoutMode: " + script.AccountStopoutMode() + "'"));
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/FXSharp.EA.NewsBox/OrderCreator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace FXSharp.EA.NewsBox
6 | {
7 | public class OrderCreator
8 | {
9 | private readonly MagicBoxConfig commonCfg = new MagicBoxConfig
10 | {
11 | MinutePendingExecution = -1, // 2-1 minute
12 | MinuteExpiracy = 10,
13 | Range = 100, // 5-10 pips
14 | StopLoss = 150,
15 | TakeProfit = 300
16 | };
17 |
18 | private readonly MagicBoxConfig speechCfg = new MagicBoxConfig
19 | {
20 | MinutePendingExecution = -1, // test for 2 minutes and change range
21 | MinuteExpiracy = 30, // 20 - 30 minutes
22 | Range = 200, // 20-25 minutes
23 | StopLoss = 200,
24 | TakeProfit = 500
25 | };
26 |
27 | private CurrencyPairRegistry analyzer = new CurrencyPairRegistry();
28 |
29 | public IList CreateOrdersFromEvents(IEnumerable events)
30 | {
31 | var mgcBoxOrderList = new List();
32 |
33 | IEnumerable> groups = events.GroupBy(x => x.DateTime);
34 |
35 | foreach (var eventGroup in groups)
36 | {
37 | if (IsSingleEvent(eventGroup))
38 | {
39 | AddSingleMagicBox(mgcBoxOrderList, eventGroup);
40 | }
41 | else // multiple and collide each other
42 | {
43 | AddMagicBoxGroup(mgcBoxOrderList, eventGroup);
44 | }
45 | }
46 |
47 | return mgcBoxOrderList;
48 | }
49 |
50 | private void AddMagicBoxGroup(List mgcBoxOrderList, IGrouping eventGroup)
51 | {
52 | // refactor the this events
53 |
54 | var currencyPairsCandidate = new List();
55 |
56 | foreach (EconomicEvent economicEvent in eventGroup.Distinct())
57 | {
58 | currencyPairsCandidate.Add(new MagicBoxOrder
59 | {
60 | Symbol = economicEvent.Currency,
61 | LotSize = 1,
62 | Config = speechCfg,
63 | NewsTime = economicEvent.DateTime
64 | });
65 | }
66 |
67 | mgcBoxOrderList.AddRange(currencyPairsCandidate.Distinct());
68 | }
69 |
70 | private void AddSingleMagicBox(List mgcBoxOrderList,
71 | IGrouping eventGroup)
72 | {
73 | EconomicEvent singleEvent = eventGroup.Single();
74 |
75 | mgcBoxOrderList.Add(new MagicBoxOrder
76 | {
77 | Symbol = singleEvent.Currency,
78 | LotSize = 1,
79 | Config = SelectConfig(singleEvent),
80 | NewsTime = singleEvent.DateTime
81 | });
82 | }
83 |
84 | private static bool IsSingleEvent(IGrouping item)
85 | {
86 | return item.Count() == 1;
87 | }
88 |
89 | private MagicBoxConfig SelectConfig(EconomicEvent eventx)
90 | {
91 | return eventx.IsSpeechOrMeeting ? speechCfg : commonCfg;
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/CurrencyPairRegistry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using FXSharp.TradingPlatform.Exts;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace FXSharp.EA.NewsBox
7 | {
8 | public class CurrencyPairRegistry
9 | {
10 | private static readonly Dictionary currencyToPair = new Dictionary
11 | {
12 | {"NZD", "NZDUSD"},
13 | {"AUD", "AUDUSD"},
14 | {"CNY", "AUDUSD"},
15 | {"JPY", "USDJPY"},
16 | {"CHF", "USDCHF"},
17 | {"EUR", "EURUSD"},
18 | {"GBP", "GBPUSD"},
19 | {"CAD", "USDCAD"},
20 | {"USD", "EURUSD"}
21 | };
22 |
23 | private static readonly IList currenciesPriorities = new List
24 | {
25 | "EUR",
26 | "GBP",
27 | "AUD",
28 | "NZD",
29 | "USD",
30 | "CAD",
31 | "CHF",
32 | "JPY"
33 | };
34 |
35 | private static IList currencyPairs = new List();
36 |
37 | static CurrencyPairRegistry()
38 | {
39 | for (int i = 0; i < currenciesPriorities.Count - 1; i++)
40 | {
41 | for (int j = i + 1; j < currenciesPriorities.Count; j++)
42 | {
43 | currencyPairs.Add(string.Format("{0}{1}", currenciesPriorities[i], currenciesPriorities[j]));
44 | }
45 | }
46 |
47 | RemoveUnregisteredCurrencies();
48 |
49 | //RemoveHighSpreadCurrencies();
50 | }
51 |
52 | public static IList CurrencyPairs
53 | {
54 | get { return currencyPairs; }
55 | }
56 |
57 | public static void FilterCurrencyForMinimalSpread(EExpertAdvisor ea)
58 | {
59 | currencyPairs = GetLowSpreadsCurrencies(ea).ToList();
60 | //currencyPairs.Remove("GBPNZD");
61 | }
62 |
63 | private static IEnumerable GetLowSpreadsCurrencies(EExpertAdvisor ea)
64 | {
65 | var spreadInfos = new List();
66 |
67 | foreach (string pair in CurrencyPairs)
68 | {
69 | double spread = ea.MarketInfo(pair, MARKER_INFO_MODE.MODE_SPREAD);
70 | spreadInfos.Add(new SpreadInfo {Symbol = pair, Spread = spread});
71 | }
72 |
73 | IEnumerable results = from s in spreadInfos
74 | where s.Spread <= 30
75 | orderby s.Spread ascending
76 | select s.Symbol;
77 |
78 | return results;
79 | }
80 |
81 | private static void RemoveUnregisteredCurrencies()
82 | {
83 | currencyPairs.Remove("NZDCAD");
84 | currencyPairs.Remove("NZDCHF");
85 | }
86 |
87 | public string RelatedCurrencyPair(string currency)
88 | {
89 | return currencyToPair[currency];
90 | }
91 |
92 | public IEnumerable RelatedCurrencyPairs(string currency)
93 | {
94 | IEnumerable result = from s in currencyPairs
95 | where s.Contains(currency)
96 | select s;
97 |
98 | return result;
99 | }
100 | }
101 | }
--------------------------------------------------------------------------------
/TradePlatform.MT4/TradePlatform.MT4.SDK/TradePlatform.MT4.SDK.Library/UnitTests/WindowFunctionsTests.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using TradePlatform.MT4.Core;
3 | using TradePlatform.MT4.Core.Utils;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace TradePlatform.MT4.SDK.Library.UnitTests
7 | {
8 | public static class WindowFunctionsTests
9 | {
10 | public static void RunTests(MqlHandler script)
11 | {
12 | script.HideTestIndicators(false);
13 | script.WindowRedraw();
14 |
15 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug, message: "Test 'Period: " + script.Period() + "'"));
16 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
17 | message: "Test 'RefreshRates: " + script.RefreshRates() + "'"));
18 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
19 | message: "Test 'WindowBarsPerChart: " + script.WindowBarsPerChart() + "'"));
20 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
21 | message: "Test 'WindowExpertName: " + script.WindowExpertName() + "'"));
22 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
23 | message: "Test 'WindowFind: " + script.WindowFind("Test") + "'"));
24 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
25 | message: "Test 'WindowFirstVisibleBar: " + script.WindowFirstVisibleBar() + "'"));
26 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
27 | message:
28 | "Test 'WindowHandle: " +
29 | script.WindowHandle(SYMBOLS.EURUSD, TIME_FRAME.PERIOD_H1) + "'"));
30 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
31 | message: "Test 'WindowIsVisible: " + script.WindowIsVisible(0) + "'"));
32 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
33 | message: "Test 'WindowOnDropped: " + script.WindowOnDropped() + "'"));
34 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
35 | message: "Test 'WindowPriceMax: " + script.WindowPriceMax() + "'"));
36 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
37 | message: "Test 'WindowPriceMin: " + script.WindowPriceMin() + "'"));
38 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
39 | message: "Test 'WindowPriceOnDropped: " + script.WindowPriceOnDropped() + "'"));
40 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
41 | message:
42 | "Test 'WindowScreenShot: " + script.WindowScreenShot("test.bmp", 200, 200) +
43 | "'"));
44 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
45 | message: "Test 'WindowTimeOnDropped: " + script.WindowTimeOnDropped() + "'"));
46 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
47 | message: "Test 'WindowsTotal: " + script.WindowsTotal() + "'"));
48 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
49 | message: "Test 'WindowXOnDropped: " + script.WindowXOnDropped() + "'"));
50 | Trace.Write(new TraceInfo(BridgeTraceErrorType.Debug,
51 | message: "Test 'WindowYOnDropped: " + script.WindowYOnDropped() + "'"));
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/FXSharp.EA.FirstTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {09D4D2C3-05E1-4586-A2F2-66DB0A8C9E83}
8 | Library
9 | Properties
10 | FXSharp.EA.FirstTest
11 | FXSharp.EA.FirstTest
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | {e33f0f2b-6fbd-4e1c-9981-510dd229c58e}
56 | FXSharp.TradingPlatform.Exts
57 |
58 |
59 | {65aa3653-ce56-4029-a9ad-46d5caa45829}
60 | TradePlatform.MT4.Core
61 |
62 |
63 | {44136017-54ee-4868-9557-acb70b85bd7c}
64 | TradePlatform.MT4.SDK.API
65 |
66 |
67 |
68 |
75 |
--------------------------------------------------------------------------------
/FXSharp.EA.FirstTest/MyExpertAdvisor.cs:
--------------------------------------------------------------------------------
1 | //using TradePlatform.MT4.Data;
2 |
3 | using System;
4 | using System.Threading;
5 | using FXSharp.TradingPlatform.Exts;
6 | using TradePlatform.MT4.SDK.API;
7 |
8 | namespace FXSharp.EA.FirstTest
9 | {
10 | public class MyExpertAdvisor : EExpertAdvisor
11 | {
12 | private QuoteBeat beat;
13 | private int count = 0;
14 |
15 | private bool isInitialize;
16 | private Order order;
17 | private double threshold = 3;
18 |
19 | protected override int Init()
20 | {
21 | beat = new QuoteBeat();
22 | beat.Add(new Quote(Bid, Ask));
23 |
24 | isInitialize = true;
25 |
26 | return 1;
27 | }
28 |
29 | protected override int DeInit()
30 | {
31 | return 1;
32 | }
33 |
34 | protected override int Start()
35 | {
36 | if (!isInitialize)
37 | {
38 | Init();
39 | }
40 |
41 | // should introduce event and directly buy or sell
42 | // should create new object for decision making.
43 |
44 | while (true)
45 | {
46 | RefreshRates();
47 |
48 | beat.Add(new Quote(Bid, Ask));
49 |
50 | PrintReport(beat);
51 |
52 | if (beat.LastDelta >= threshold)
53 | {
54 | if (IsNoOpenOrder())
55 | {
56 | Console.WriteLine("No Open Order");
57 | order = Buy(1);
58 |
59 | //order.ChangeStopLossInPoints(100);
60 | order.ChangeTakeProfitInPoints(40);
61 | }
62 | else
63 | {
64 | if (IsAlreadyOpenBuy()) return 1;
65 |
66 | order.Close();
67 |
68 | order = Buy(1);
69 | //order.ChangeStopLossInPoints(100);
70 | order.ChangeTakeProfitInPoints(40);
71 | }
72 | }
73 | else if (Math.Abs(beat.LastDelta) >= threshold)
74 | {
75 | if (IsNoOpenOrder())
76 | {
77 | Console.WriteLine("No Open Order");
78 | order = Sell(1);
79 | //order.ChangeStopLossInPoints(100);
80 | order.ChangeTakeProfitInPoints(40);
81 | }
82 | else
83 | {
84 | if (IsAlreadyOpenSell()) return 1;
85 |
86 | order.Close();
87 | order = Sell(1);
88 | //order.ChangeStopLossInPoints(100);
89 | order.ChangeTakeProfitInPoints(40);
90 | }
91 | }
92 |
93 | Thread.Sleep(500);
94 | }
95 |
96 |
97 | return 1;
98 | }
99 |
100 | private void PrintReport(QuoteBeat beat)
101 | {
102 | Console.WriteLine("Delta Bid : {0}, Ask : {1}", beat.DeltaBid, beat.DeltaAsk);
103 | Console.WriteLine("Max Up : {0}, Down : {1}", beat.MaxUp, beat.MaxDown);
104 | }
105 |
106 | private bool IsAlreadyOpenSell()
107 | {
108 | return order.OrderType == ORDER_TYPE.OP_SELL;
109 | }
110 |
111 | private bool IsAlreadyOpenBuy()
112 | {
113 | return order.OrderType == ORDER_TYPE.OP_BUY;
114 | }
115 |
116 | private bool IsNoOpenOrder()
117 | {
118 | return order == null || !order.IsOpen;
119 | }
120 | }
121 | }
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/FXSharp.EA.PinBar.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {55C80730-D36C-4561-8664-0DD936F0E047}
8 | Library
9 | Properties
10 | FXSharp.EA.PinBar
11 | FXSharp.EA.PinBar
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | {f864a993-0025-44a7-8517-9d216b93b29f}
52 | FXSharp.EA.OrderManagements
53 |
54 |
55 | {e33f0f2b-6fbd-4e1c-9981-510dd229c58e}
56 | FXSharp.TradingPlatform.Exts
57 |
58 |
59 | {65aa3653-ce56-4029-a9ad-46d5caa45829}
60 | TradePlatform.MT4.Core
61 |
62 |
63 | {44136017-54ee-4868-9557-acb70b85bd7c}
64 | TradePlatform.MT4.SDK.API
65 |
66 |
67 |
68 |
75 |
--------------------------------------------------------------------------------
/FXSharp.EA.PinBar/PinBarEA.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using FXSharp.EA.OrderManagements;
3 | using FXSharp.TradingPlatform.Exts;
4 | using TradePlatform.MT4.SDK.API;
5 |
6 | namespace FXSharp.EA.PinBar
7 | {
8 | public class PinBarEA : EExpertAdvisor
9 | {
10 | private const double Range = 100;
11 | private bool _isInitialize;
12 | private IOrderManager _orderManager;
13 | //private double LotSize = 1;
14 | private DateTime _prevtime = default(DateTime);
15 |
16 | protected override int DeInit()
17 | {
18 | return 0;
19 | }
20 |
21 | protected override int Init()
22 | {
23 | _orderManager = new NoOrderCreatedManager(this);
24 |
25 | _prevtime = Time[0];
26 | _isInitialize = true;
27 | return 0;
28 | }
29 |
30 | private bool IsNewBar()
31 | {
32 | if (_prevtime != Time[0])
33 | {
34 | _prevtime = Time[0];
35 | return (true);
36 | }
37 |
38 | return (false);
39 | }
40 |
41 | private bool IsBearishPinBar()
42 | {
43 | // the body is small, the position of the body near open.
44 | // still can handle if this fall into trap both shadow is > 50 ??
45 | return (High[1] - Math.Max(Close[1], Open[1]))/Point > 600;
46 | }
47 |
48 | private bool IsBullishPinBar()
49 | {
50 | return (Math.Min(Close[1], Open[1]) - Low[1])/Point > 600;
51 | }
52 |
53 | protected override int Start()
54 | {
55 | if (!_isInitialize)
56 | {
57 | Init();
58 | }
59 |
60 | if (IsNewBar())
61 | {
62 | if (IsBullishPinBar())
63 | {
64 | _orderManager.OnNewBullishPinBar();
65 | }
66 | else if (IsBearishPinBar())
67 | {
68 | _orderManager.OnNewBearishPinBar();
69 | }
70 | }
71 | else
72 | {
73 | _orderManager.OnTick();
74 | }
75 | return 0;
76 | }
77 |
78 | internal Order CreatePendingBuyOrder()
79 | {
80 | double slPoints = (High[1] - Low[1])/Point + 2*Range;
81 | double tpPoints = 2*slPoints*Point;
82 | var moneyManagement = new MoneyManagement(2, Balance);
83 | double lotSize = moneyManagement.CalculateLotSize(slPoints);
84 | Order order = PendingBuy(Symbol, lotSize, High[1] + Range*Point, Low[1] - Range*Point, High[1] + tpPoints);
85 | this.ObjectsDeleteAll();
86 | return order;
87 | }
88 |
89 | internal Order CreatePendingSellOrder()
90 | {
91 | double slPoints = (High[1] - Low[1])/Point + 2*Range;
92 | double tpPoints = 2*slPoints*Point;
93 | var moneyManagement = new MoneyManagement(2, Balance);
94 | double lotSize = moneyManagement.CalculateLotSize(slPoints);
95 | Order order = PendingSell(Symbol, lotSize, Low[1] - Range*Point, High[1] + Range*Point, Low[1] - tpPoints);
96 | this.ObjectsDeleteAll();
97 | return order;
98 | }
99 |
100 | internal void MoveToPendingOrderCreatedState(Order order)
101 | {
102 | _orderManager = new PendingOrderCreatedManager(this, order);
103 | }
104 |
105 | internal void MoveToOrderRunningState(Order order)
106 | {
107 | _orderManager = new OrderRunningManager(this, order);
108 | }
109 |
110 | public void OrderCompleted()
111 | {
112 | _orderManager = new NoOrderCreatedManager(this);
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------