// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM Preloadbars = 500000
// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
DEFPARAM FLATBEFORE = 101000
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 055000
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 101000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 055000
timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
timeframe (default)
// Conditions to enter long positions
indicator1, indicator2, ignored, ignored = CALL "PRC_DynamicRSI"[0.1, 0.1, 14, 60]
c1 = (indicator1 > indicator2)
indicator3 = DEMA[14](close)
indicator4 = CALL "PRC_Adaptive-ATR-ADX-Trend-V2"[14, 3.5, 1.75, 14, 30, 0, 1](close)
c2 = (indicator3 CROSSES OVER indicator4)
c3 = (indicator3 > indicator4)
c4 = (indicator1 CROSSES OVER indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF (c3 AND c4) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET TARGET pPROFIT 6
QUIT
It maybe that your broker won’t allow you to preload 500k bars IG for instance only allows 200K
Forum is full of people with code not working, please describe with words what is your problem exactly and take the time to:
- 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’.
I have changed the preload to 200k, but still not working. I’m using the time frame 150 second may be that is the reason ??
PreLoadBars are limited to 10K, no matter what you write in your code.
200K or more ar the bars that can be used for backtesting.
It appears that the problem is not DEFPARAM. Check what kind of indicators you re using and how many bars they require (a 5000-period Ema could exceed 10K bars for calculations).
You should post your code so that it can be tested (with details on TF used and instrument traded).
The code is posted above.
Code in text is good (as you have posted) but if you also post the .itf file then we not need to go looking for the Indicators and also we would have the .itf all set up with the same variable values as you are using.
I will then test on my Platform and see if I get the same error as you.
Code of indicators, this is what Roberto is talking about. The problem is surely located in that codes 🙂
The file is attached for your review.
[attachment file=”176639″]
Instrument and Timeframe?? We need to have same set up as you.
Doesn’t take a single trade over 100k bars backtest … see attached … is that what you get?
I could only find out that the could be in the indicator “PRC_Adaptive-ATR-ADX-Trend-V2”, as replacing line 24 with this one:
indicator4 = 1//CALL "PRC_Adaptive-ATR-ADX-Trend-V2"[14, 3.5, 1.75, 14, 30, 0, 1](close)
got rid of any error message.
I could not spot the issue in the indicator, though.