Page 1 of 1

2 Data Series not working

Posted: Jun 25 2024
by neckar
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

Re: 2 Data Series not working

Posted: Jun 26 2024
by TJ
Please post your code. Not everyone wants to open a pla file.


See posts #1&2
viewtopic.php?t=11713

Re: 2 Data Series not working

Posted: Jun 26 2024
by neckar
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;

Re: 2 Data Series not working

Posted: Jun 26 2024
by TJ
See posts #1&2
viewtopic.php?t=11713

Re: 2 Data Series not working

Posted: Jun 26 2024
by neckar
Now I hope it looks like better... :D

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;

Re: 2 Data Series not working

Posted: Jun 26 2024
by TJ

Re: 2 Data Series not working  [SOLVED]

Posted: Jun 27 2024
by neckar
Thank you, Thank you, Thank you very much.
Now is working propertly.