Hello, I am learning to program in NT. I want to apply a simple system, but I don't know why it gives me an error.
The idea is the following. A system that goes long if the open of the current candle is higher than the close of the previous candle. On the contrary, it should go short if the opening of the current candle is lower than the closing of the previous candle. In both cases I want the trade to close at the close of the entry candle, as I use daily candles. I leave you my code, and if you can correct it, you would help me a lot.
Thank you all.
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "InApertura";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 2;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 0;
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 = 0;
// 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 (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
{
ExitLong("","");
}
// Set 1
if (Open[0] >= Close[1])
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
}
Comment