Hello,
I keep getting one of my trading system rejected and I can sort it out…
The error is “This trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick.” However, I don’t need much preloadbars for this system and I don’t see any mistakes.
It is currently running on demo without problems and I was trying to implement it on the 10 seconds DAX 1€ and prt keep cutting it of for a reason that I don’t see…!
I know that some of you already encountered this kind of problem and I already had a look at how it has been solved but I can’t relate my case to those as I don’t find the same mistakes!
Thanks for your help 😀
//-------------------------------------------------------------------------
// Code principal : PPJ avec trailing stop v2
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Code principal : PPJ avec trailing stop v2
//-------------------------------------------------------------------------
DEFPARAM PRELOADBARS = 3000
// Cumul des positions désactivé
DEFPARAM CumulateOrders = False
//************************************************************************
//Horaires de trading
// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
DEFPARAM FLATBEFORE = 080000
// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
DEFPARAM FLATAFTER = 170000
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 170000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//************************************************************************
IF Time < Time[1] THEN
PlusHaut = High
PlusBas = Low
PP = (PlusHaut[1] + PlusBas[1] + Close[1]) / 3
Premierpassage=0
ELSE
PlusHaut = Max(High,PlusHaut[1])
PlusBas = Min(Low,PlusBas[1])
PP = PP[1]
ENDIF
//************************************************************************
// Conditions pour ouvrir une position acheteuse
c1 = (close CROSSES UNDER pp)
IF c1 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
Premierpassage=1
SET STOP pLOSS 50
ENDIF
// Conditions pour ouvrir une position en vente à découvert
c2 = (close CROSSES OVER pp)
IF c2 AND timeEnterBefore AND timeEnterAfter AND Premierpassage=0 AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
Premierpassage=1
SET STOP pLOSS 50
ENDIF
//************************************************************************
//trailing stop function
trailingstart = 5 //trailing will start @trailinstart points profit
trailingstep = 10 //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
newSL = tradeprice(1)+trailingstep
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep THEN
newSL = newSL+trailingstep
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
newSL = tradeprice(1)-trailingstep
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep THEN
newSL = newSL-trailingstep
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
Give your topic a meaningful title.Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Error is meaningless.
Thank you 🙂
Thanks robertogozzi! Should I create a new one or could I change it?
By the way, do you have any suggestion regarding my problem? 🙂
You can set preloaded bars to its maximum which is 10K, despite your code does not seem to need them.
Don’t duplicate posts, leave them where they are and the way they are.
Ok understood!
However I already tried that and as you said it does not even require that amount.
This is the problem and I can’t figure out what could be the problem… It keeps telling me that I don’t have enough preload bars. I think the problem is elsewhere but can’t figure out where. That’s why I came to you guys 🙂
@Nicolas?
Surely below will not work?
Below may cause the Algo stoppage … despite what the error message says?
You need the Trail Start to be more than the Trail Step (usually Start is several times the Step),
trailingstart = 5 //trailing will start @trailinstart points profit
trailingstep = 10 //trailing step to move the "stoploss"
What is the PRT version please?
Hello GraHal, Nicolas,
Thanks for your proposal GraHal! However I already have som systems that are currently running and have that set up. Just to be sure I tried and same, the system is kicked out…
@Nicolas, I’m currently in v10.3-1.8.0_202. Do you think it could come from the plateform?
I’m just asking questions in order to get a complete picture 🙂
Is the error message pop directly at start or later?
Did you try with a “preloadbars = 0”?
Oh ok 🙂
Directly at start and I tried removing the trailing stop function, the time of entry, the date and nothing changes…
I just tried with preloadbars = 0 and still out with the same error 🙁
I tried removing part by part some of the code and seems to come from this part:
ELSE
PlusHaut = Max(High,PlusHaut[1])
PlusBas = Min(Low,PlusBas[1])
PP = PP[1]
Do you know why?
Thanks! 😀
Try this, in this order, and make a test after each step if it solves the issue:
- remove the preloadbars line completely
- change the line 30 with: “if day<>day[1]”
- change the lines 46 and 55 by adding: “and pp>0” at the end of the lines (c1 and c2 conditions)
With the second change it works, not with the other. However, when I do this change, the Daily PP isn’t correct anymore..
Why not using a simplier daily pivot points formula:
Ht = DHigh(1)
Bs = DLow(1)
C = DClose(1)
Pivot = (Ht + Bs + C) / 3
Because with this formula I don’t get the right PP..
With this formula I get the right one
IF Time < Time[1] THEN
PlusHaut = High
PlusBas = Low
PP = (PlusHaut[1] + PlusBas[1] + Close[1]) / 3
Premierpassage=0
ELSE
PlusHaut = Max(High,PlusHaut[1])
PlusBas = Min(Low,PlusBas[1])
PP = PP[1]
ENDIF
And with this one I get another daily pp which isn’t good
Ht = DHigh(1)
Bs = DLow(1)
C = DClose(1)
PP = (Ht + Bs + C) / 3