Hi – I have the very same, but for V11.1 – 1.8.0_45.
Please notice : this is a Paper account for PRT(/IB) itself (not IG).
Also notice : I don’t post this to solve my problem (I suppose I may work it out) BUT similarities may show with the original post/problem.
The Strategy runs fine in BackTesting, but it fails for just running the Strategy “live” (Automatic Trading) as soon as it enters the Market.
I am pretty sure it is related to a recently added Indicator which in itself is simple :
DTSignal = 0
MyDT01 = ExponentialAverage[DT01Avg](Close) + 0.0001
MyDT02 = ExponentialAverage[DT02Avg](Close) + 0.0001
If MyDT02 crosses over MyDT01 then // Black over Red. Up-spike indicates Exit market for Long.
DTSignal = 0.5
endif
If MyDT01 crosses over MyDT02 then // Red over Black. Down-spike indicates Exit market for Short.
DTSignal = -0.5
endif
RETURN DTSignal as "DTSignal"
This code is called like this :
DT01AVG = 16 // 10-02-2020,PS.
DT02AVG = 32 // 10-02-2020,PS.
DTSignal = CALL "DTTrigger"[DT01AVG,DT02AVG] // 12-02-2020,PS, For Testing !
(the parameters default to 11 and 10 respectively)
and putting this on top of my code it does NOT go wrong. However, when the order enters the Market (I just attempted a Short) it fails immediately. Please notice that the call at the top of the code remained in there for dummy, but that at other places it is called for real and that I don’t even know whether it is called.
if not JustTraded then
DTSignal = CALL "DTTrigger"[DT01AVG,DT02AVG] // 09-02-2020,PS.
if LongOnMarket then
...
if not MustSell then
If HasBeenHigh and DTSignal > 0 then
I expect that something just conflicts somewhere and that it may relate to the parameter naming or something like that. Ragarding this, please notice that the same Indicator(s) also run separately for visuality :
DT01 (parameter defaults to 18):
AVG = DT01Avg
RETURN ExponentialAverage[AVG](Close) + 0.0001 as "DT01" // This one is running ahead of DT02.
DT02 (parameter defaults to 28):
AVG = DT02Avg
RETURN ExponentialAverage[AVG](Close) + 0.0001 as "DT02" // This one is running behind DT01.
Key could be that the DT01Avg and DT02Avg are being used everywhere. Thus, in the “visuality” Indicator(s) (DT01/DT02), in the calculating Indicator (DTTrigger), thus also in the Parameters of each of them and in the calling main code.
Crucial difference between the Paper program and the Backtesting program, is that the same variables are there (Backtesting) used as parameters again for varying the Backtests. If this would be the key to success somehow, then obviously *that* can not be done in the real program (never mind it runs in Paper mode).
Lastly, I just tried the code with commented-out related lines (this is the assignment of the DT01Avg and DT02Avg variables plus the call to DTTrigger.
The triggering line of code was also deactivated like this :
if not MustSell then
If 0 then // HasBeenHigh and DTSignal > 0 then // 12-02-2020,PS, Deactivated for Test.
MustSell = 1
if graph0 then
Trigger = Trigger + 0.0002
//graphonprice(((Trigger))) COLOURED (255,0,255) as "Sell to exit market because HasBeenHigh and Gain Trend urges for Trail-up"
endif
endif
endif
(with the note that many of these same sequences of code exist under here, with the difference of the + 0.0002 being 0.0003 etc.)
and further down the line :
if MustSell then // 28-05-2018,PS, This If instead of the combined sh*t.
Sell at Market
...
And now the code just works.
Please remember that the Call to the indicator can be on top of the program and that it works for each bar(-call).
Hints are welcome of course because testing is crazily tedious (wait for ages until your strategy triggers).
And as said, I hope it helps the OP seeing similarities and find his problem.
Best regards,
Peter