Exp_-_LineOfZERO

Author: Copyright © 2010, expforex
Orders Execution
Checks for the total of open orders
0 Views
0 Downloads
0 Favorites
Exp_-_LineOfZERO
ÿþ//+------------------------------------------------------------------+

//|                                             Exp - LineOfZERO.mq4 |

//|                                       Copyright © 2010, expforex |

//|                                        http://www.expforex.at.ua |

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

#property copyright "Copyright © 2010, expforex"

#property link      "http://www.expforex.at.ua"



#property indicator_chart_window



extern int OP=-1;

extern int Magic=-1;

int start()

  {

   int    counted_bars=IndicatorCounted();

//----

   SetHLine(Green,"LineofZERO",startZERO(OP));

//----

   return(0);

  }

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







double startZERO(int OP=0)

  {

   double BuyLots=0;

   double SellLots=0;

   double BuyProfit=0;

   double SellProfit=0;

   int Total=OrdersTotal();

   for(int i=Total-1;i>=0;i--)

     {

      if(OrderSelect(i,SELECT_BY_POS))

        {

         if(OrderSymbol()!=Symbol()&&( OrderMagicNumber()!=Magic || Magic==-1)) continue;

         if(OrderType()==OP_BUY)

           {

            BuyLots=BuyLots+OrderLots();

            BuyProfit=BuyProfit+OrderProfit()+OrderCommission()+OrderSwap();

           }

         if(OrderType()==OP_SELL)

           {

            SellLots=SellLots+OrderLots();

            SellProfit=SellProfit+OrderProfit()+OrderCommission()+OrderSwap();

           }

        }

     }

   double Price=0;

   double TickValue=MarketInfo(Symbol(),MODE_TICKVALUE);

   if(BuyLots>0) double BuyLevel=NormalizeDouble(Bid-(BuyProfit/(TickValue*BuyLots)*Point),Digits); else BuyLevel=0;

   if(SellLots>0) double SellLevel=NormalizeDouble(Ask+(SellProfit/(TickValue*SellLots)*Point),Digits); else SellLevel=0;

   if((BuyLots-SellLots)>0) Price=NormalizeDouble(Bid-((BuyProfit+SellProfit)/(TickValue*(BuyLots-SellLots))*Point),Digits);

   if((SellLots-BuyLots)>0) Price=NormalizeDouble(Ask+((BuyProfit+SellProfit)/(TickValue*(SellLots-BuyLots))*Point),Digits);

   string Title="#@>25=L 157 C1KB:0 4;O "+Symbol();

   string ZeroLevel=" =5 ACI5AB2C5B";

   if(Price>0) ZeroLevel=" = "+DoubleToStr(Price,Digits);

   string Buy=" =5 ACI5AB2C5B";

   if(BuyLevel>0) Buy=" = "+DoubleToStr(BuyLevel,Digits);

   string Sell=" =5 ACI5AB2C5B";

   if(SellLevel>0) Sell=" = "+DoubleToStr(SellLevel,Digits);

   string Message="#@>25=L 157 C1KB:0"+ZeroLevel+"\t\n#@>25=L =0 ?>:C?:C"+Buy+"\t\n#@>25=L =0 ?@>406C"+Sell;

 if (Price==0)Price=Ask;

   if(OP==OP_BUY)return(BuyLevel);

   if(OP==OP_SELL)return(SellLevel); 

   if(OP==-1)return(Price);





  }

  

  

  

  void SetHLine(color cl,string nm="",double p1=0,int st=0,int wd=1) 

  {

  string Autor=" 2B>@ DC=:F88 4;O H01;>=0 : KimiV";

   if(nm=="") nm=DoubleToStr(Time[0],0);

   if(p1<=0) p1=Bid;

   if(ObjectFind(nm)<0) ObjectCreate(nm,OBJ_HLINE,0,0,0);

   ObjectSet(nm,OBJPROP_PRICE1,p1);

   ObjectSet(nm,OBJPROP_COLOR,cl);

   ObjectSet(nm,OBJPROP_STYLE,st);

   ObjectSet(nm,OBJPROP_WIDTH,wd);

  }



  

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