how to: add together first and last trades profit?

 

hi

so, we're talking only about currently opened trades. i would like to add the profit of the first and the last one together. i can add all the trade's profits together, but thats not what i want, so what do you guys suggest? the trades have not been named like ticket_11 or whatever, so an orderselect by position should do the trick...
i was thinking of this, but its obviously rubbish:

{
   OrderSelect(0,SELECT_BY_POS,MODE_TRADES); //first trade
   AllProfit += OrderProfit();
   OrderSelect(Total-1,SELECT_BY_POS,MODE_TRADES); //last trade
   AllProfit += OrderProfit();
}

just so you don't think i'm a lazy bastard, heres the code for adding everything together :D

for (int cnt = 0 ; cnt < total ; cnt++)
   {
      OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      AllProfit += OrderProfit();
   }

so if any of you care to help i appreciate it! thanks!

 
double  firstProfit=0,
        lastProfit=0;
int     openCount=0;
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol() ){              // and my pair.
    openCount++;
    if (openCount == 1) lastProfit = OrderProfit();
    firstProfit = OrderProfit();
}
 

hi

thanks for the idea! in your code the first and last profit is declared seperately in firstProfit and lastProfit if i get it right. if i am going to add them together anyway, wouldnt it be better to make it like this?: AllProfit += OrderProfit();

double  pos;
double  firstProfit=0,
        lastProfit=0;
int     openCount=0;
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol() ){              // and my pair.
    openCount++;
    if (openCount == 1) AllProfit += OrderProfit();
}
 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

Reason: