I am developing a strategy and want to add two line to MACD indicator when I run strategy .
I have used AddLine method but it doesn't work.
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "ReverseUniRenkoStratetegy";
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 = 0;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
LookbackOffset = 2;
MaxProfit = 0;
MaxLoss = 0;
TakeProfit = 0;
StopLoss = 0;
ProfitPrice = 0;
LossPrice = 0;
MACDUpperBoundary = 0;
MACDLowerBoundary = 0;
}
else if (State == State.Configure)
{
InitMACD();
}
else if (State == State.DataLoaded)
{
ClearOutputWindow();
DayNetProfit = 0;
LastTradeIndexProcessed = SystemPerformance.AllTrades.Count();
sessionIterator = new SessionIterator(Bars);
MyPrint(string.Format("Current Profit", SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit));
}
}
void InitMACD()
{
if(MACDUpperBoundary != 0 || MACDLowerBoundary != 0)
{
macd = MACD(12, 26, 9);
macd.Panel = 2;
macd.Plots[0].Brush = Brushes.Transparent;
macd.Plots[1].Brush = Brushes.Transparent;
macd.Plots[2].Width = 4;
AddChartIndicator(macd);
AddLine(Brushes.Red, MACDUpperBoundary, "UpperBoundary"); // MACDUpperBoundary=0.3
AddLine(Brushes.Red, MACDLowerBoundary, "LowerBoundary");// MACDLowerBoundary=-0.3
}
}
Comment