Home Artists Posts Import Register

Downloads

Content


In  this post I am going to build furter on my previous two posts where I  tested the best trading strategy that you can use for manual and bot  trading. This time I will add the PSAR and another mysterious indicator  that you can use for determining the optimal entry positions for your  long and short trades. So let's quickly continue...

Intro

This time I will try to squeeze even better results out of this  baseline strategy by using the Parabolic SAR or 'parabolic stop and  reverse'. With this indicator I want to try to find the best entries for  long and short trading and as an exception I will only test this  strategy on the futures setup I have.

The strategy

So what about this strategy?

SMA100

Well to begin, I first start with the  baseline SMA that got me the best results and that was the SMA 100. I  also tried the EMA 100 to find out it it would perform better, but that  wasn't the case. So I use this SMA setting.

If price is above the SMA100, then only long trades may be made. And  if the price is below the SMA100, then only short trades are allowed.

PSAR

Then I use the PSAR, that I adjusted a little bit so that it was not that sensitive for ranging or flat markets.

I only adjusted the increment of this indicator from 0.02 to 0.001. This way it gor less sensitive to market ranges as I said.

If price is above the PSAR, and above the SMA, then a long position  is allowed. And if price is below the SMA and the PSAR, then only short  trades are made.

These to indicators determine the direction of the trade. However, I will also use two other signals for the actual entry.

There can only be an entry at the moment the PSAR changed from above  the price to below the price. So there are only single moments when  these shifts of above to below or vice-versa occur.

And as for the final indicator that determines the actual entry, here  I use a price surge. And to determine if there is a price surge I use a  moving average over the trading volume.

This is a 100 period moving average that acts as some sort of slowly  adjusting variable theshold. If price is below this theshold, there is  not much action in the market and clearly no signal for entry.

However, if there is a sudden increas in volume, indicated by price  that rises above its SMA100 in combination with the SMA and both the  PSAR based indicators that indicate a long or short. Then a position in  the direction of the trend is taken.

There is however one thing and that is that these sudden volume  increases do not always match the PSAR's shift from bottom to top or  vice-versa. So these are missed opportunities if you trade this with the  strict rules set in a trading bot algorithm. But if you trade manually,  then you can always use your eyeballs and market insight to determine  if you want to trade or not.

As for the exit signals. Here I use three exit types: Stop-loss, ROI setting and exit signal from a indicator.

The Stoploss, has been set to 100 percent, since I expect that the  exit signal will let me exit the trade in time. It is not the best  practice but in this case I am fairly confident that the strategy will  help me out with this. But this is not financial or trading advice here.

The second exit type is the ROI setting. Since I take the risk of  getting stopped out at 100% I also take the liberty to set my target  profit to a risk:reward of 1 to 2. So in this case if I have 200%  profits, then this is enough for me to step out.

The third exit here is the SMA100. If price gets below this line, then I assume the trend is over and exit the position.

I might search for even better exit indicators later, but this will  suffice. And I also want to keep things simple here so to afford manual  trading.

So there you have it. A strategy that uses the Parabolic SAR as its main indicator for determining the trade entry.

Let's see if I can get parabolic results here as well...

Backtest results

For the backtests I  use an automatic backtest engine and all the trading rules have been  coded into an algorithm that can automatically test the rules of the  strategy over a long period of data and over multiple trading pairs. To  avoid survivorship bias and other kinds of biases.

It also makes testing a trading algorithm much more convienent and  quick. And also this kind of backtesting is very honest, and sometimes a  bit harsh if a trading strategy idea just does not work out. It does  the tests, calculates the results and gives you the feedback without any  humen feelings.

def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:

       conditions_long = []

       conditions_short = []



       conditions_long.append(

           (dataframe['close'] > dataframe[f'ma_{self.ma.value}'])

           & (dataframe['psar_indicator'] == 0)

           & (dataframe['psar_r'] == 1)

           & (dataframe['volume'] > dataframe['vol_sma'])

       )

       conditions_short.append(

           (dataframe['close'] < dataframe[f'ma_{self.ma.value}'])

           & (dataframe['psar_indicator'] == 1)

           & (dataframe['psar_r'] == 1)

           & (dataframe['volume'] > dataframe['vol_sma'])

       )



       dataframe.loc[

           reduce(lambda x, y: x & y, conditions_long),

           ['enter_long', 'enter_tag'],] = (1, "PSAR_indicates_Long")



       dataframe.loc[

           reduce(lambda x, y: x & y, conditions_short),

           ['enter_short', 'enter_tag'],] = (1, "PSAR_indicates_Short")



       return dataframe



   def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:

       conditions_long_close = []

       conditions_short_close = []



       conditions_long_close.append(

           (dataframe['close'] < dataframe[f'ma_{self.ma.value}'])

       )



       conditions_short_close.append(

           (dataframe['close'] > dataframe[f'ma_{self.ma.value}'])

       )



       dataframe.loc[

           reduce(lambda x, y: x & y, conditions_long_close),

           ['exit_long', 'exit_tag'],] = (1, "Price_got_below_sma_after_long_exiting")



       dataframe.loc[

           reduce(lambda x, y: x & y, conditions_short_close),

           ['exit_short', 'exit_tag'],] = (1, "Price_got_above_sma_after_short_exiting")



       return dataframe

So, after I did the tests on different timeframes, at the moment the  best results can be made on the 4 hour timeframe. Which was expected  since the SMA 100 also performed well here.

The endbalance of this strategy is excellent. Seeing the amount of  trades this strategy had to make, which is even less than the 1 day  timeframe makes this strategy manageable for manual trading. If you  roughly calculate 5 years of backtest data, which is around (5 x 365)  1825 days, and you divide the amount of trades by this number, then you  get around a half a trade a day, so actually on average 1 trade every  two days or so.

As with all trend trading strategies, the winrate is low. And here  could be made a lot of improvements by adding your own personal rules to  filter out even more of the bad trades, besides the PSAR and Volume. On  average you have 4 losing trades against 2 winning trades. And the  longest losing streak detected is 19 losers after another.

All the ratios like Sharpe, Sortino and Calmare are also positive  about this way of trading, altough the Sharpe score lags a little bit  behind here.

Let's take a look at some graphs.

The weelkly performance plot has a good steady incline, but shows  also that some moments can be tense if you see these steep drop offs of  your profitability curve. Luckily these moments do not last long and at  some moment the curve stays relatively stable.

At these same moments the drawdown curve starts to rise. At some  points it reaches a maximum drawdown of 20 percent, with an average  drawdown of 7.8 percent. These numners look very good for a trend  trading strategy in my opinion.

The profits and losses graph from this backtest shows that this  strategy had regular weeks with profits of over 5000 USDT. Althoug I do  not have the information of this comes from long or short trades. Or  just both. There were some weeks that sufferd big losses, but on average these did  not came higher then, let's say 3000 USDT.

So now you have more information on the performance profile of this strategy for possible use in the future.

Now to round things off here, this plots overview shows the  comparison of this trading strategies performance over earlier tests. It does not have a specific plot that stands out in its performance,  whether that is negative or positive.

But you have to remember that most of the other well performing  algo's performances here are mainly caused by very sophisicated and  sometimes complicated trading rules that can only be done by a trading  bot. The strategy you are reading this post is made for manual  trading and has some very simple rules here.

So taken this into consideration I think it a very good performance.  Even though it is not always shown in numbers or graphs here.

This counts also for this chart. The two extremely well performing plots here are the results of very complicated trading rules.

And these results are sometimes questioned by the audience as well.  And that is totally fine by me. Because only from dialogues about these  results we can all learn something. And that can make us all perform  better in trading. Just keep the conversation  friendly.

Now these tests gave this strategy a score of 422 points according to  my personal scoring mechanism. And that score made this strategy enter  the league on the 4th spot. Right between most of the black box trading  algorithms.

A very wel deserved spot for such a simple manual trading strategy. I  think that, if you used this strategy as a baseline for further  development, you might have a chance to have a pretty good trading  strategy in your hands. But this is not financial advice and please do  your own research before using any of these strategies.

And so we come to the end of this post.

Many thanks to all of you who are still reading and I hope this  strategy gave you some inspiration to test out things for yourself too.  And maybe improve it here and there as well.

I am curious if anyone can provide us with an excellent exit indicator or signal to improve on this strategy even further.

Thanks for liking and commenting.

Until the next time, where I have something very special to show you!!

Goodbye!


Comments

Michael

Hello D€D.. still a download problem -> virus detected

Michael

Am I the only having this problem with Google Chrome?

Michael

Same thing with Microsoft Edge & Mac

Dutch Algotrading

I reuploaded the file but this time in zip. hope this helps! ALso checking the file online did not gave me any results. Here is virustotal result as an example: https://www.virustotal.com/gui/file/4fd417caa5f73e05e0184cc93026506d740674519a877f65dc4979ea6b17f455/detection

Michael

On the download windon, it just says "virus detected" and there is no way of downloading it. Maybe this has something to do with 7z?

Michael

It's working now with simple zip files

Adam Iulian

ImportError: Short strategies cannot run in spot markets. Please make sure that this is the correct strategy and that your trading mode configuration is correct. You can run this strategy in spot markets by setting `can_short=False` in your strategy. Please note that short signals will be ignored in that case.