All you need to know:
%%Personally, I don't think risk management can turn a losing method into a winning method, like the old saying: Can't turn a pig's..... I was eager to see if @Buy1Sell2 could show us how instead of just preaching to us.
Actually I tried using a random number generator to generate stock prices and "traded" using "stop loss" and "trialing stop", no cigar. Not sure if the codes were error free though.
Personally, I don't think risk management can turn a losing method into a winning method
%%
It cant;
Speaking of randomness (and this is totally baffling) Tom Basso demonstrated that it is possible to make money with totally random entry points!
I am quoting from the book "Trade Your Way to Financial Freedom" (by Van K. Tharp):
"Tom Basso designed a simple, random-entry trading system … We determined the volatility of the market by a 10-day exponential moving average of the average true range.
Our initial stop was three times that volatility reading.
Once entry occurred by a coin flip, the same three-times-volatility stop was trailed from the close. However, the stop could only move in our favor. Thus, the stop moved closer whenever the markets moved in our favor or whenever volatility shrank. We also used a 1% risk model for our position-sizing system. …
We ran it on 10 markets. And it was always, in each market, either long or short depending upon a coin flip. … It made money 100% of the time when a simple 1% risk money management system was added. … The system had a (trade success) reliability of 38%, which is about average for a trend-following system."
Basso took a losing strategy--random entries--and made it profitable with just risk management.
Traders spend a lifetime searching for the best possible entry, while the key to success is the exit and the money management part.
I tested the following: Buy SPY at open, sell at close, everyday. After 25 years I was net profitable.Likewise, Basso found that risk management can indeed make a profitable system, with some markets.
Basso took a losing strategy--random entries--and made it profitable with just risk management.

%%Guys, consider this quote from @Tradex : (@ironchef , you'd probably have more success if you vary your stop action [initial placement, and tightening] similar-to/exactly like Basso did. Of course, this will add more complexity to your code.)
Here's one article about this: https://www.nasdaq.com/articles/rev...nt-your-entry-forex-trading-part-1-2016-11-05
I've found, that when people say they "tested" moving average crossovers, and conclude that "they don't work." They usually didn't test them with out-of-the-box thinking. They didn't test them with a dynamically varying period of the moving averages based upon recent price-action/volatility.
People say Stop-and-Reverse systems don't work. They can if your stop is dynamic and intelligent. And ... out-of-the-box thinking is required.
Likewise, Basso found that risk management can indeed make a profitable system, with some markets.
In sum, risk management can be an edge--in and of itself, but is certainly not the only edge, and;
Basso took a losing strategy--random entries--and made it profitable with just risk management.