i have very less knowledge of coding so plese forgive my small silly questions....
i have build a strategy for sma cross without any trading parameters, because i just want arrows to show on my chart when crossover is done of sma. but i am unable to see thos arrows on my chart. i will post the code and startegy here if some one can help me.
thanks
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class SMAcross : Strategy
{
private SMA SMA1;
private SMA SMA2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "SMAcross";
Calculate = Calculate.OnBarClose;
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;
PeriodFast = 20;
PeriodSlow = 210;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
SMA1 = SMA(Close, Convert.ToInt32(PeriodFast));
SMA2 = SMA(Close, Convert.ToInt32(PeriodSlow));
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CrossAbove(SMA1, SMA2, 1))
{
Draw.ArrowUp(this, @"SMAcross Arrow up_1", false, 0, 0, Brushes.Lime);
}
// Set 2
if (CrossBelow(SMA1, SMA2, 1))
{
Draw.ArrowDown(this, @"SMAcross Arrow down_1", false, 0, 0, Brushes.Red);
}
}
Comment