__________ TakeProfit

Author:
__________ TakeProfit
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
__________ TakeProfit
//+------------------------------------------------------------------+
//|                                             _TakeProfitMove.mq4  |
//|                                           "ÑÊÐÈÏÒÛ ÄËß ËÅÍÈÂÎÃÎ" |
//|                Ñêðèïò ïåðåìåùàåò TakeProfit íà Distance îò ðûíêà |
//|                           Bookkeeper, 2006, yuzefovich@gmail.com |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
//#property show_inputs
//+------------------------------------------------------------------+
extern int Distance=5;            // Ðàññòîÿíèå îò ðûíêà            |
extern bool UpDoun=true; //äëÿ òîëüêî "ïîäòàñêèâàíèÿ" ê ðûíêó =false |
          //äëÿ è "ïîäòàñêèâàíèÿ" ê ðûíêó è "îòñêîêà" îò ðûíêà =true |
//+------------------------------------------------------------------+
void start() 
{
double NewPrice;
int    i,Total,Dist;
int    Dgts=MarketInfo(Symbol(),MODE_DIGITS);     
bool   GoGo;
//+------------------------------- ÓÇÍÀÒÜ ÎÃÐÀÍÈ×ÅÍÈÅ ÑÂÎÅÃÎ ÄÖ -----+
//  if(Distance<10) Dist=10;
//  else 
    Dist=Distance;
//+------------------------------------------------------------------+
  Total=OrdersTotal();
  if(Total>0)
  {
     for(i=Total-1; i>=0; i--) 
     {
        if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) 
        {
           if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) 
           {
              NewPrice=Bid-Dist*Point;
              if(UpDoun==true) GoGo=true;
              else
              {
                 if(OrderTakeProfit()<NewPrice) GoGo=true;
                 else GoGo=false;
              }
              if(GoGo==true) if(OrderModify(OrderTicket(),
                             OrderOpenPrice(),
                             OrderStopLoss(),
                             NormalizeDouble(NewPrice,Dgts),
                             OrderExpiration(),
                             CLR_NONE)!=TRUE) 
                             Print("LastError = ", GetLastError());
           }
           if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) 
           {
              NewPrice=Ask+Dist*Point;
              if(UpDoun==true) GoGo=true;
              else
              {
                 if(OrderTakeProfit()>NewPrice) GoGo=true;
                 else GoGo=false;
              }
              if(GoGo==true) if(OrderModify(OrderTicket(),
                             OrderOpenPrice(),
                             OrderStopLoss(),
                             NormalizeDouble(NewPrice,Dgts),
                             OrderExpiration(),
                             CLR_NONE)!=TRUE) 
                             Print("LastError = ", GetLastError());
           }
        }
     }
  }
}
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---