KantorInformationDD





//+------------------------------------------------------------------+
//|                                   KantorInformation v1.00               |
//|                                   Copyright © 2008, Denkhaus     |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Denkhaus Logic Research 2008"
#property indicator_chart_window

extern bool    ShowMarketPrice   = true;
extern color   ColorMarketPrice  = White;
extern bool    ShowAvgEntryPrice  = true;
extern color   ColorAvgEntryPrice = DodgerBlue;

extern bool    ShowDailyWL       = false;
extern color   ColorDailyWL      = Yellow;
extern bool    ShowHourlyWL      = false;
extern color   ColorHourlyWL     = Olive;
extern bool    ShowAverageWL     = False;
extern color   ColorAverageWL    = Orange;

extern bool    ShowLineLabels    = true;
extern bool    ShowSwapInfo      = true;
extern int     WLShift           = 0;
//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void init()
{   
   DeleteObjects();  
}
//+------------------------------------------------------------------+
//|  Custom indicator iteration function                             |
//+------------------------------------------------------------------+  
void deinit()
{
   DeleteObjects();   
   return(0);
}
//+------------------------------------------------------------------+
//|  Custom indicator iteration function                             |
//+------------------------------------------------------------------+
void start()
{
   double Avg1_H1    = iMA(NULL, PERIOD_H1, 5,  0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg2_H1    = iMA(NULL, PERIOD_H1, 7,  0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg3_H1    = iMA(NULL, PERIOD_H1, 22, 0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg4_H1    = iMA(NULL, PERIOD_H1, 34, 0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg1_D1    = iMA(NULL, PERIOD_D1, 5,  0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg2_D1    = iMA(NULL, PERIOD_D1, 7,  0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg3_D1    = iMA(NULL, PERIOD_D1, 22, 0, MODE_SMA, PRICE_CLOSE, WLShift);
   double Avg4_D1    = iMA(NULL, PERIOD_D1, 34, 0, MODE_SMA, PRICE_CLOSE, WLShift);
   
   double dWLDaily  = 0.0;
   double dWLHourly = 0.0;
    
   if(Symbol() == "GBPUSD")
   {
     dWLDaily    = (Avg1_D1 + Avg2_D1 + Avg3_D1 + Avg4_D1)/4;
     dWLHourly   = (Avg1_H1 + Avg2_H1 + Avg3_H1 + Avg4_H1)/4;
   }
   else
   {
     dWLDaily    = (Avg1_D1 + Avg2_D1 + Avg3_D1)/3;
     dWLHourly   = (Avg1_H1 + Avg2_H1 + Avg3_H1)/3;
   }
   
   double dWLAverage = (dWLDaily + dWLHourly)/2;
   
   if(ShowSwapInfo)
   {      
      double dSpreadValue = MarketInfo(Symbol(), MODE_SPREAD);
      double dPipValue = MarketInfo(Symbol(), MODE_TICKVALUE);
      double dTickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
      double dSwapLong  = MarketInfo(Symbol(), MODE_SWAPLONG) * dTickValue;
      double dSwapShort = MarketInfo(Symbol(), MODE_SWAPSHORT)* dTickValue;
      string SwapInfo   = StringConcatenate("1 Pip= ", dPipValue, "$ Spread:", dSpreadValue, "  SWAP buy:", dSwapLong,"$|sell:", dSwapShort, "$");  
   
      if(dSwapLong > dSwapShort)
      {
         ShowLabelObject("SwapInfo", SwapInfo, Lime,1,5,12);
      }
      else if(dSwapLong < dSwapShort)
      {
         ShowLabelObject("SwapInfo", SwapInfo, Red,1,5,12);
      }
   }
   else
   {
      ObjectDelete("SwapInfo");
   }
   
   if(ShowMarketPrice)
   {
      ShowHLineObject("MarketPrice", ColorMarketPrice, Close[0]);            
   }
   else  
   {
     DeleteHLineObject("MarketPrice");
   }
   
   if(ShowDailyWL)
   {
      ShowHLineObject("DailyWL", ColorDailyWL, dWLDaily);            
   }
   else  
   {
     DeleteHLineObject("DailyWL");
   }
   
   if(ShowHourlyWL)
   {
      ShowHLineObject("HourlyWL", ColorHourlyWL, dWLHourly);      
   }
   else  
   {
     DeleteHLineObject("HourlyWL");
   }
   
   if(ShowAverageWL)
   {
      ShowHLineObject("AverageWL", ColorAverageWL, dWLAverage);
   }
   else  
   {
      DeleteHLineObject("AverageWL");
   }  
   
   int    nOrders       = 0;
   double dOpenPrice    = 0.0;
   double dProfit       = 0.0;
   
   for (int i = 0; i <= OrdersTotal(); i++) 
   { 
      if(OrderSelect(i,SELECT_BY_POS))
      { 
         if(OrderSymbol() == Symbol())
         {
            if(OrderType() == OP_BUY || OrderType() == OP_SELL)
            { 
               dOpenPrice += OrderOpenPrice();
               dProfit+= OrderProfit() + OrderSwap();
               nOrders++;
            }
         } 
      }
   }   
   
   if(nOrders > 0)
   {
      double dAvgEntryPrice = dOpenPrice/nOrders;
      
      if(ShowAvgEntryPrice)
      {
         ShowHLineObject("AvgEntryPrice", ColorAvgEntryPrice, dAvgEntryPrice);            
      }
      else  
      {
         DeleteHLineObject("AvgEntryPrice");
      }
      
      if(ObjectFind("PipRectangle")!= 0)
      {
         ObjectCreate("PipRectangle", OBJ_RECTANGLE, 0, Time[0], dAvgEntryPrice, Time[0], Close[0]);      
      }
      
      datetime dtInfoText     = Time[0] + Period() * 1000;
      double   dPriceInfoText = ((Close[0] + dAvgEntryPrice)/2) + 2 * Point;
      
      if(ObjectFind("InfoString")!= 0)
      {         
         ObjectCreate("InfoString", OBJ_TEXT, 0,dtInfoText, dPriceInfoText);         
      }
      
      ObjectSetText("InfoString", DoubleToStr(dProfit,2), 8, "Verdana", Gold);
      ObjectSet("InfoString", OBJPROP_PRICE1, dPriceInfoText);
      ObjectSet("InfoString", OBJPROP_TIME1, dtInfoText);      
      
      ObjectSet("PipRectangle", OBJPROP_TIME1,  Time[0]);         
      ObjectSet("PipRectangle", OBJPROP_PRICE1, dAvgEntryPrice);  
      ObjectSet("PipRectangle", OBJPROP_TIME2,  Time[0] + Period() * 2000);         
      ObjectSet("PipRectangle", OBJPROP_PRICE2, Close[0]);  
      
      if(dProfit < 0 )
      {
         ObjectSet("PipRectangle", OBJPROP_COLOR, Maroon);           
      }
      else
      {
         ObjectSet("PipRectangle", OBJPROP_COLOR, DarkGreen);  
      }
   }
   else
   {     
      ObjectDelete("PipRectangle");
      ObjectDelete("InfoString");  
   }  
}


//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void ShowLabelObject(string name, string text, color clr, int corner, int xDist, int yDist)
{
   if(ObjectFind(name)!= 0)
   {
      CreateLabelObject(name,text, clr, corner, xDist, yDist);     
   }       
   
   ObjectSetText(name, text, 10, "Verdana", clr);   
}

//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void CreateLabelObject(string name, string text, color clr, int corner, int xDist, int yDist)
{
   ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name, text, 10, "Verdana", clr);
   ObjectSet(name, OBJPROP_CORNER, corner);
   ObjectSet(name, OBJPROP_XDISTANCE, xDist);
   ObjectSet(name, OBJPROP_YDISTANCE, yDist);
}
//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void DeleteHLineObject(string name)
{
   ObjectDelete(name);
   ObjectDelete(name + "_Label");
}
//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void ShowHLineObject(string name, color clr, double dValue)
{
   if(ObjectFind(name)!= 0)
   {
      CreateHLineObject(name,clr, dValue);         
   }    
   
   if(ShowLineLabels)
   {
      ObjectSet(name + "_Label",OBJPROP_PRICE1,dValue);  
      ObjectSet(name + "_Label",OBJPROP_TIME1,Time[0] + Period() * 3000);  
   }
   
   ObjectSet(name, OBJPROP_PRICE1, dValue);
}
//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void CreateHLineObject(string name, color clr, double dValue)
{
   if(ShowLineLabels)
   {
      ObjectCreate   (name + "_Label", OBJ_TEXT, 0,Time[0] + Period() * 3000, dValue); 
      ObjectSetText  (name + "_Label",  name, 7, "Verdana", clr);
   }
   
   ObjectCreate   (name,            OBJ_HLINE, 0, Time[0], dValue);
   ObjectSet      (name,            OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet      (name,            OBJPROP_COLOR, clr);  
   ObjectSet      (name,            OBJPROP_WIDTH, 2);
   
}
//+------------------------------------------------------------------+
//|  Custom indicator initialization function                        |
//+------------------------------------------------------------------+
void DeleteObjects()
{   
   ObjectDelete("PipRectangle");
   ObjectDelete("InfoString");
   
   ObjectDelete("AvgEntryPrice");    
   ObjectDelete("AvgEntryPrice_Label"); 
   ObjectDelete("MarketPrice");
   ObjectDelete("MarketPrice_Label");   
   ObjectDelete("AverageWL");
   ObjectDelete("AverageWL_Label");
   ObjectDelete("HourlyWL");
   ObjectDelete("HourlyWL_Label");
   ObjectDelete("DailyWL");   
   ObjectDelete("DailyWL_Label");
   ObjectDelete("SwapInfo");
}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders


Other Features: