Working with more than one date interval  [SOLVED]

Questions about MultiCharts and user contributed studies.
Seed83
Posts: 5
Joined: 29 Jan 2015
Has thanked: 2 times

Working with more than one date interval

Postby Seed83 » 29 Jan 2015

Hi, sorry for my poor English

I want to run a test with two or more data interval. For instance, let's take a look at the built-in signal MovAvgCross LE and SE. I want to run the test only in the week (7-13 december) and in the week(11-17 january).

inputs: Price( Close ), Length( 9 ), ConfirmBars( 1 ) ;
variables: var0( 0 ) ;
if date >1141206 and date < 1141214
and date >1150110 and date < 1150118 then begin
condition1 = Price > AverageFC( Price, Length ) ;
if condition1 then
var0 = var0 + 1
else
var0 = 0 ;

condition1 = CurrentBar > ConfirmBars and var0 = ConfirmBars ;
if condition1 then
Buy ( "MACrossLE" ) next bar at market ;
end

the backtest didn't start and I don't know why. If I type just "if date >1141206 and date < 1141214" the backtest works. What do I have to do? Thank you in advance.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Working with more than one date interval

Postby TJ » 29 Jan 2015

Hi, sorry for my poor English
I want to run a test with two or more data interval. For instance, let's take a look at the built-in signal MovAvgCross LE and SE. I want to run the test only in the week (7-13 december) and in the week(11-17 january).
inputs: Price( Close ), Length( 9 ), ConfirmBars( 1 ) ;
variables: var0( 0 ) ;
if date >1141206 and date < 1141214
and date >1150110 and date < 1150118 then begin
condition1 = Price > AverageFC( Price, Length ) ;
if condition1 then
var0 = var0 + 1
else
var0 = 0 ;
condition1 = CurrentBar > ConfirmBars and var0 = ConfirmBars ;
if condition1 then
Buy ( "MACrossLE" ) next bar at market ;
end
the backtest didn't start and I don't know why. If I type just "if date >1141206 and date < 1141214" the backtest works. What do I have to do? Thank you in advance.
YOu will need the brackets to separate the date logic, and to change one of the "and" to "OR".

Code: Select all


if (date >1141206 and date < 1141214)
OR (date >1150110 and date < 1150118)
then begin

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Working with more than one date interval  [SOLVED]

Postby TJ » 29 Jan 2015

ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

Seed83
Posts: 5
Joined: 29 Jan 2015
Has thanked: 2 times

Re: Working with more than one date interval

Postby Seed83 » 29 Jan 2015

ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713
Thank you very much!


Return to “MultiCharts”