Newbie trying to figure out really simple problem

To add comments, please log in or register
Max Weiss
21
Max Weiss  

Hello, everyone,
I started learning how to program in MQL5 today and I'm trying to make a simple moving average cross expert advisor. It compiles without errors, but when I try to test it in the strategy tester it does not seem to work, it stays still. I'm not sure if the problem is in the code or in my strategy tester settings. Below is the code:


void OnTick()
  {
double mymovingaveragearray1 [], mymovingaveragearray2[],mymovingaveragearray3[];
int movingaveragedefinition1 = iMA (_Symbol,_Period, 05,0,MODE_EMA,PRICE_CLOSE);
int movingaveragedefinition2 = iMA (_Symbol,_Period, 75,0,MODE_EMA,PRICE_CLOSE);
int movingaveragedefinition3 = iMA (_Symbol,_Period, 85,0,MODE_EMA,PRICE_CLOSE);
ArraySetAsSeries (mymovingaveragearray1, true);
ArraySetAsSeries (mymovingaveragearray2, true);
ArraySetAsSeries (mymovingaveragearray3, true);
CopyBuffer(movingaveragedefinition1,0,0,3,mymovingaveragearray1);
CopyBuffer(movingaveragedefinition2,0,0,3,mymovingaveragearray2);
CopyBuffer(movingaveragedefinition3,0,0,3,mymovingaveragearray3);
if(
(mymovingaveragearray1[0]>mymovingaveragearray2[0])
&&(mymovingaveragearray1[0]>mymovingaveragearray3[0])
&&(mymovingaveragearray1[3]<mymovingaveragearray2[3])
&&(mymovingaveragearray1[3]<mymovingaveragearray3[3])
)
{Comment ("Buy");
}
if(
(mymovingaveragearray1[0]<mymovingaveragearray2[0])
&&(mymovingaveragearray1[0]<mymovingaveragearray3[0])
&&(mymovingaveragearray1[3]>mymovingaveragearray2[3])
&&(mymovingaveragearray1[3]>mymovingaveragearray3[3])
)
{Comment ("Sell");
}
  }


Thank you very much

amando
2283
amando  
read the documentaion, you have to split between oninit and ontick
Max Weiss
21
Max Weiss  
amando:
read the documentaion, you have to split between oninit and ontick
I Don't get it, how come?
Andrew Quallis
13
Andrew Quallis  
I'm a newbie that paid my registration fee and recently started trading but can't request my payment after satisfying my 5% qualification.
Keith Watford
Moderator
20547
Keith Watford  
Andrew Quallis:
I'm a newbie that paid my registration fee and recently started trading but can't request my payment after satisfying my 5% qualification.

What registration fee?

What are you talking about?

Juvenille Emperor Limited
Moderator
10432
Eleni Anna Branou  
Andrew Quallis:
I'm a newbie that paid my registration fee and recently started trading but can't request my payment after satisfying my 5% qualification.

You are probably talking about some broker, so contact them, we can't help you here.

To add comments, please log in or register