publicclass NewTrendTrades : Strategy
{
#region Variables
// Wizard generated variables
privateint contracts = 2; // Default setting for Contracts
privateint stop = 6; // Default setting for Stop 1st contract
privateint trlTrigger = 6; //Default setting for number of ticks profit which will move the stop to b/e
privateint t1 = 8; // Default setting for T1
privateint t2 = 16; // Default setting for T2
// User defined variables (add any user defined variables below)
#endregion
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverridevoid Initialize()
{
EntriesPerDirection = 1; //For uniquely named entries which are required for scaling out
EntryHandling = EntryHandling.UniqueEntries;
CalculateOnBarClose = true;
SetStopLoss("Long 1a", CalculationMode.Ticks, Stop, true);
SetStopLoss("Long 1b", CalculationMode.Ticks, Stop, true);
SetProfitTarget("Long 1a", CalculationMode.Ticks, T1);
SetProfitTarget("Long 1b", CalculationMode.Ticks, T2);
SetStopLoss("Short 1a", CalculationMode.Ticks, Stop, true);
SetStopLoss("Short 1b", CalculationMode.Ticks, Stop, true);
SetProfitTarget("Short 1a", CalculationMode.Ticks, T1);
SetProfitTarget("Short 1b", CalculationMode.Ticks, T2);
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Here we reset the stop to its original value in the case we trailed during the last trade.
if (Position.MarketPosition==MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, Stop);
}
//Here we will move the stoploss to b/e if the market has moved enough in our direction
elseif (Position.MarketPosition==MarketPosition.Long)
{
if (Close[0]>1.2948) //this didn't effect my stops at all??!!!
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
}
elseif (Position.MarketPosition==MarketPosition.Short)
{
if (Close[0]<(Position.AvgPrice-trlTrigger*TickSize))
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);

Comment