Since I don’t know if a picture of my notebook is really helpfull for anybody, here is a little guide and toolkit to test the method we are discussing. This way everybody can check for themselves.
We can backtest a different set of indicator values with PRT. Run a simple backtest with the respective range for the indicator value. Sort the results according to the indicator you are testing. Don’t close the result list! Prorealtime provides a reasonably good result table IMO.
Here is the position sizing function:
MAXSHARES = (COUNTOFLONGSHARES <= 5)
If longonmarket and COUNTOFLONGSHARES <= MAXSHARES then
Buy 1 contract at market
//Buy 5 contracts at market
Endif
Set stop loss positionsize×X
Set target positionsize×X
Time dependent entry and exit variables can also be tested with adapting values.
In this example the system initiates the sequence of trades with a time lag:
If (entrycondition = true) and longonmarket and COUNTOFLONGSHARES <= MAXSHARES and BARINDEX-TRADEINDEX(1)>=X then
Buy 1 contract at market
Endif
This will help to calculate returns for a long term etf strategy buying regularly like Casper’s great piece. https://www.prorealcode.com/topic/vusa-daily-buy-and-hold-v2-0/
If we buy a real etf and not a cfd on a etf the cost calculation is a lot more easy.
Another possibility is to wait for better prices before adding more positions:
If longonmarket and COUNTOFLONGSHARES <= MAXSHARES and close < tradeprice[1] then
Buy 1 contract at market
Endif
Maybe somebody else provides the code to withhold the first trade before the price drops. In the example above, at least we don’t miss any big move completely. A more classic trendfollowing approach is waiting for the price to actually go up first. I added the example because it’s also included in the book chapter mentioned in my last post.
Of course a time based exit with adapting values can also be implemented. For every new trade, the exit is delayed.
If onmarket and BARINDEX-TRADEINDEX(1)>=X then
Sell at market
Endif
As usual more complex functions can be applied to change the indicator values. This way we can test different distributions other than linearity. In the examples above X marks the indicator which is tested. An example for an exponential distribution:
X = round(exp(indicator value)-1)×100 //the round can be excluded if not needed
For full enjoynment, here is a helpful formula collection:
http://www.itl.nist.gov/div898/handbook/eda/section3/eda366.htm
I hope this helps for testing this method in Proorder. Improvements and necessary corrections to the code snippets are welcome.