
04-06-2006, 06:12 PM
|
 |
Senior Member
|
|
Join Date: Oct 2005
Posts: 994
|
|
Quote:
|
Originally Posted by codersguru
This is my profit protector code:
PHP Code:
extern bool ProtectProfit= true; extern double ProfitToProtect = 150;
int start() { ... if(ProtectProfit) ProfitProtect(ProfitToProtect); .... }
void ProfitProtect(double profit) { int total = OrdersTotal(); double MyCurrentProfit=0; for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == MagicNumber) MyCurrentProfit += OrderProfit(); } Print("My Current Profit is : " + DoubleToStr(MyCurrentProfit,2) + " While My Profit Target is " + DoubleToStr(profit,2)); if(MyCurrentProfit>=profit) CloseAll(); } void CloseAll() { int total = OrdersTotal(); for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == MagicNumber) if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Violet); } }
|
I've set my profit protectot level to 150USD and I'll (ojala) get them!
150USD from 100USD in 5 hours are ??? what?
|