Robot-Arrows-Rest

Author: ��������� (�) 2013
Orders Execution
Checks for the total of closed ordersChecks for the total of open orders
0 Views
0 Downloads
0 Favorites
Robot-Arrows-Rest
//+------------------------------------------------------------------+
//|                                            Robot-Arrows-Rest.mq4 |
//|                                               ÃðÈÃÎÐÜåâ (ñ) 2013 |
//|                                               grig4096@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "ÃðÈÃÎÐÜåâ (ñ) 2013"
#property link      "grig4096@yandex.ru"

// +--- Ïðîðèñîâêà ñòðåëî÷åê íà ãðàôèêå äëÿ îòêðûòûõ è çàêðûòûõ ïîçèöèé ----------------------------------------------------------------------------------------------+
void fArrowsRest()
{
   int      i;
   string   cArrowOpenName;
   string   cArrowCloseName;
   string   cTrendLineName;
   for( i = 0; i <= OrdersHistoryTotal(); i++ )
      if( OrderSelect( i, SELECT_BY_POS, MODE_HISTORY ) )
         if( OrderSymbol() == Symbol() )
         {
            cArrowOpenName = "#" + DoubleToStr( OrderTicket(), 0 ) + " " + fIfThenStr( OrderType() == OP_BUY, "buy", "sell" ) + " " + 
               DoubleToStr( OrderLots(), 2 ) + " " + Symbol() + " at " + DoubleToStr( OrderOpenPrice(), MarketInfo( Symbol(), MODE_DIGITS ) );
            cArrowCloseName = cArrowOpenName + " close at " + DoubleToStr(  OrderClosePrice(), MarketInfo( Symbol(), MODE_DIGITS ) );
            if( OrderType() == OP_BUY )  fArrowPaint( cArrowOpenName, OrderOpenTime(), OrderOpenPrice(), 1, Blue );
            if( OrderType() == OP_SELL ) fArrowPaint( cArrowOpenName, OrderOpenTime(), OrderOpenPrice(), 2, Red  );
            fArrowPaint( cArrowCloseName, OrderCloseTime(), OrderClosePrice(), 3, Green );
            cTrendLineName = "#" + DoubleToStr( OrderTicket(), 0 ) + " " + DoubleToStr( OrderOpenPrice(), MarketInfo( Symbol(), MODE_DIGITS ) ) + " -> " + DoubleToStr( OrderClosePrice(), MarketInfo( Symbol(), MODE_DIGITS ) );
            if( ObjectFind( cTrendLineName ) == -1 )
            {
               ObjectCreate( cTrendLineName, OBJ_TREND, 0, OrderOpenTime(), OrderOpenPrice(), OrderCloseTime(), OrderClosePrice() );
               ObjectSet( cTrendLineName, OBJPROP_STYLE, STYLE_DOT );
               ObjectSet( cTrendLineName, OBJPROP_WIDTH, 1 );
               ObjectSet( cTrendLineName, OBJPROP_COLOR, fIfThenInt( OrderType() == OP_BUY, Blue, Red ) );
               ObjectSet( cTrendLineName, OBJPROP_RAY, 0 );
            }
         }
   for( i = 0; i <= OrdersTotal(); i++ )
      if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) )
         if( OrderSymbol() == Symbol() )
         {
            cArrowOpenName = "#" + DoubleToStr( OrderTicket(), 0 ) + " " + fIfThenStr( OrderType() == OP_BUY, "buy", "sell" ) + " " + 
               DoubleToStr( OrderLots(), 2 ) + " " + Symbol() + " at " + DoubleToStr( OrderOpenPrice(), MarketInfo( Symbol(), MODE_DIGITS ) );
            if( OrderType() == OP_BUY )  fArrowPaint( cArrowOpenName, OrderOpenTime(), OrderOpenPrice(), 1, Blue );
            if( OrderType() == OP_SELL ) fArrowPaint( cArrowOpenName, OrderOpenTime(), OrderOpenPrice(), 2, Red  );
         }
}

void fArrowPaint( string cArrowName, datetime dTime, double nPrice, int nArrowCode, int nArrowColor )
{
   if( ObjectFind( cArrowName ) == -1 ) 
   {
      ObjectCreate( cArrowName, OBJ_ARROW, 0, dTime, nPrice );
      ObjectSet( cArrowName, OBJPROP_ARROWCODE, nArrowCode );
      ObjectSet( cArrowName, OBJPROP_COLOR, nArrowColor );
   }   
}

// +--- Âîâðàùàåò ñòðîêó cStr1 åñëè óñëîâèå lIf == true, èíà÷å âîçâðàùàåò ñòðîêó cStr2 -------------------------------------------------------------------------------+
string fIfThenStr( bool lIf, string cStr1, string cStr2 )
{
   if( lIf ) return( cStr1 ); else return( cStr2 );
}

// +--- Âîâðàùàåò öåëîå ÷èñëî nInt1, åñëè óñëîâèå lIf == true, èíà÷å âîçâðàùàåò öåëîå ÷èñëî nInt2 --------------------------------------------------------------------+
int fIfThenInt( bool lIf, int nInt1, int nInt2 )
{
   if( lIf ) return( nInt1 ); else return( nInt2 );
}

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 ---