How to code? - page 213

 
quest:
HI, I have problem. I need import ATR value from metatrader to csv file.

Unfortunately I do not know how to do.

Please help me write the script.

I tried using FileWrite - MQL4 Documentation and iATR - MQL4 Documentation. But I failed it..

Well the example from help file of metaeditor works quite nice:

int handle;

datetime orderOpen=OrderOpenTime();

handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');

if(handle>0)

{

FileWrite(handle, iATR(NULL,0,20,0));

FileClose(handle);

}

 

Problem with EA coding

Hello!

I`m newbie on forex market. I`m trying to build my own EA, and I succeed but i have few question about some features...

I trade on 5 different currency pairs: EURUSD, AUDUSD, USDCAD, USDJPY and NZDUSD...on H1 timeframe.

I want to implement some new features in EA, for example when EA open long trade on one currency pair and that trade goes to -50pips that my EA open another long trade on the same pair.

And, if possible to code that they both close when I have cumulative profit...maybe first one is -20 pips, but the second is +30 and to close immediatelly both (so I have +10 pips profit).

Could someone help me code it?

 
Kalenzo:
Well the example from help file of metaeditor works quite nice:

int handle;

datetime orderOpen=OrderOpenTime();

handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');

if(handle>0)

{

FileWrite(handle, iATR(NULL,0,20,0));

FileClose(handle);

}

Realy thanks.

How to adjust to import the entire history of ATR. Then complete history atr values + date?

 
quest:
Realy thanks. How to adjust to import the entire history of ATR. Then complete history atr values + date?

int handle;

datetime orderOpen=OrderOpenTime();

handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');

if(handle>0)

{

for(int x=0;x<Bars;x++)

{

FileWrite(handle, TimeToStr(Time[x]),iATR(NULL,0,20,x));

}

FileClose(handle);

}

 
Kalenzo:

int handle;

datetime orderOpen=OrderOpenTime();

handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');

if(handle>0)

{

for(int x=0;x<Bars;x++)

{

FileWrite(handle, TimeToStr(Time[x]),iATR(NULL,0,20,x));

}

FileClose(handle);

}

Wow, I do not know what to say. Thank you so much. You really helped me

 

Hi guys !

Please, what i need put in my EA to it open the orders only when the time hour equals 00:00 ? I need that it open the order only in this hour, can you put here to me the programation code ?

I trying this but it not works:

if (TimeHour(TimeCurrent() == 0)

{

OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, SL, TP, 0, Magic, 0, Lime);

}

Thank you very much !

 
Tio Patinhas:
Hi guys !

Please, what i need put in my EA to it open the orders only when the time hour equals 00:00 ? I need that it open the order only in this hour, can you put here to me the programation code ?

I trying this but it not works:

if (TimeHour(TimeCurrent() == 0)

{

OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, SL, TP, 0, Magic, 0, Lime);

}

Thank you very much !

Try this way:

int mark;

int start()

{

....

if(Hour()==0&&mark==0)

{

OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, SL, TP, 0, Magic, 0, Lime);

mark=1;

}

if(Hour()>1)mark=0;

...

}
 
Roger09:
Try this way:
int mark;

int start()

{

....

if(Hour()==0&&mark==0)

{

OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, SL, TP, 0, Magic, 0, Lime);

mark=1;

}

if(Hour()>1)mark=0;

...

}

IT WORKS !!! tHANK YOU VERY MUCH MY FRIEND, YOU IS THE MAN!!!

 

How to

How to add lines in indicator like RSI 80% RSI 20% in mql4 code , not through manual method

Guide the code used.

 
junglelion:
How to add lines in indicator like RSI 80% RSI 20% in mql4 code , not through manual method Guide the code used.

By buffer or by instruction

By instruction is something like

#property indicator_level1 30

#property indicator_level2 70

Reason: