Problem getting MC to access the desired Data Series

Questions about MultiCharts and user contributed studies.
bobbakerr
Posts: 9
Joined: 29 Aug 2010
Has thanked: 2 times
Been thanked: 1 time

Problem getting MC to access the desired Data Series

Postby bobbakerr » 29 Aug 2010

I'm trying to write a program to automatically trade for me. However, the program Enters positions off of Data #1, when I've told it to Enter off of Data #2. It Exits off of Data #1, which is correct. If anyone can help me by pointing out what I've done wrong, I'd be very grateful. Otherwise, I think there is a 'bug' in MC.

Here is my Code:

Code: Select all

inputs:  F1(12),S1(20),L1(6),F2(12),S2(20),L2(6),F3(270),S3(585),L3(203),
          T1(0600),T2(1410){,X(5)},Y(90);
variables:  MACD1(0),MACD2(0),MACD3(0),OldMA(0),MACDBuy(9999),MACDSS(-9999);

MACD1=MACD(Close of Data1,F1,S1); // Uses 240-Tick chart.
MACD1=XAverage(MACD1,L1); // Exit off of this.
MACD2=MACD(Close of Data2,F2,S2); // Uses 480-Tick chart.
MACD2=XAverage(MACD2,L2); // Enter off of this.
MACD3=MACD(Close of Data3,F3,S3);


if CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition<=0
  and MACD2[1]<0 and MACD2[1]<MACD2[2] and MACD2>MACD2[1] and MACD3>MACD3[1]
  and AverageFC(Close of Data2,Y) > OldMA then begin
   Buy next bar at market;
   MACDBuy=MACD2;
  end;   
   
If MarketPosition=1 and MACD1[1]>0 and MACD1<MACD1[1] then Sell next bar at market;   


If CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition>=0
  and MACD2[1]>0 and MACD2[1]>MACD2[2] and MACD2<MACD2[1] and MACD3<MACD3[1]
  and AverageFC(Close of Data2,Y){AverageFC(Close,Y) of Data2} < OldMA then begin
   SellShort next bar at market;
   MACDSS=MACD2;
  end;   

If MarketPosition=-1 and MACD1[1]<0 and MACD1>MACD1[1] then BuyToCover next bar at market;   
   
Setstoploss(400);
   
SetExitOnClose;

OldMA=AverageFC(Close of Data2,Y);

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1899 times

Re: Problem getting MC to access the desired Data Series

Postby TJ » 29 Aug 2010

try this:

MACD2 = MACD(Close, F2, S2) Data2;

bobbakerr
Posts: 9
Joined: 29 Aug 2010
Has thanked: 2 times
Been thanked: 1 time

Re: Problem getting MC to access the desired Data Series

Postby bobbakerr » 29 Aug 2010

No, TJ, it didn't help. In fact, it eliminated most of the trades and knocked almost $4000 off of the profit. But thank you for the suggestion.

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1899 times

Re: Problem getting MC to access the desired Data Series

Postby TJ » 29 Aug 2010

TJ wrote:try this:

MACD2 = MACD(Close, F2, S2) Data2;


p.s. you have to apply the same for all dataX components.

bobbakerr
Posts: 9
Joined: 29 Aug 2010
Has thanked: 2 times
Been thanked: 1 time

Re: Problem getting MC to access the desired Data Series

Postby bobbakerr » 29 Aug 2010

(I did.) I think MC has a bug.


Return to “MultiCharts”