I am using create atm for trades.
If I use sample cumulative profit calculations it shows me zero profit all the time, I tried to search from forum. not found solutions
I tried to use this example:
if (Bars.FirstBarOfSession)
{
// Store the strategy's prior cumulated realized profit and number of trades
priorTradesCount = Performance.AllTrades.Count;
priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit;
/* NOTE: Using .AllTrades will include both historical virtual trades as well as real-time trades.
If you want to only count profits from real-time trades please use .RealtimeTrades. */
}
/* Prevents further trading if the current session's realized profit exceeds $1000 or if realized losses exceed $400.
Also prevent trading if 10 trades have already been made in this session. */
if (Performance.AllTrades.TradesPerformance.Currency. CumProfit - priorTradesCumProfit >= 1000
|| Performance.AllTrades.TradesPerformance.Currency.C umProfit - priorTradesCumProfit <= -400
|| Performance.AllTrades.Count - priorTradesCount > 10)
{
/* TIP FOR EXPERIENCED CODERS: This only prevents trade logic in the context of the OnBarUpdate() method. If you are utilizing
other methods like OnOrderUpdate() or OnMarketData() you will need to insert this code segment there as well. */
// Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
return;
}
Comment