Plotting indicator from a system

Is there some setting or additional code that's required to plot an indicator from within system code? The indicator I have works fine if plotted as an indicator but when I use it in the system nothing is plotted.

Thanks very much for your input!

//INTRODUCTORY SETTINGS AND INPUTS	
NumPos = 1; 	//Number of allowed positions
SetPositionSize(100/NumPos,spsPercentOfEquity);
SetOption( "MaxOpenPositions", NumPos );
SetTradeDelays(1,1,1,1);
BuyPrice = Open;
SellPrice = Open;
SecTrendSum = 0;	//Sum of sectors in uptrends

//INPUTS
Sec_MA_len = Optimize("SecMA Len", 20, 10, 30, 2);
BreadthBuy = Optimize("Breadth Buy", 5, 1, 9, 1);
BreadthSell = 3; //Optimize("Breadth Sell", 4, 0, 9, 1);



//Gather relative data from cap weighted sectors

	SetForeign("SPY");
	Mkt = C;
	
	SetForeign("XLB");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	//SetForeign("XLC"); --- data starts in late 2018
	//SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLE");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLF");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLI");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLK");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLU");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLV");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	SetForeign("XLY");
	SecTrendSum = SecTrendSum + IIf(MA(C/Mkt,Sec_MA_len) > Ref( MA(C/Mkt,Sec_MA_len), -1),1,0);
	
	RestorePriceArrays(); 

//Plot indicators with buy and sell levels
Plot(SecTrendSum, "SecTrendSum", ColorRGB( 128, 128, 255 ), 1);
Plot(BreadthBuy, "Buy level", colorBlue, 32); 
Plot(BreadthSell, "Sell level", colorRed, 32);

Buy = SecTrendSum >= BreadthBuy;
Sell = SecTrendSum <= BreadthSell;


Filter = 1;
AddColumn( C, "SPY", format = 1.2);
AddColumn( SecTrendSum, "SecTrendSum", format = 1.2);

Analysis window is not a chart. To plot a chart use formula in the chart.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.