Hello!! Good morning!!
Attached you can find a strategy file. This strategy tries to take in account 2 MACD indicators. The first one for data 1 and the second for data 2. If the MACD is above its average in both cases you can buy taken in account some rules. These rules work propertly but the strategy only take in account the MACD indicator of the data 1. The one in data 2 doesn´t work well.
Could you please help me why is not taken into account the MACD indicator of the data 2?
Thank you in advance
2 Data Series not working [SOLVED]
- TJ
- Posts: 7774
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
Ok, here you are. Thank you!!
input: MyStartTime (1530), MyEndTime (2100), Periodo (7);
variables: Media(0), MACD1( 0 ), MACDAvg1( 0 ), MACD2( 0 ), MACDAvg2( 0 ), Maximo(0), Minimo(0), MaximoStop(0), MinimoStop(0);
MACD1 = MACD( Close data1, 12, 26 ) ;
MACDAvg1 = XAverage( MACD1, 9 ) ;
MACD2 = MACD( Close data2, 12, 26 ) ;
MACDAvg2 = XAverage( MACD2, 9 ) ;
Media=Average(Close data1,Periodo);
Maximo=High[0];
MaximoStop=High[0];
Minimo=Low[0];
MinimoStop=Low[0];
if time > MyStartTime and time < MyEndTime
and Close data1 > Media
and MACD1 > MACDAvg1
and MACD2 > MACDAvg2
then Buy next bar at Maximo stop;
if time > MyStartTime and time < MyEndTime
and (Close data1 < Media)
and (MACD1 < MACDAvg1)
and (MACD2 < MACDAvg2)
then sellshort next bar at Minimo stop;
if Low [0] < Media then sell next bar at MinimoStop stop;
if High [0] > Media then buy to cover next bar at MaximoStop stop;
setexitonclose;
input: MyStartTime (1530), MyEndTime (2100), Periodo (7);
variables: Media(0), MACD1( 0 ), MACDAvg1( 0 ), MACD2( 0 ), MACDAvg2( 0 ), Maximo(0), Minimo(0), MaximoStop(0), MinimoStop(0);
MACD1 = MACD( Close data1, 12, 26 ) ;
MACDAvg1 = XAverage( MACD1, 9 ) ;
MACD2 = MACD( Close data2, 12, 26 ) ;
MACDAvg2 = XAverage( MACD2, 9 ) ;
Media=Average(Close data1,Periodo);
Maximo=High[0];
MaximoStop=High[0];
Minimo=Low[0];
MinimoStop=Low[0];
if time > MyStartTime and time < MyEndTime
and Close data1 > Media
and MACD1 > MACDAvg1
and MACD2 > MACDAvg2
then Buy next bar at Maximo stop;
if time > MyStartTime and time < MyEndTime
and (Close data1 < Media)
and (MACD1 < MACDAvg1)
and (MACD2 < MACDAvg2)
then sellshort next bar at Minimo stop;
if Low [0] < Media then sell next bar at MinimoStop stop;
if High [0] > Media then buy to cover next bar at MaximoStop stop;
setexitonclose;
- TJ
- Posts: 7774
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
See posts #1&2
viewtopic.php?t=11713
viewtopic.php?t=11713
Now I hope it looks like better...
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Code: Select all
input: MyStartTime (1530), MyEndTime (2100), Periodo (7);
variables: Media(0), MACD1( 0 ), MACDAvg1( 0 ), MACD2( 0 ), MACDAvg2( 0 ), Maximo(0), Minimo(0), MaximoStop(0), MinimoStop(0);
MACD1 = MACD( Close data1, 12, 26 ) ;
MACDAvg1 = XAverage( MACD1, 9 ) ;
MACD2 = MACD( Close data2, 12, 26 ) ;
MACDAvg2 = XAverage( MACD2, 9 ) ;
Media=Average(Close data1,Periodo);
Maximo=High[0];
MaximoStop=High[0];
Minimo=Low[0];
MinimoStop=Low[0];
if time > MyStartTime and time < MyEndTime
and Close data1 > Media
and MACD1 > MACDAvg1
and MACD2 > MACDAvg2
then Buy next bar at Maximo stop;
if time > MyStartTime and time < MyEndTime
and (Close data1 < Media)
and (MACD1 < MACDAvg1)
and (MACD2 < MACDAvg2)
then sellshort next bar at Minimo stop;
if Low [0] < Media then sell next bar at MinimoStop stop;
if High [0] > Media then buy to cover next bar at MaximoStop stop;
setexitonclose;
- TJ
- Posts: 7774
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times