Hi all,
I am not sure if I have my thinking wrong or not.
I have a simple backtest built off an indicator and it shows the black program termination mark on the very last bar (RHS) and a sell (X), whether the indicator
is in sell or not.
To me this is a false and misleading signal, and I have to look at the indicators to determine if it hasnt just flagged a real sell or not. I dont why it would do that.
Any assistance would be greatly appreciated.
Although the following code uses a CALL, the problem exists on other backtests as well using standard indicators.
Thanks for any assistance you can provide
John
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
ignored, indicator1 = CALL JBWaveTrendDiff
c1 = (indicator1 > 0)
IF c1 THEN
BUY 5000 CASH AT MARKET
ENDIF
// Conditions to exit long positions
ignored, indicator2 = CALL JBWaveTrendDiff
c2 = (indicator2 < 0)
IF c2 THEN
SELL AT MARKET
ENDIF
To write code, please use the <> “insert PRT code” button, to make code easier to read. Thank you.
For anyone to be of help, please post the code for the CALLed indicator or modify the code using a standard indicator.
Hi Roberto,
sorry about the code.
Indicator code is below:
n1 = 10 //Channel Length
n2 = 21 //Average Length
ap = medianprice
esa = exponentialaverage[n1](ap)
apesa = abs(ap - esa)
d = exponentialaverage[n1](apesa)
ci = (ap - esa) / (0.015 * d)
tci = exponentialaverage[n2](ci)
wt1 = tci
wt2 = average[4](wt1)
RETURN 0 as "0", (wt1-wt2)*20 coloured(0,0,200) as "difference"
It works, as far as I understand what it does, I tested it on a Daily TF on a coulple of stocks as from attached pics. I embedded the indicator in the strategy, but this shouldn’t make any difference. I used GRAPH to debug the strategy:
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
n1 = 10 //Channel Length
n2 = 21 //Average Length
ap = medianprice
esa = exponentialaverage[n1](ap)
apesa = abs(ap - esa)
d = exponentialaverage[n1](apesa)
ci = (ap - esa) / (0.015 * d)
tci = exponentialaverage[n2](ci)
wt1 = tci
wt2 = average[4](wt1)
//RETURN 0 as "0", (wt1-wt2)*20 coloured(0,0,200) as "difference"
// Conditions to enter long positions
indicator1 = (wt1-wt2)*20
c1 = (indicator1 > 0)
c2 = (indicator1 < 0)
IF c1 THEN
BUY 5000 CASH AT MARKET
ENDIF
// Conditions to exit long positions
IF c2 THEN
SELL AT MARKET
ENDIF
graph indicator1
Did you set your initial capital large enough to accomodate all losses?
This is a “normal” behavior if you backtest a strategy on a stock you haven’t the real time subscription. Is it the case? 😉
Hi Nicolas and thanks,
I dont recall it being normal some time ago with the end of day version on other backtests I had. I think I only started seeing it with 10.3 perhaps?
I wouldnt mind the black stop line signalling the end of run, its the sell signal that is just plain incorrect logic. It should not flag a sell unless the logic says to sell, not the end of program.
Even if it isnt real time, it shouldnt give misleading signals which are effectively telling you to close out each day. I am trying to use the backtest to work out what I do on the next day, not much use if it constantly tells me every day to close out open positions.
I dont need real time, since I work the ASX and its not available real time through PRT but I shouldnt expect different behavoiur in the two either.
Thanks for your help
John
Thank you Roberto for your effort in setting it up and testing it. The stock I used as an example the capital went up over the period, not down so running out of funds was not an issue.
As per Nicolas post, It seems realtime works differently to end of day. As I said in response to Nicolas, it would be better with the sell signal not being there.
End of run line OK, but an end of run shouldnt force a close out of position. I think that is an error.
Thanks again.