Adding counter to data2  [SOLVED]

Questions about MultiCharts and user contributed studies.
StefanoSF
Posts: 116
Joined: 19 Aug 2012
Location: San Francisco
Has thanked: 23 times
Been thanked: 30 times
Contact:

Adding counter to data2

Postby StefanoSF » 03 Sep 2013

Does anyone know how to code a bar counter on data2 that triggers trade on data1?

This is what I have but it counts data1 instead of data2:

Code: Select all

inputs:
ShareOrPosition( 1 ),
Price(Close),
cBars( 0 );

variables:
Count( 0 ),
Closedown(false),
Countconfirm(false);


{ ==== CONDITIONS ================================================================}

Closedown = Price[0] data2 < Price[1] data2;
if Closedown then
Count = Count + 1 else Count = 0 ; //Should count data2. The problem seems here
Countconfirm = Count = cBars;

{ ===== SETUP AND ENTRY =====================================================================}

if Countconfirm then
Buy ("LE") next bar open; // Should Buy data1



SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Adding counter to data2  [SOLVED]

Postby SP » 03 Sep 2013

With barstatus (2)=2 the code only counts at the closing tick of data 2.

Code: Select all


{ ==== CONDITIONS ================================================================}
if barstatus (2)=2 then begin

Closedown = Price[0] data2 < Price[1] data2;
if Closedown then
Count = Count + 1 else Count = 0 ;
Countconfirm = Count = cBars;

end;


Return to “MultiCharts”