Code change from v3 to v4

 

Hi I'm updating my code from version 3 to version 4 and I could use some help!

Here is my version 3 code:

if Period=60

and iMA(10,MODE_EMA,0) > iMA(20,MODE_EMA,0)

and iMA(20,MODE_EMA,0) > iMA(50,MODE_EMA,0)

then Begin

h1 = FileOpen(Symbol+"3", ";");

FileWrite(h1, "1");

FileClose(h1);

end;

How do I re-write this in Metrader v4 ? (I keep on getting an invalid handle )

if (PERIOD_H1
&& iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0) > iMA(NULL,0,20,0,MODE_EMA, PRICE_CLOSE,0)
&& iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0) > iMA(NULL,0,50,0,MODE_EMA, PRICE_CLOSE,0)

{


h1 = FileOpen("GBPJPY3", FILE_CSV|FILE_READ,';');

FileWrite(h1, "1");

FileClose(h1);

}

Thank You In Advance,

 

Are you a DElphi programmer?

If you want to write to file, you need to open FILE_WRITE, also MT uses double-quotes, i.e. ";"

 

Thanks for your help and YES I am a Delphi programmer? How could you tell?

 
what about this

  if ( PERIOD_H1 
       && iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0) > iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0) 
       && iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0) > iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,0)  
     )
   {
     //---do the job
   }

you seems forget one parenthesis
 
Raymond1:

Thanks for your help and YES I am a Delphi programmer? How could you tell?


Ha-ha you wrote delphi code instead of MQ4 code.