stavka_po_stopline

Author: �������� ������� 2011, EVgEN_SA.
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
stavka_po_stopline
//+------------------------------------------------------------------+
//|                                                   stavka_po_stopline.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Ñàâåëüåâ Åâãåíèé© 2011, EVgEN_SA."
#property link      "http://www.metaquotes.net"
#property show_inputs
#include <WinUser32.mqh>

#define OrSt "stavka po stopline"
extern int    TekstSize  = 15 ;

extern double        RiskPercent=2;
extern int    slip           = 3    ;
double               Lot;
extern int    Magic         = 227  ;

int                DigLots;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
ObjectsDeleteAll(0, OBJ_HLINE); 
 //  ObjectsDeleteAll(); 
//----
//   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   int      i;
   
 
  int sa=0;int ba=0;
   int Balance1=0;
  double CC71 =Open[0];
double CC72 =Low[0];
double CC73 =High[0];



int mng=0;



int Line_A_SK =Digits;
if  (Digits==2)mng = 100;
if  (Digits==3)mng = 1000; 
if  (Digits==4)mng = 10000; 
if  (Digits==5)mng = 100000;
if  (Digits==6)mng = 1000000;
if  (Digits==7)mng = 10000000;

 for(i=0;i<ObjectsTotal();i++)
   {
      if(StringFind(ObjectName(i),"#",0)>=0) continue;
      if(ObjectType(ObjectName(i))==OBJ_HLINE)
      
 double p=0;
 p=ObjectGet(ObjectName(i),OBJPROP_PRICE1);
 if (p>0){
Comment("ÑÒÀÂÊÀ ÁÓÄÅÒ ÓÑÒÀÍÎÂËÅÍÍÀ ×ÅÐÅÇ 13 ÑÅÊÓÍÄ");
Sleep(10000);
}
 

 
 
 }
double ip=p-Ask;
 if (ip<0) ba=1;
 if (ip>0) sa=1;
 if (p==0) sa=0;
  if (p==0) ba=0;
 //////////////////
double Tps=Bid+1000*Point;//äëÿ áóé
double Tpss=Bid-1000*Point;//äëÿ ñåë

string rt=DoubleToStr (Ask,Digits) ;//äëÿ áóé


 double sSLs=((p-Ask)*mng);//äëÿ ñåë
 double sSLss=((Ask-p)*mng);//äëÿ áóé
 double SLss= NormalizeDouble(Ask-((Ask-p)*mng)*Point,Digits); //äëÿ áóé

 //////////////////////////
if (ip<0) Lot=((AccountBalance()*RiskPercent/100.0)/((Ask-p)/Point*MarketInfo(Symbol(),MODE_TICKVALUE)));////////áóé;
 if (ip>0) Lot=((AccountBalance()*RiskPercent/100.0)/((p-Bid)/Point*MarketInfo(Symbol(),MODE_TICKVALUE)));////////ñåë;

   if (p==0){
Comment("ÍÅ ÓÑÒÀÍÎÂËÅÍÀ ÑÒÎÏ ËÈÍÈß-ÏÅÐÅÇÀÃÐÓÇÊÀ" );
Sleep(15000);
}


if (ip>0){
Comment("Order Sell. Lot=",DoubleToStr(Lot,2)," OP=",DoubleToStr(Bid,Digits)," SL=",DoubleToStr(SLss,Digits));
}
if (ip<0){
Comment("Order Buy. Lot=",DoubleToStr(Lot,2)," OP=",DoubleToStr(Ask,Digits)," SL=",DoubleToStr(SLss,Digits));
}

   
//==============================================================================//
//                          Îòêðûâàåì îðäåðà
//==============================================================================///

if (ba==1)
{

OrderSend(Symbol(),OP_BUY,Lot,Ask,slip,SLss,0,OrSt,Magic,0,Blue);

ObjectsDeleteAll(0, OBJ_HLINE); 

}

{
if (sa==1)
{

OrderSend(Symbol(),OP_SELL,Lot,Bid,slip,SLss,0,OrSt,Magic,Red);
ObjectsDeleteAll(0, OBJ_HLINE); 

}

   }
//return(0);
}

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

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