<div dir="ltr"><div style>Two versions of the code, see at the end. The first converts my std::vectors to Rcpp equivalents. The second builds the data frame from the std::vectors.</div><div style><br></div><div style>Calling the function containing this code numerous times (hundreds if not thousands) returning the std::vectors directly seems to cause random crashes or hangs somewhere after the return statement. The other version seems to work properly.</div>
<div style><br></div><div style>Thanks,</div><div><br></div><div>  return Rcpp::DataFrame::create(</div><div>               Rcpp::Named("Entry") = Rcpp::IntegerVector(ibeg.begin(), ibeg.end()),</div><div>               Rcpp::Named("Exit") = Rcpp::IntegerVector(iendOut.begin(),iendOut.end()),</div>
<div>               Rcpp::Named("Position") = Rcpp::IntegerVector(position.begin(), position.end()),</div><div>               Rcpp::Named("StopLoss") = Rcpp::NumericVector(stopLoss.begin(), stopLoss.end()),</div>
<div>               Rcpp::Named("StopTrailing") = Rcpp::NumericVector(stopTrailing.begin(), stopTrailing.end()),</div><div>               Rcpp::Named("ProfitTarget") = Rcpp::NumericVector(profitTarget.begin(), profitTarget.end()),</div>
<div>               Rcpp::Named("ExitPrice") = Rcpp::NumericVector(exitPrice.begin(), exitPrice.end()),</div><div>               Rcpp::Named("Gain") = Rcpp::NumericVector(gain.begin(), gain.end()),</div>
<div>               Rcpp::Named("MAE") = Rcpp::NumericVector(mae.begin(), mae.end()),</div><div>               Rcpp::Named("MFE") = Rcpp::NumericVector(mfe.begin(), mfe.end()),</div><div>               Rcpp::Named("Reason") = Rcpp::IntegerVector(reason.begin(), reason.end()));</div>
<div>   /*</div><div>   return Rcpp::DataFrame::create(</div><div>               Rcpp::Named("Entry") = ibeg,</div><div>               Rcpp::Named("Exit") = iendOut,</div><div>               Rcpp::Named("Position") = position,</div>
<div>               Rcpp::Named("StopLoss") = stopLoss,</div><div>               Rcpp::Named("StopTrailing") = stopTrailing,</div><div>               Rcpp::Named("ProfitTarget") = profitTarget,</div>
<div>               Rcpp::Named("ExitPrice") = exitPrice,</div><div>               Rcpp::Named("Gain") = gain,</div><div>               Rcpp::Named("MAE") = mae,</div><div>               Rcpp::Named("MFE") = mfe,</div>
<div>               Rcpp::Named("Reason") = reason);</div><div>               */</div></div>