can not compile - page 2

 
ray2955:

Ok lets see

if (OrderHistoryTotal(1))
if ( OrderClosePrice(1) == OrderTakeProfit(1) )

Im only opening one trade at a time.


explain how do you come to use "1" in the function
 
deVries:

explain how do you come to use "1" in the function

I understand as Orderhistory accumulates the new entry is in position 1 ?
 
ray2955:

I understand as Orderhistory accumulates the new entry is in position 1 ?


Is this telling so....

int OrdersHistoryTotal( ) 
Returns the number of closed orders in the account history loaded into the terminal. 
The history list size depends on the current settings of the "Account history" tab of the terminal. 
Sample:
  // retrieving info from trade history
  int i,hstTotal=OrdersHistoryTotal();
  for(i=0;i<hstTotal;i++)
    {
     //---- check selection result
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
       {
        Print("Access to history failed with error (",GetLastError(),")");
        break;
       }
     // some work with order
    }





What program is really yours own created...

Think you don't understand att all the program you wanted to change

what is written inside other programs needs most of the time modification in other programs to let it do what you wanted to do

If you don't know what you're doing then you're certainly fail writing the solution

 
deVries 2012.04.19 10:04
ray2955:


Im sorry there is a miss communication, What im trying to do is to store or access the closed price of the last TP execution.

Example TP executed at 1.4356

There are several reasons for closing a trade. Only the TP closing price Im looking for.

Thank your for any help.


then you have to check if the trade is closed at OrderTakeProfit() ofcours in historytotal

with other words OrderClosePrice()in OrderHistory has to be the same as OrderTakeProfit() then the trade is closed at takeprofitHope you don't mind me

Hope you don't mind I'm interfering here deVries, this is too long for simple solution.

ray 2955, I think you should re - read the book again, there's example at MQL4 Book > Programming of Trade Operations > Closing and Deleting Orders, though it using OrdersTotal().

Here's what deVries mean :

int Total_History = OrdersHistoryTotal();
for (int pos = 0; pos >= Total_History; pos++)
    {
    if (OrderSelect (pos, SELECT_BY_POS, MODE_HISTORY) == true &&
        OrderClosePrice() == OrderTakeProfit())
        {
        Print ("We have the winner :) ");
        }
    }
 

I see this scrolls througth the entire history.

I have a question, a new intry into history isnt in pos. # 1

simular to mode Trade ?

Thanks for this info.

 
ray2955:

I see this scrolls througth the entire history.

I have a question, a new intry into history isnt in pos. # 1

simular to mode Trade ?

Thanks for this info.

Open MetaTrader's Terminal window (Ctrl + T), select account history tab, and do this : if you select Order tab (or Type, or price tab), you will see small triangle, That's how Order history is arranged. So number 1 in account history tab does not always necessary the most recent closed or deleted position.
 
onewithzachy:

Where do you get that, I mean the link or something.

That code is not even complete :(

Order History sort by closing date - MQL4 forum
 
onewithzachy:
Open MetaTrader's Terminal window (Ctrl + T), select account history tab, and do this : if you select Order tab (or Type, or price tab), you will see small triangle, That's how Order history is arranged. So number 1 in account history tab does not always necessary the most recent closed or deleted position.


Thanks for your help I have a better understanding on how history is stored.

I have been away from mql4 for a couple of mos. My brain was fried trying to design a robust EA.

Im back with some new ideas this is a ruebics cube challenge.

 

On a previous posting deVries provided a linc to this.

If you have any suggestions to getting last executed TP level

I would aprieciate it.Beats by Dr. Dre Tour

 
fasdfwesdgwe:
If you have any suggestions to getting last executed TP level
I gave you the link AND a code example. All you had to do was THINK and code it.
int tickets[], nTickets = GetHistoryOrderByCloseTime(tickets);
if (nTickets == 0){
    // No previous order on this chart 
    // Handle how you see fit.
}
else if (!OrderSelect(tickets[0], SELECT_BY_TICKET) ){
    Alert("unexpected");
    // Handle how you see fit.
}
else{
    double lastTP = OrderTakeProfit(); 
    // What you asked for
}
Reason: