2 Data Series not working  [SOLVED]

Questions about MultiCharts and user contributed studies.
neckar
Posts: 4
Joined: Jun 19 2019
Has thanked: 1 time
Been thanked: 1 time

Jun 25 2024

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
Attachments
Double Macd.pla
(3.49 KiB) Downloaded 90 times

User avatar
TJ
Posts: 7774
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

Jun 26 2024

Please post your code. Not everyone wants to open a pla file.


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

neckar
Posts: 4
Joined: Jun 19 2019
Has thanked: 1 time
Been thanked: 1 time

Jun 26 2024

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;

User avatar
TJ
Posts: 7774
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

Jun 26 2024

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

neckar
Posts: 4
Joined: Jun 19 2019
Has thanked: 1 time
Been thanked: 1 time

Jun 26 2024

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;

User avatar
TJ
Posts: 7774
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

Jun 26 2024


neckar
Posts: 4
Joined: Jun 19 2019
Has thanked: 1 time
Been thanked: 1 time

Jun 27 2024

Thank you, Thank you, Thank you very much.
Now is working propertly.