Thanks.
namespace NinjaTrader.NinjaScript.Strategies
{
public class MyCustomStrategy3 : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "MyCustomStrategy3";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1)
return;
// Set 1
if (GetCurrentBid(0) > High[1])
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if (GetCurrentAsk(0) < Low[1])
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
}
}
}
Comment