I REALLY suck at building even basic strategies. It won't work and I don't why.
On backtesting it buys all over the place or not at all when it should.
Indicators
SMA 150 Fisher Transform 15 day
Entry Price must be above SMA150
Fisher Transform 15 day must be below -1
Fisher Transform must cross up through an SMA 1 of itself + offset of 1
Exit Fisher Transform line crosses down through SMA1 of itself + offset of 1
Here is the code: (do I post here??)
Thanks to anyone who can spot my probably simple error.
Description = @"Enter when 1) Fisher Transform 15 Day less than - 1. 2) Price above 150 SMA 3)Fisher Transform crosses up through SMA of FIsher Transform 1 + 1 4) sell when Fisher Transform crosses down through SMA 1+1 (offset)";
Name = "FisherXMAup1";
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)
{
FisherTransform1 = FisherTransform(Close, 15);
FisherTransform1.Plots[0].Brush = Brushes.DodgerBlue;
AddChartIndicator(FisherTransform1);
SMA1 = SMA(Close, 150);
SMA1.Plots[0].Brush = Brushes.Goldenrod;
AddChartIndicator(SMA1);
SMA2 = SMA(FisherTransform1, 1);
SMA2.Plots[0].Brush = Brushes.Goldenrod;
AddChartIndicator(SMA2);
SMA3 = SMA(FisherTransform1, 1);
SMA3.Plots[0].Brush = Brushes.Goldenrod;
AddChartIndicator(SMA3);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 15)
return;
// Set 1
if ((FisherTransform1[0] < -1)
&& (Close[0] > SMA1[0])
&& (CrossAbove(FisherTransform1, SMA2, 1)))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if (CrossBelow(FisherTransform1, SMA3, 1))
{
ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
}
}
}
}
Comment