I created a strategy using the strategy builder..it compiled ok..
But it won't plot on the charts... ( i did enable strategy for the chart it's on in the control center))
It's just a simple one for me to test the functionality... I have another strategy I'm using and it's working fine.
All it does it puts an up arrow when the 7 EMA is higher than the 14 EMA..
Now I don't use this strategy to plot the EMA just to mark the above condition with upArrow.
I use the default EMA to plot the EMA's on chart...
Here is the code that the builder produced..
public class EMAPlotTest : Strategy
{
private EMA EMA1;
private EMA EMA2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "EMAPlotTest";
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;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
EMA1 = EMA(Close, 7);
EMA2 = EMA(Close, 14);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 0)
return;
// Set 1
if (EMA1[0] > EMA2[0])
{
Draw.ArrowUp(this, @"EMAPlotTest Arrow up_1", false, 0, 0, Brushes.Lime);
}
}
}
I'm not sure on the reason why it won't plot? did the builder generate the wrong condition code? EMA1[0] > EMA2[0]
Thanks
Traderhawk
Comment