How to code? - page 8

 
Michel:
I think this may be not always true. I had a discussion with Slawa about, and it seems that HISTORY, like TRADE, are not always sorted by date, and depends of the sort colonn you are using on the terminal tab. So it's more secure to scan all (!) History and compare closing dates; then remember the last one so the next time you don't need to scan the whole array.

very good idea!

 

Last order profit

Hi

This is what I use - works well.

[CODE/]///////////

int i,orders;

//Determine if the last trade was a winner or losser

orders = HistoryTotal();

//Print("PP0: orders : ", orders);

for(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) || (OrderMagicNumber() != MagicNum1)) continue;

//Print("PP11 Profit : ", OrderProfit());

if(OrderProfit()>0)

{

wl = -1;

break;

}

if(OrderProfit()<0)

{

wl = 1;

break;

}

}

[\code]

 

History script!

Please check my history script and you'll find the answer I hope so:

http://www.metatrader.info/node/111

 

Cconverting MetaStock code to MT4?

Hello!

Can anyone convert MetaStock code to MT4?

I have "Wolfe Wave" code and needs conversion.

Please find code and documents in attachment.

Thank you.

 

There is good thread about it here.

 

GetLastProfit()

fxdk:
Is there a method in mql4 for checking whether the last trade resulted in profit or loss, after it's closed?

I'm trying OrderSelect() and OrderProfit() with the HistoryTotal() using an array.. but the OrderProfit seems to be referring to the 'open order' , so it's not giving me the results im wanting.

On average, my system has 5 consecutive wins, to 1 lose. What im wanting to do is, after a losing trade, i want to increase the number of lots used as the chances are the next trade after it will be a win.

I therefore need to check what the last closed trade resulted in, before modifying the number of lots.

Any help would be appreciated...

For the History script go to:

http://www.metatrader.info/node/111

This is the code you want:

Alert("LastProfit/Loss : " , GetLastProfit());

.............................

double GetLastProfit()

{

int total = HistoryTotal();

datetime cur_order = 0;

datetime last_order=0;

double profit=0;

for(int cnt = 0 ; cnt < total ; cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);

cur_order = OrderCloseTime();

if(cur_order>last_order)

{

last_order = cur_order;

profit = OrderProfit();

}

}

return (profit);

}
 
FX-Hedger:
Hello!

Can anyone convert MetaStock code to MT4?

I have "Wolfe Wave" code and needs conversion.

Please find code and documents in attachment.

Thank you.

hi Hedger

I dont know how to convert Meta to Mt4, but i've this indicator...

Hope u like it...

Files:
wolf.mq4  9 kb
 
hellkas:
hi Hedger

I dont know how to convert Meta to Mt4, but i've this indicator...

Hope u like it...

Thanks for the Indicator hellka!

This Indicator does not catch the Wolfe Wave acuratly every time.

May be someone can improve it a little?

 

Profit in Pips

Hey,

Can anyone think of a way to calculate the profits as pips, as opposed to profit in $?

ie. a script to return the total number of pips profit so far. Or, the total number of pips profit between month x and month y.

Thanks.

 

Searching for someone to code a part in an indicator

hi there,

actually i have the MA crossover with wav indicator, it actually shows arrows for buy/sell decisions, i would like to let it work with me instead of just showing these arrows however it can buy/sell automatically ...

anyone who could do this for me, message me back, and i'll send him the indicator to do it for me.

Best Regards,

t0shiba

Reason: