+1 888 340 6572

4.6.3 Strategy Performance: Difference between revisions

From MultiCharts
(Created page with " Signals as well as functions and indicators can get key information upon the current strategy state during their calculation through ''StrategyInfo'': ''StrategyInfo.AvgEntr...")
 
No edit summary
Line 2: Line 2:
Signals as well as functions and indicators can get key information upon the current strategy state during their calculation through ''StrategyInfo'':
Signals as well as functions and indicators can get key information upon the current strategy state during their calculation through ''StrategyInfo'':


''StrategyInfo.AvgEntryPrice'' is the average open price of the position on the chart. If the position is not opened, then 0 is returned;
* {{color|blue|StrategyInfo.AvgEntryPrice}} is the average open price of the position on the chart. If the position is not opened, then 0 is returned;


''StrategyInfo.MarketPosition'' is the current market position. For example, we are at the short position for 100 contracts, then ''StrategyInfo.MarketPosition'' will return “-100”. For example, if we have a long position for 50 contracts, the ''StrategyInfo.MarketPosition'' will return the value “50”.
* {{color|blue|StrategyInfo.MarketPosition}} is the current market position. For example, we are at the short position for 100 contracts, then ''StrategyInfo.MarketPosition'' will return “-100”. For example, if we have a long position for 50 contracts, the {{color|blue|StrategyInfo.MarketPosition}} will return the value “50”.


''StrategyInfo.ClosedEquity'' – is the current NetProfit of the strategy on this bar.
* {{color|blue|StrategyInfo.ClosedEquity}} – is the current NetProfit of the strategy on this bar.


''StrategyInfo.OpenEquity'' = current ''NetProfit'' + current ''OpenPL'' of the strategy on this bar.
* {{color|blue|StrategyInfo.OpenEquity}} = current ''NetProfit'' + current ''OpenPL'' of the strategy on this bar.


Following keywords can be used only in signals.
Following keywords can be used only in signals.
Line 14: Line 14:
More detailed information upon current strategy parameters can be obtained through ''CurrentPosition(IMarketPosition)'':
More detailed information upon current strategy parameters can be obtained through ''CurrentPosition(IMarketPosition)'':


:''CurrentPosition.Value'' – the same as StrategyInfo.MarketPosition.
* {{color|blue|CurrentPosition.Value}} – the same as StrategyInfo.MarketPosition.
:''CurrentPosition.Side'' – EMarketPositionSide.Flat – there is no open position, EMarketPositionSide.Long – long position is opened,  
* {{color|blue|CurrentPosition.Side}} – EMarketPositionSide.Flat – there is no open position, EMarketPositionSide.Long – long position is opened,  
:''EMarketPositionSide.Short'' – short position is opened.
* {{color|blue|EMarketPositionSide.Short}} – short position is opened.
:''CurrentPosition.Profit'' = ''CurrentPosition.OpenProfit'' – current ''OpenPL'' upon the open position or 0, if the position is closed.
* {{color|blue|CurrentPosition.Profit}} = }}CurrentPosition.OpenProfit'' – current ''OpenPL'' upon the open position or 0, if the position is closed.
:''CurrentPosition.ProfitPerContract'' – current OpenPL upon the open position per contract or 0, if the position is closed.
* {{color|blue|CurrentPosition.ProfitPerContract}} – current OpenPL upon the open position per contract or 0, if the position is closed.
:''CurrentPosition.OpenLots'' – the amount of not closed contracts in the position.
* {{color|blue|CurrentPosition.OpenLots}} – the amount of not closed contracts in the position.
:''CurrentPosition.MaxDrawDown'' – minimum OpenPL for the current position, for the whole period of time, while the position was opened.
* {{color|blue|CurrentPosition.MaxDrawDown}} – minimum OpenPL for the current position, for the whole period of time, while the position was opened.
:''CurrentPosition.MaxRunUp'' – maximum OpenPL for the current position, for the whole period of time, while the position was opened.
* {{color|blue|CurrentPosition.MaxRunUp}} – maximum OpenPL for the current position, for the whole period of time, while the position was opened.
:''CurrentPosition.ClosedTrades[]'' – the list of closed trades (ITrade) in the current position.
* {{color|blue|CurrentPosition.ClosedTrades[]}} – the list of closed trades (ITrade) in the current position.
:''CurrentPosition.OpenTrades[]'' – the list of open trades (ITrade) in the current position.
* {{color|blue|CurrentPosition.OpenTrades[]}} – the list of open trades (ITrade) in the current position.




''CurSpecOrdersMode'' – current mode of special orders (ESpecOrdersMode.PerContract, ESpecOrdersMode.PerPosition)
''' {{color|blue|CurSpecOrdersMode}}''' – current mode of special orders (ESpecOrdersMode.PerContract, ESpecOrdersMode.PerPosition)


''PositionSide'' – current position:  
'''{{color|blue|PositionSide}}''' – current position:  
*''EMarketPositionSide.Flat'' – position is not opened,  
* {{color|blue|EMarketPositionSide.Flat}} – position is not opened,  
*''EMarketPositionSide.Long'' – long position,  
* {{color|blue|EMarketPositionSide.Long}} – long position,  
* EMarketPositionSide.Short – short position.
* {{color|blue|EMarketPositionSide.Short}} – short position.
<br>
<br>
In signals, the history of positions is available (IMarketPosition), either opened or closed by the strategy through Positions[](IMarketPosition).
In signals, the history of positions is available (IMarketPosition), either opened or closed by the strategy through '''Positions[](IMarketPosition)'''.
* Position[0] – current position (the same as CurrentPosition),  
* Position[0] – current position (the same as CurrentPosition),  
* Position[1] – the previous opened position, etc.
* Position[1] – the previous opened position, etc.
Line 40: Line 40:
Closed positions information is available through the ''IMarketPosition'' interface:
Closed positions information is available through the ''IMarketPosition'' interface:


:''IMarketPosition.Value'' – 0, as there are no open trades in the close position.
* {{color|blue|IMarketPosition.Value}} – 0, as there are no open trades in the close position.
:''IMarketPosition.Side'' – EMarketPositionSide.Long – long position.
* {{color|blue|IMarketPosition.Side}} – EMarketPositionSide.Long – long position.
:''EMarketPositionSide.Short'' – short position.
* {{color|blue|EMarketPositionSide.Short}} – short position.
:''IMarketPosition.Profit'' - total profit upon all the position trades.
* {{color|blue|IMarketPosition.Profit}} - total profit upon all the position trades.
:''IMarketPosition.ProfitPerContract'' – profits upon all the position trades per contract.
* {{color|blue|IMarketPosition.ProfitPerContract}} – profits upon all the position trades per contract.
:''IMarketPosition.OpenLots'' = 0 for the closed positions, as by default, all the contracts were closed.
* {{color|blue|IMarketPosition.OpenLots}} = 0 for the closed positions, as by default, all the contracts were closed.
:''IMarketPosition.MaxDrawDown'' – maximum potential loss for the position, for the whole period, while the position was opened.
* {{color|blue|IMarketPosition.MaxDrawDown}} – maximum potential loss for the position, for the whole period, while the position was opened.
:''IMarketPosition.MaxRunUp'' – maximum OpenPL for the position, for the whole period, while the position was opened.
* {{color|blue|IMarketPosition.MaxRunUp}} – maximum OpenPL for the position, for the whole period, while the position was opened.
:''IMarketPosition.ClosedTrades[]'' – list of trades (ITrade) in the position.
* {{color|blue|IMarketPosition.ClosedTrades[]}} – list of trades (ITrade) in the position.
:''IMarketPosition.OpenTrades[]'' – list of opened trades for the closed position, that is empty.  
* {{color|blue|IMarketPosition.OpenTrades[]}} – list of opened trades for the closed position, that is empty.  


<div style="background-color: #E5F6FF;">'''Example:'''
<div style="background-color: #E5F6FF;">'''Example:'''
Line 100: Line 100:


The following main settings of the strategy are available:
The following main settings of the strategy are available:
:''GrossLoss'' – Profit amount upon losing trades
 
:''GrossProfit'' – Profit amount upon profitable trades
* {{color|blue|GrossLoss}} – Profit amount upon losing trades
:''NetProfit'' – net profit upon the strategy (GrossProfit+ GrossLoss)
* {{color|blue|GrossProfit}} – Profit amount upon profitable trades
:''NumEvenTrades'' – amount of zero trades with Profit = $0.00.
* {{color|blue|NetProfit}} – net profit upon the strategy (GrossProfit+ GrossLoss)
:''NumLosTrades'' – amount of losing trades with Profit < $0.00.
* {{color|blue|NumEvenTrades}} – amount of zero trades with Profit = $0.00.
:''NumWinTrades'' – amount of profitable trades with Profit > 0.00$.
* {{color|blue|NumLosTrades}} – amount of losing trades with Profit < $0.00.
:''TotalBarsEvenTrades'' – amount of bars in zero trades.
* {{color|blue|NumWinTrades}} – amount of profitable trades with Profit > 0.00$.
:''TotalBarsLosTrades'' – amount of bars in losing trades.
* {{color|blue|TotalBarsEvenTrades}} – amount of bars in zero trades.
:''TotalBarsWinTrades'' – amount of bars in profitable trades.
* {{color|blue|TotalBarsLosTrades}} – amount of bars in losing trades.
:''AvgBarsEvenTrade'' – average number of bars in zero trades.
* {{color|blue|TotalBarsWinTrades}} – amount of bars in profitable trades.
:''AvgBarsLosTrade'' – average number of bars in losing trades.
* {{color|blue|AvgBarsEvenTrade}} – average number of bars in zero trades.
:''AvgBarsWinTrade'' – average number of bars in profitable trades.
* {{color|blue|AvgBarsLosTrade}} – average number of bars in losing trades.
:''LargestLosTrade'' – Profit of the most losing strategy trade.
* {{color|blue|AvgBarsWinTrade}} – average number of bars in profitable trades.
:''LargestWinTrade'' – Profit of the most profitable strategy trade.
* {{color|blue|LargestLosTrade}} – Profit of the most losing strategy trade.
:''MaxConsecLosers'' – maximum number of losing trades in a row (Profit < 0).
* {{color|blue|LargestWinTrade}} – Profit of the most profitable strategy trade.
:''MaxConsecWinners'' – maximum number of profitable trades in a row (Profit > 0)
* {{color|blue|MaxConsecLosers}} – maximum number of losing trades in a row (Profit < 0).
:''MaxDrawDown'' – maximum draw down StrategyInfo.OpenEquity for all previous trade period.  
* {{color|blue|MaxConsecWinners}} – maximum number of profitable trades in a row (Profit > 0)
:''MaxLotsHeld'' – maximum number of possessing contracts for all previous trade period.
* {{color|blue|MaxDrawDown}} – maximum draw down StrategyInfo.OpenEquity for all previous trade period.  
:''TotalTrades'' – total number of trades for the whole trade period.
* {{color|blue|MaxLotsHeld}} – maximum number of possessing contracts for all previous trade period.
:''PercentProfit'' – number of profitable trades with respect to the total number of trades in percent.
* {{color|blue|TotalTrades}} – total number of trades for the whole trade period.
* {{color|blue|PercentProfit}} – number of profitable trades with respect to the total number of trades in percent.




Trade information(ITrade) (entry + closing exit):
Trade information(ITrade) (entry + closing exit):
<syntaxhighlight>
 
public interface ITrade
'''{{color|blue|public interface ITrade}}'''
{
* {{color|blue|double CommissionValue { get; }}} – commission of the trade
double CommissionValue { get; } – commission of the trade
* {{color|blue|ITradeOrder EntryOrder { get; }}} – the order, that opened the trade - entry
ITradeOrder EntryOrder { get; } – the order, that opened the trade - entry
* {{color|blue|ITradeOrder ExitOrder { get; }}}– the order, that closed the trade - exit
ITradeOrder ExitOrder { get; }– the order, that closed the trade - exit
* {{color|blue|bool IsLong { get; }}} – Means, that the entry was Buy (true) or SellShort (false)
bool IsLong { get; } – Means, that the entry was Buy (true) or SellShort (false)
* {{color|blue|bool IsOpen { get; }}} – Means, that the entry was not closed yet
bool IsOpen { get; } – Means, that the entry was not closed yet
* {{color|blue|double Profit { get; }}} – OpenPL, if the trade is opend or TradeProfit – if closed.
double Profit { get; } – OpenPL, if the trade is opend or TradeProfit – if closed.
 
}
 
</syntaxhighlight>
Trade order information ITradeOrder:
Trade order information ITradeOrder:
<syntaxhighlight>
public interface ITradeOrder
{
EOrderAction Action { get; } – EOrderAction.Buy, EOrderAction.Sell, EOrderAction.SellShort, EOrderAction.BuyToCover.
int BarNumber { get; } – number of the bar, on which the order occured (Bars.CurrentBar, on which the order occured)
OrderCategory Category { get; } – OrderCategory.Market, OrderCategory.Limit, OrderCategory.Stop, OrderCategory.StopLimit
int Contracts { get; } – number of contracts in the filled order
string Name { get; } – order name
double Price { get; } – execution price
DateTime Time { get; } – time of the bar where the order was executed
}


</syntaxhighlight>
'''{{color|blue|public interface ITradeOrder}}'''
* {{color|blue|EOrderAction Action { get; }}} – EOrderAction.Buy, EOrderAction.Sell, EOrderAction.SellShort, EOrderAction.BuyToCover.
* {{color|blue|int BarNumber { get; }}} – number of the bar, on which the order occured (Bars.CurrentBar, on which the order occured)
* {{color|blue|OrderCategory Category { get; }}} – OrderCategory.Market, OrderCategory.Limit, OrderCategory.Stop, OrderCategory.StopLimit
* {{color|blue|int Contracts { get; }}} – number of contracts in the filled order
* {{color|blue|string Name { get; }}} – order name
* {{color|blue|double Price { get; }}} – execution price
* {{color|blue|DateTime Time { get; } }}– time of the bar where the order was executed
 
 


[[Category:.NET Programming Giude]]
[[Category:.NET Programming Giude]]

Revision as of 19:35, 3 May 2013

Signals as well as functions and indicators can get key information upon the current strategy state during their calculation through StrategyInfo:

  • StrategyInfo.AvgEntryPrice is the average open price of the position on the chart. If the position is not opened, then 0 is returned;
  • StrategyInfo.MarketPosition is the current market position. For example, we are at the short position for 100 contracts, then StrategyInfo.MarketPosition will return “-100”. For example, if we have a long position for 50 contracts, the StrategyInfo.MarketPosition will return the value “50”.
  • StrategyInfo.ClosedEquity – is the current NetProfit of the strategy on this bar.
  • StrategyInfo.OpenEquity = current NetProfit + current OpenPL of the strategy on this bar.

Following keywords can be used only in signals.

More detailed information upon current strategy parameters can be obtained through CurrentPosition(IMarketPosition):

  • CurrentPosition.Value – the same as StrategyInfo.MarketPosition.
  • CurrentPosition.Side – EMarketPositionSide.Flat – there is no open position, EMarketPositionSide.Long – long position is opened,
  • EMarketPositionSide.Short – short position is opened.
  • CurrentPosition.Profit = }}CurrentPosition.OpenProfit – current OpenPL upon the open position or 0, if the position is closed.
  • CurrentPosition.ProfitPerContract – current OpenPL upon the open position per contract or 0, if the position is closed.
  • CurrentPosition.OpenLots – the amount of not closed contracts in the position.
  • CurrentPosition.MaxDrawDown – minimum OpenPL for the current position, for the whole period of time, while the position was opened.
  • CurrentPosition.MaxRunUp – maximum OpenPL for the current position, for the whole period of time, while the position was opened.
  • CurrentPosition.ClosedTrades[] – the list of closed trades (ITrade) in the current position.
  • CurrentPosition.OpenTrades[] – the list of open trades (ITrade) in the current position.


CurSpecOrdersMode – current mode of special orders (ESpecOrdersMode.PerContract, ESpecOrdersMode.PerPosition)

PositionSide – current position:

  • EMarketPositionSide.Flat – position is not opened,
  • EMarketPositionSide.Long – long position,
  • EMarketPositionSide.Short – short position.


In signals, the history of positions is available (IMarketPosition), either opened or closed by the strategy through Positions[](IMarketPosition).

  • Position[0] – current position (the same as CurrentPosition),
  • Position[1] – the previous opened position, etc.


Closed positions information is available through the IMarketPosition interface:

  • IMarketPosition.Value – 0, as there are no open trades in the close position.
  • IMarketPosition.Side – EMarketPositionSide.Long – long position.
  • EMarketPositionSide.Short – short position.
  • IMarketPosition.Profit - total profit upon all the position trades.
  • IMarketPosition.ProfitPerContract – profits upon all the position trades per contract.
  • IMarketPosition.OpenLots = 0 for the closed positions, as by default, all the contracts were closed.
  • IMarketPosition.MaxDrawDown – maximum potential loss for the position, for the whole period, while the position was opened.
  • IMarketPosition.MaxRunUp – maximum OpenPL for the position, for the whole period, while the position was opened.
  • IMarketPosition.ClosedTrades[] – list of trades (ITrade) in the position.
  • IMarketPosition.OpenTrades[] – list of opened trades for the closed position, that is empty.
Example:

Initially, CurrentPosition.Value = 0

CurrentPosition.Side = EMarketPositionSide.Flat
CurrentPosition.OpenLots = 0
CurrentPosition.ClosedTrades[] –  empty
CurrentPosition.OpenTrades[]

The strategy has generated and executed a Buy order for 100 contracts. Now our position is the following:

CurrentPosition.Value = 100
CurrentPosition.Side = EMarketPositionSide.Long
CurrentPosition.OpenLots = 100
CurrentPosition.ClosedTrades[] –  empty
CurrentPosition.OpenTrades[] – one element (EntryOrder = Buy for 100, ExitOrder = null)

The strategy has generated and executed a Sell total order for 10 contracts. Now our position is the following:

CurrentPosition.Value = 50
CurrentPosition.Side = EMarketPositionSide.Long
CurrentPosition.OpenLots = 50
CurrentPosition.ClosedTrades[] – one element (EntryOrder = Buy for 10, ExitOrder =Sell for 10)
CurrentPosition.OpenTrades[] – one element (EntryOrder = Buy for 90, ExitOrder = null)

The strategy has generated and executed aSellShort order for 50 contracts. Now our position is the following: The strategy has generated and executed aSellShort order for 50 contracts. Now our position is the following:

CurrentPosition.Value = -50
CurrentPosition.Side = EMarketPositionSide.Short
CurrentPosition.OpenLots = 50
CurrentPosition.ClosedTrades[] – empty
CurrentPosition.OpenTrades[] – one element (EntryOrder = SellShort for 50, ExitOrder = null)

Position[1].Value = 0
Position[1].Side = EMarketPositionSide.Long
Position[1].OpenLots = 0
Position[1].ClosedTrades[] – two elements:
1)	Entry = Buy for 10 Exit = Sell for 10
2)	Entry = Buy for 90 Exit = SellShort for 90
Position[1].OpenTrades[] – empty

The following main settings of the strategy are available:

  • GrossLoss – Profit amount upon losing trades
  • GrossProfit – Profit amount upon profitable trades
  • NetProfit – net profit upon the strategy (GrossProfit+ GrossLoss)
  • NumEvenTrades – amount of zero trades with Profit = $0.00.
  • NumLosTrades – amount of losing trades with Profit < $0.00.
  • NumWinTrades – amount of profitable trades with Profit > 0.00$.
  • TotalBarsEvenTrades – amount of bars in zero trades.
  • TotalBarsLosTrades – amount of bars in losing trades.
  • TotalBarsWinTrades – amount of bars in profitable trades.
  • AvgBarsEvenTrade – average number of bars in zero trades.
  • AvgBarsLosTrade – average number of bars in losing trades.
  • AvgBarsWinTrade – average number of bars in profitable trades.
  • LargestLosTrade – Profit of the most losing strategy trade.
  • LargestWinTrade – Profit of the most profitable strategy trade.
  • MaxConsecLosers – maximum number of losing trades in a row (Profit < 0).
  • MaxConsecWinners – maximum number of profitable trades in a row (Profit > 0)
  • MaxDrawDown – maximum draw down StrategyInfo.OpenEquity for all previous trade period.
  • MaxLotsHeld – maximum number of possessing contracts for all previous trade period.
  • TotalTrades – total number of trades for the whole trade period.
  • PercentProfit – number of profitable trades with respect to the total number of trades in percent.


Trade information(ITrade) (entry + closing exit):

public interface ITrade

  • double CommissionValue { get; } – commission of the trade
  • ITradeOrder EntryOrder { get; } – the order, that opened the trade - entry
  • ITradeOrder ExitOrder { get; }– the order, that closed the trade - exit
  • bool IsLong { get; } – Means, that the entry was Buy (true) or SellShort (false)
  • bool IsOpen { get; } – Means, that the entry was not closed yet
  • double Profit { get; } – OpenPL, if the trade is opend or TradeProfit – if closed.


Trade order information ITradeOrder:

public interface ITradeOrder

  • EOrderAction Action { get; } – EOrderAction.Buy, EOrderAction.Sell, EOrderAction.SellShort, EOrderAction.BuyToCover.
  • int BarNumber { get; } – number of the bar, on which the order occured (Bars.CurrentBar, on which the order occured)
  • OrderCategory Category { get; } – OrderCategory.Market, OrderCategory.Limit, OrderCategory.Stop, OrderCategory.StopLimit
  • int Contracts { get; } – number of contracts in the filled order
  • string Name { get; } – order name
  • double Price { get; } – execution price
  • DateTime Time { get; } – time of the bar where the order was executed