nevalyashka_v1

Author: Copyright © 2015, Skype: mqlcmillion
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersChecks for the total of closed orders
0 Views
0 Downloads
0 Favorites
nevalyashka_v1
ÿþ//+------------------------------------------------------------------+

//|                                                  nevalyashka.mq4 |

//|                            Copyright © 2015, Skype:  mqlcmillion |

//|                                                cmillion@narod.ru |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2015, Skype:  mqlcmillion "

#property link      "cmillion@narod.ru"

#property strict

#property description "!>25B=8: ?5@52>@0G8205B >@45@0 ?>A;5 70:@KB8O"

//---

extern int    stoploss=10,//AB>?;>AA

takeprofit  = 20,  //B59:?@>D8B

Magic       = 123; //845=B8D8:0F8>==K9 =><5@ >@45@>2 A>25B=8:0

extern double Lot         = 0.1; //=0G0;L=K9 ;>B

extern double K_Lot       = 1.5; //:>MDD8F85=B C25;8G5=8O ;>B0 ?>A;5 C1KB:0

double lot;

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int OnInit()

  {

   lot=Lot;

   if(OrderSend(Symbol(),OP_SELL,Lot,Bid,30,NormalizeDouble(Ask+stoploss*Point,Digits),

      NormalizeDouble(Bid-takeprofit*Point,Digits)," ",777,Blue)==-1) Print("Error");

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void OnTick()

  {

   int i,tip=0;

   for(i=0; i<OrdersTotal(); i++)

     {

      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

        {

         if(OrderSymbol()==Symbol() && Magic==OrderMagicNumber())

           {

            return;

           }

        }

     }

   for(i=OrdersHistoryTotal()-1; i>=0; i--)

     {

      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))

        {

         if(OrderSymbol()==Symbol() && Magic==OrderMagicNumber())

           {

            tip=OrderType();

            if(OrderProfit()<0) lot=NormalizeDouble(OrderLots()*K_Lot,2);

            else lot=Lot;

            break;

           }

        }

     }

   if(tip==OP_BUY) if(OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),30,NormalizeDouble(Ask+stoploss*Point,Digits),

      NormalizeDouble(Bid-takeprofit*Point,Digits),NULL,Magic,clrNONE)==-1) Print("Error");

   if(tip==OP_SELL) if(OrderSend(Symbol(),OP_BUY,lot,NormalizeDouble(Ask,Digits),30,NormalizeDouble(Bid-stoploss*Point,Digits),

      NormalizeDouble(Ask+takeprofit*Point,Digits),NULL,Magic,clrNONE)==-1) Print("Error");

   return;

  }

//+------------------------------------------------------------------+

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