KantorInformationDD
Download scriptThe provided script is a comprehensive dashboard and visual aid tool designed to display critical trading information directly on a price chart. It simplifies the analysis of market trends, current positions, and cost factors by overlaying dynamic lines and text labels onto the screen.
Market Trend Analysis (Moving Averages)
The core logic revolves around calculating "Weighted Levels" based on Moving Averages across two different timeframes: Hourly (H1) and Daily (D1).
- Dynamic Calculation: The script calculates several moving averages for both the hourly and daily periods.
- Pair-Specific Logic: It features specific logic for the GBPUSD currency pair, adjusting the number of averages used in its calculation to ensure accuracy for that specific market.
- Visual Overlays: These calculations result in three distinct horizontal lines that you can toggle on your chart:
- Daily Weighted Level: Represents the broader, long-term trend.
- Hourly Weighted Level: Represents the shorter-term, immediate trend.
- Average Weighted Level: A blended view of both daily and hourly trends to provide a balanced perspective on market direction.
Trade Position Management
For active traders, the script automatically monitors open positions to provide an instant "snapshot" of current performance:
- Break-Even Tracking: It calculates your average entry price across all open trades for the current symbol. If you have multiple positions open, it draws a line showing exactly where your "break-even" point is.
- Profit/Loss Visualization: The script creates a dynamic rectangle on the chart that visualizes the distance between your average entry price and the current market price.
- If the trade is in profit, the rectangle changes color to green.
- If the trade is in a loss, it turns maroon.
- Real-Time P&L: It displays your current profit (including swap charges) in a prominent gold text label on the chart, allowing you to see your gains or losses at a glance without navigating through separate menus.
Market Data & Cost Information
The script also provides utility data that helps in making informed execution decisions:
- Swap Analysis: It calculates the "Swap" costs (overnight interest) for both buying and selling. If there is a discrepancy between the buy and sell swap rates, it highlights this information with specific colors to warn the trader of potential holding costs.
- Price Monitoring: It can display the current market price as a clear horizontal line, making it easier to track price action relative to your trading levels.
User Customization
The logic is built to be highly adaptable. Users can choose to show or hide any of the aforementioned features (Market Price, Average Entry, Daily/Hourly Levels, Swap Info) and customize the colors of these elements to suit their personal visual preferences.
//+------------------------------------------------------------------+
//| 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");
}
Comments