public class VscraperOnly : Strategy
{
#region Variables
private int target = 24;
private int stop = 12;
private int entryOffset = 1;
private int entryOffsetBars = 8;
private bool be2 = false;
private bool be3 = false;
private bool _initialized = false;
private IOrder entryOrder = null;
private int barNumberOfOrder = 0;
#endregion
protected override void Initialize()
{
Add(Vscraper());
CalculateOnBarClose = true;
EntryHandling = EntryHandling.UniqueEntries;
EntriesPerDirection = 1;
TraceOrders = true;
SetProfitTarget("GoLong", CalculationMode.Ticks, target);
SetStopLoss("GoLong", CalculationMode.Ticks, stop, false);
SetProfitTarget("GoShort", CalculationMode.Ticks, target);
SetStopLoss("GoShort", CalculationMode.Ticks, stop, false);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if (!_initialized)
{
_initialized = true;
}
if (BarsInProgress != 0) return;
if (CurrentBar < 35) return;
if (Position.MarketPosition != MarketPosition.Flat) return;
// Condition set 1
if (Vscraper().Signal[0] == 1)
{
if(entryOrder == null)
{
entryOrder = EnterLongLimit(Close[0] - entryOffset*TickSize, "GoLong");
barNumberOfOrder = CurrentBar;
}
if (CurrentBar > barNumberOfOrder + entryOffsetBars)
CancelOrder(entryOrder);
}
// Condition set 2
if (Vscraper().Signal[0] == -1)
{
if(entryOrder == null)
{
entryOrder = EnterShortLimit(Close[0] + entryOffset*TickSize, "GoShort");
barNumberOfOrder = CurrentBar;
}
if (CurrentBar > barNumberOfOrder + entryOffsetBars)
CancelOrder(entryOrder);
}
//Condition set 3
if (Vscraper().Signal[0] == 0) return;
}


Comment