C# Class Forex_Strategy_Builder.Backtester

Class Backtester
Inheritance: Data
Mostra file Open project: nuggett11/Forex-Strategy-Builder Class Usage Examples

Private Properties

Property Type Description
AnalyseEntry void
AnalyseExit void
AnalysePermanentSLExit void
AnalysePermanentTPExit void
ArrangeBarsHighLow void
BarInterpolation void
CalculateAdditionalStats void
CancelInvalidOrders void
CancelNoexecutedEntryOrders void
CancelNoexecutedExitOrders void
CheckOrd bool
EntryLogicConditions void
ExecOrd OrderStatus
ExecuteEntryAtClosingPrice void
ExecuteEntryAtOpeningPrice void
ExecuteExitAtClosingPrice void
FastCalculating bool
FindCancelExitOrder void
GenerateAccountStats void
GenerateAccountStatsInMoney void
IntrabarScanning bool
MarginCallCheckAtBarClosing void
NearestMethod void
NormalizeEntryLots double
OptimisticPessimisticMethod void
OrdBuyLimit void
OrdBuyMarket void
OrdBuyStop void
OrdBuyStopLimit void
OrdSellLimit void
OrdSellMarket void
OrdSellStop void
OrdSellStopLimit void
RandomMethod void
ResetStart void
ResetStop void
SetAdditioanlMoneyStats void
SetAdditioanlStats void
SetEntryOrders void
SetExitOrders void
SetPosition void
ShortestMethod void
TickScanning bool
TransferFromPreviousBar void

Public Methods

Method Description
AccountExchangeRate ( double price ) : double

Account Exchange Rate.

BalanceDrawdown ( int bar ) : int

Returns the Balance Drawdown in pips

Calculate ( ) : void

Calculate strategy

CalculateAccountStats ( ) : void

Calculates the account statistics.

Calculation ( ) : void

The main calculating cycle

Commission ( double lots, double price, bool isPosClosing ) : double

Calculates the commission in pips.

CommissionInMoney ( double lots, double price, bool isPosClosing ) : double

Calculates the commission in currency.

EquityDrawdown ( int bar ) : int

Returns the Equity Drawdown in pips

LongBalance ( int bar ) : int

Returns the long balance at the end of the bar in pips.

LongMoneyBalance ( int bar ) : double

Returns the long balance at the end of the bar in money.

MoneyBalanceDrawdown ( int bar ) : double

Returns the Balance Drawdown in currency

MoneyEquityDrawdown ( int bar ) : double

Returns the Equity Drawdown in currency.

MoneyToPips ( double money, int bar ) : double

Converts money to pips.

PipsToMoney ( double pips, int bar ) : double

Converts pips to money.

RequiredMargin ( double lots, int bar ) : double

Calculates the required margin.

RolloverInMoney ( PosDirection posDir, double lots, int daysRollover, double price ) : double

Calculates the rollover fee in currency.

Scan ( ) : void

Performs an intrabar scanning

ShortBalance ( int bar ) : int

Returns the short balance at the end of the bar in pips.

ShortMoneyBalance ( int bar ) : double

Returns the short balance at the end of the bar in money.

TradingSize ( double size, int bar ) : double

Calculates the trading size in normalized lots.

Private Methods

Method Description
AnalyseEntry ( int bar ) : void

Checks the slots for a permission to open a position. If there are no filters that forbid it, sets the entry orders.

AnalyseExit ( int bar ) : void

Sets the close orders for the indicated bar.

AnalysePermanentSLExit ( int bar ) : void

Sets Permanent Stop Loss close orders for the indicated bar

AnalysePermanentTPExit ( int bar ) : void

Sets Permanent Take Profit close orders for the indicated bar

ArrangeBarsHighLow ( int bar ) : void

Arranges the order of hitting the bar's Top and Bottom.

BarInterpolation ( int bar ) : void

Arranges the orders inside the bar.

CalculateAdditionalStats ( ) : void

Calculates the values of the stats parameters.

CancelInvalidOrders ( int bar ) : void

Checks all orders in the current bar and cancels the invalid ones.

CancelNoexecutedEntryOrders ( int bar ) : void

Cancel all no executed entry orders

CancelNoexecutedExitOrders ( int bar ) : void

Cancel all no executed exit orders

CheckOrd ( int bar, int iOrd ) : bool

Checks the order

EntryLogicConditions ( int bar, string group, double buyPrice, double sellPrice, bool &canOpenLong, bool &canOpenShort ) : void

checks if the opening logic conditions allow long or short entry.

ExecOrd ( int bar, Order order, double price, BacktestEval testEval ) : OrderStatus

Tunes and Executes an order

ExecuteEntryAtClosingPrice ( int bar ) : void

Executes an entry at the closing of the bar

ExecuteEntryAtOpeningPrice ( int bar ) : void

Executes an entry at the beginning of the bar

ExecuteExitAtClosingPrice ( int bar ) : void

Executes an exit at the closing of the bar

FastCalculating ( int startBar ) : bool

Calculate statistics

FindCancelExitOrder ( int bar, Order order ) : void

Finds and cancels the exit order of an entry order

GenerateAccountStats ( ) : void

Generate the Account Statistics in pips.

GenerateAccountStatsInMoney ( ) : void

Generate the Account Statistics in currency.

IntrabarScanning ( int bar, BacktestEval eval, double &current, int &reachedIntrabar, int &tradedIntrabar, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : bool

Intrabar Scanning

MarginCallCheckAtBarClosing ( int bar ) : void

Checks and perform actions in case of a Margin Call

NearestMethod ( int bar, BacktestEval eval, double &current, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : void

Nearest order first Method

NormalizeEntryLots ( double lots ) : double
OptimisticPessimisticMethod ( int bar, BacktestEval eval, double &current, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : void

Optimistic / Pessimistic Method

OrdBuyLimit ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Buy Limit.

OrdBuyMarket ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Buy Market.

OrdBuyStop ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Buy Stop.

OrdBuyStopLimit ( int bar, int orderIf, int toPos, double lots, double price1, double price2, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Buy Stop Limit.

OrdSellLimit ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Sell Limit.

OrdSellMarket ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Sell Market.

OrdSellStop ( int bar, int orderIf, int toPos, double lots, double price, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Sell Stop.

OrdSellStopLimit ( int bar, int orderIf, int toPos, double lots, double price1, double price2, OrderSender sender, OrderOrigin origin, string note ) : void

Sets a new order Sell Stop Limit.

RandomMethod ( int bar, BacktestEval eval, double &current, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : void

Random Execution Method

ResetStart ( ) : void

Resets the variables and prepares the arrays

ResetStop ( ) : void

Resets the variables at the end of the test.

SetAdditioanlMoneyStats ( ) : void

Sets the additional stats in Money.

SetAdditioanlStats ( ) : void

Sets the additional stats in pips.

SetEntryOrders ( int bar, double price, PosDirection posDir, double lots ) : void

Sets an entry order

SetExitOrders ( int bar, double priceStopLong, double priceStopShort ) : void

Sets an exit order

SetPosition ( int bar, OrderDirection ordDir, double lots, double price, int ordNumb ) : void

Sets the position.

ShortestMethod ( int bar, BacktestEval eval, double &current, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : void

Shortest route inside the bar Method

TickScanning ( int bar, BacktestEval eval, double &current, int &reachedTick, bool isTopReachable, bool isBottomReachable, bool isHigherPrice, bool isLowerPrice, double priceHigher, double priceLower, Order orderHigher, Order orderLower, bool isClosingAmbiguity ) : bool

Tick Scanning

TransferFromPreviousBar ( int bar ) : void

Method Details

AccountExchangeRate() public static method

Account Exchange Rate.
public static AccountExchangeRate ( double price ) : double
price double
return double

BalanceDrawdown() public static method

Returns the Balance Drawdown in pips
public static BalanceDrawdown ( int bar ) : int
bar int
return int

Calculate() public static method

Calculate strategy
public static Calculate ( ) : void
return void

CalculateAccountStats() public static method

Calculates the account statistics.
public static CalculateAccountStats ( ) : void
return void

Calculation() public static method

The main calculating cycle
public static Calculation ( ) : void
return void

Commission() public static method

Calculates the commission in pips.
public static Commission ( double lots, double price, bool isPosClosing ) : double
lots double
price double
isPosClosing bool
return double

CommissionInMoney() public static method

Calculates the commission in currency.
public static CommissionInMoney ( double lots, double price, bool isPosClosing ) : double
lots double
price double
isPosClosing bool
return double

EquityDrawdown() public static method

Returns the Equity Drawdown in pips
public static EquityDrawdown ( int bar ) : int
bar int
return int

LongBalance() public static method

Returns the long balance at the end of the bar in pips.
public static LongBalance ( int bar ) : int
bar int
return int

LongMoneyBalance() public static method

Returns the long balance at the end of the bar in money.
public static LongMoneyBalance ( int bar ) : double
bar int
return double

MoneyBalanceDrawdown() public static method

Returns the Balance Drawdown in currency
public static MoneyBalanceDrawdown ( int bar ) : double
bar int
return double

MoneyEquityDrawdown() public static method

Returns the Equity Drawdown in currency.
public static MoneyEquityDrawdown ( int bar ) : double
bar int
return double

MoneyToPips() public static method

Converts money to pips.
public static MoneyToPips ( double money, int bar ) : double
money double
bar int
return double

PipsToMoney() public static method

Converts pips to money.
public static PipsToMoney ( double pips, int bar ) : double
pips double
bar int
return double

RequiredMargin() public static method

Calculates the required margin.
public static RequiredMargin ( double lots, int bar ) : double
lots double
bar int
return double

RolloverInMoney() public static method

Calculates the rollover fee in currency.
public static RolloverInMoney ( PosDirection posDir, double lots, int daysRollover, double price ) : double
posDir PosDirection
lots double
daysRollover int
price double
return double

Scan() public static method

Performs an intrabar scanning
public static Scan ( ) : void
return void

ShortBalance() public static method

Returns the short balance at the end of the bar in pips.
public static ShortBalance ( int bar ) : int
bar int
return int

ShortMoneyBalance() public static method

Returns the short balance at the end of the bar in money.
public static ShortMoneyBalance ( int bar ) : double
bar int
return double

TradingSize() public static method

Calculates the trading size in normalized lots.
public static TradingSize ( double size, int bar ) : double
size double
bar int
return double