View Single Post
  #20 (permalink)  
Old 04-06-2006, 06:12 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Talking

Quote:
Originally Posted by codersguru
This is my profit protector code:

PHP Code:
extern bool      ProtectProfittrue;
extern double    ProfitToProtect 150;



int start()
{
...
if(
ProtectProfit)
   
ProfitProtect(ProfitToProtect);
....
}



void ProfitProtect(double profit)
{
      
int total  OrdersTotal();
      
double MyCurrentProfit=0;
      for (
int cnt 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 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?
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Reply With Quote