Ask! - page 43

 

ok I'm asking...

how do I use file functions so that it appends data to the end of the file rather than overwriting it.

https://www.mql5.com/en/forum/174700/page77

please reply on the thread that this link goes to where I normally read.

 

How to retrieve a specified closed order using HistoryTotal() ?

Hi All

is there a way using HistoryTotal function to be able to find a particular order (buy or sell) closed ?

I tried with this code but it seems not working :

int hstTotal=HistoryTotal();

for(i=0;i<hstTotal;i++)

{

//---- check selection result

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)

{

if (Debug==true) Print("Access to history failed with error (",GetLastError(),")");

break;

}

if (OrderType()==OP_BUY && OrderComment()=="LONG")

{

..take some action...

}

if (OrderType()==OP_SELL && OrderComment()=="SHORT")

{

..take some action...

}

}

[/code]

And when a buy order was in place using OrderSelect I identified this using "LONG" as comment (and "SHORT" if a sell order) :

[code]

Sell:

..

..

OrderSend(Symbol(),OP_SELL,Lots,Entry,Slippage,StopLoss,TakeProfit,"SHORT",0,0);

..

..

Buy:

..

..

OrderSend(Symbol(),OP_BUY,Lots,Entry,Slippage,StopLoss,TakeProfit,"LONG",0,0);

..

..

Maybe is not supported OrderComment using MODE_HISTORY mode? And if so how can I solve this issue?

thx a lot

Skyline

 
skyline:
Hi All

is there a way using HistoryTotal function to be able to find a particular order (buy or sell) closed ?

I tried with this code but it seems not working :

int hstTotal=HistoryTotal();

for(i=0;i<hstTotal;i++)

{

//---- check selection result

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)

{

if (Debug==true) Print("Access to history failed with error (",GetLastError(),")");

break;

}

if (OrderType()==OP_BUY && OrderComment()=="LONG")

{

..take some action...

}

if (OrderType()==OP_SELL && OrderComment()=="SHORT")

{

..take some action...

}

}

[/code]

And when a buy order was in place using OrderSelect I identified this using "LONG" as comment (and "SHORT" if a sell order) :

[code]

Sell:

..

..

OrderSend(Symbol(),OP_SELL,Lots,Entry,Slippage,StopLoss,TakeProfit,"SHORT",0,0);

..

..

Buy:

..

..

OrderSend(Symbol(),OP_BUY,Lots,Entry,Slippage,StopLoss,TakeProfit,"LONG",0,0);

..

..

Maybe is not supported OrderComment using MODE_HISTORY mode? And if so how can I solve this issue?

thx a lot

Skyline

Skyline,

Be aware that the broker will append the comment with their own comments on the order for different reasons, and always when then the order is closed by SL or TP. What are the criteria for looking up the trades? Once you defone that then you'll have you solution.

 
Nicholishen:
Skyline, Be aware that the broker will append the comment with their own comments on the order for different reasons, and always when then the order is closed by SL or TP. What are the criteria for looking up the trades? Once you defone that then you'll have you solution.

Oh that's no a good news :|

Anyway i'm trying to explain my problem : in my EA I have different kind of buy (or sell), I have a kind that have to be opened whenever a condition is met also a lot of time in a day (something like that when price penetrate an EMA then an order is placed), and another type that have to be triggered only once per day depending on different conditions based on different EMA. So what I have to do is to let the first kind of buy/sell to open/close orders a lot of time in a day while the second kind of buy/sell orders have to be opened only once a day, so I thought that if I could localize in some way any kind of buy/sell order in history i could solve my problem , but it seems not possible

 

daily chart values

codersguru:
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.

Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:

High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!

 
payal:
Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:

High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!

from your description, i'm assuming you are using this on the daily chart???

to answer your question, here's how i would solve the problem.

if (DayOfWeek() == 0)

{

High[2], Low[2], Close[2], //etc

}

else

{

High[1], Low[1], Close[1],//etc

)

of course, you would arrange the high low and close to however you are using them

 
payal:
Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:

High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!

Check this file https://c.mql5.com/forextsd/forum/4/fibopiv_v3.mq4

U will find the answer for your question there.

Regards

Kale

 

Thank u

Eaglehawk:
from your description, i'm assuming you are using this on the daily chart???

to answer your question, here's how i would solve the problem.

if (DayOfWeek() == 0)

{

High[2], Low[2], Close[2], //etc

}

else

{

High[1], Low[1], Close[1],//etc

)
of course, you would arrange the high low and close to however you are using them

Thank u so much. Have a Great day!!

 

Thank u

Kalenzo:
Check this file https://c.mql5.com/forextsd/forum/4/fibopiv_v3.mq4

U will find the answer for your question there.

Regards

Kale

Thank u, have a great day!!

 

Is there any indicator that can show us the high0low ao ech bar in value in top or below each bar ?