I have a problem that my strategy plot does not show up on all Tickers.
Here is the code:
SetBarsRequired( sbrAll );
PriceField = ParamField("Stop Price Field",2); // Default is Low
ExitPriceField = ParamList("Exit Criteria","End-of-Day,Intraday");
ExitField = IIf(ExitPriceField=="End-of-Day",Close,Low);
SpikeBounceLevel = Optimize("SB",-500,-1000,500,10);
SpikeBounce = Ref(Foreign("~1MonthNHNL","Close"),-1) <= SpikeBounceLevel AND Foreign("~1MonthNHNL","Close") > SpikeBounceLevel;
Buy = SpikeBounce;
Sell = 0;
trailARRAY = Null;
trailstop = 0;
ATRPeriods = Param("Stop Loss ATR",63,1,100,1);
ATRRange = ATR( ATRPeriods );
ATRFactor = Param("ATR Factor",1.5,0,5,0.1);
StopLevel = ATRFactor * ATRRange;
for( i = 1; i < BarCount; i++ )
{ StopLine = PriceField[ i ] - stoplevel[i]; // Stop Loss Value is normaly Low minus ATR value
if( trailstop == 0 AND Buy[ i ] )
{
trailstop = StopLine; // Set Initial stop below Entry Signal bar
}
else Buy[ i ] = 0; // remove excess buy signals
if( trailstop > 0 AND ExitField[ i ] < trailstop ) // Determine if Exit Price (Low or Close) is below trailing stop
{
Sell[ i ] = 1; // Sell if trailing stop is below Exit Criteria i.e. Close for End-Of-Day or Low for Intraday
trailstop = 0;
}
if( trailstop > 0 )
{
trailstop = Max( StopLine, trailstop ); // Determine Trailing Stop
trailARRAY[ i ] = trailstop;
}
}
Plot( trailARRAY,"trailing stop level", colorRed,styleLine,Null,Null,1);
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
_TRACE("This is selected value of Bounce: " + SpikeBounce );
_TRACE("This is selected value of Buy: " + Buy );
_TRACE("This is selected value of Open: " + Open );
Below are examples of some charts/tickers where you can see the buy arrows/trailing stop/exit arrows being plotted correctly. The tickers are $SPX, AMZN.
Below are example charts/tickers where you can not see the buy arrows/trailing stop/exit arrows being plotted correctly. The tickers are &ES, INTU.
If I flick through the NASDAQ 100 ticker list about 5 tickers will show the plot and the other 95 show nothing.
I have been searching through the forum and Knowledge Base, tried to troubleshoot with Trace and stripping down and simplifying the code where possible, but have not found a solution yet. Obviously the code is incorrect/incomplete but I can not figure where the error is.
Would appreciate some help on this.
Let me know if you need more information.