can not compile

 

Hi guys, a bit of WHReoder program was suggested to me,I cant get it to compile.

I am trying to get the last profit taken (order price level ) to use for continuation of

trend for intri level.

int GetHistoryOrderByCloseTime(int& tickets[], int dsc=1){  #define ASCENDING -1
    /* https://forum.mql4.com/46182 zzuegg says history ordering "is not reliable
     * (as said in the doc)" [not in doc] dabbler says "the order of entries is
     * mysterious (by actual test)" */
    int nOrders = 0;    datetime OCTs[];
    for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY)  // Only orders w/
    &&  OrderMagicNumber()  == Magic.Number             // my magic number
    &&  OrderSymbol()       == chart.symbol             // and my pair.
    &&  OrderType()         <= OP_SELL//Avoid cr/bal forum.mql4.com/32363#325360
    ){
        int nextTkt = OrderTicket();        datetime nextOCT = OrderCloseTime();
        nOrders++; ArrayResize(tickets,nOrders); ArrayResize(OCTs,nOrders);
        for (int iOrders=nOrders - 1; iOrders > 0; iOrders--){  // Insertn sort.
            datetime    prevOCT     = OCTs[iOrders-1];
            if ((prevOCT - nextOCT) * dsc >= 0)     break;
            int         prevTkt = tickets[iOrders-1];
            tickets[iOrders] = prevTkt;    OCTs[iOrders] = prevOCT;
        }
        tickets[iOrders] = nextTkt;    OCTs[iOrders] = nextOCT; // Insert.
    }
    return(nOrders);
}
:
    int     tickets[],      nTickets = GetHistoryOrderByCloseTime(tickets);
    for(int iTicket = 0; iTicket < nTickets; iTicket++) if (
        OrderSelect(tickets[iTicket], SELECT_BY_TICKET) 
    ){
        double  profit  = OrderProfit() + OrderSwap() + OrderCommission(),
 

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

That code is not even complete :(

 
onewithzachy:

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

That code is not even complete :(


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.

 
ray2955:


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.

My apology, can not help. That's should be an 'include', but for what, I have no idea. You just have to wait for DeVries or WHRoeder then :(
 
onewithzachy:
My apology, can not help. That's should be an 'include', but for what, I have no idea. You just have to wait for DeVries or WHRoeder then :(


I do not have to use this bit of code. There is no restriction Im just trying to get some help.

Thanks.

 

That code snippet was not posted to be copy pasted as a complete function into an EA, it was posted that you might learn from it how to create your own code.

 
SDC:

That code snippet was not posted to be copy pasted as a complete function into an EA, it was posted that you might learn from it how to create your own code.


As i look at the code there isnt a look at the last executed TP price. How do I code a look at that price.

OrderHistoryTotal Ok,the last close how do I select TP close price.

Thanks.

 
ray2955:


As i look at the code there isnt a look at the last executed TP price. How do I code a look at that price.

OrderHistoryTotal Ok,the last close how do I select TP close price.

Thanks.

Was your coding to find at "need to store last profit taken" looking at
OrdersHistoryTotal( ) and then selecting the trades to get the trade needed ?

This is an example to look at it for getting an idea not a complete solution to write this way in your code

Have you ever looked to the code of the standard moving average EA

Inside of it you can find this

//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+

it is to calculate the lotsize after a loss the lotsize is decreased

maybe this is a better start for you...

but this is not checking magicnumber...

ofcours if you can not compile then there are errormessages to look at

all your closed trades are in OrdersHistoryTotal()

then select the trades till you have what you want

 
deVries:

Was your coding to find at "need to store last profit taken" looking at
OrdersHistoryTotal( ) and then selecting the trades to get the trade needed ?

This is an example to look at it for getting an idea not a complete solution to write this way in your code

Have you ever looked to the code of the standard moving average EA

Inside of it you can find this

it is to calculate the lotsize after a loss the lotsize is decreased

maybe this is a better start for you...

but this is not checking magicnumber...

ofcours if you can not compile then there are errormessages to look at

all your closed trades are in OrdersHistoryTotal()

then select the trades till you have what you want


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.

 
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 takeprofit

 
deVries:


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 takeprofit

Ok lets see

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

Im only opening one trade at a time.