//+------------------------------------------------------------------+ //| Heiken Ashi.mq4 | //| Copyright 2006-2014, MetaQuotes Software Corp. | //| http://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "2006-2014, MetaQuotes Software Corp." #property link "http://www.mql4.com" #property description "We recommend next chart settings (press F8 or select menu 'Charts'->'Properties...'):" #property description " - on 'Color' Tab select 'Black' for 'Line Graph'" #property description " - on 'Common' Tab disable 'Chart on Foreground' checkbox and select 'Line Chart' radiobutton" #property strict #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 White #property indicator_color3 Red #property indicator_color4 White #property indicator_color5 Red #property indicator_color6 Yellow #property indicator_color7 Green #property indicator_color8 Green #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 3 #property indicator_width4 3 #property indicator_width5 2 #property indicator_width6 2 #property indicator_width7 2 #property indicator_width8 2 //--- input int Pips1=30; input int Pips2=60; input int Pips3=90; input int Pips4=120; input color PipsColor1 = Green; input color PipsColor2 = Yellow; input color PipsColor3 = Orange; input color PipsColor4 = Red; input int arrowcode=108; input int arrowsize=1; input color ExtColor1 = Red; // Shadow of bear candlestick input color ExtColor2 = White; // Shadow of bull candlestick input color ExtColor3 = Red; // Bear candlestick body input color ExtColor4 = White; // Bull candlestick body extern bool showMagnifiedPrice = true; extern int up_downShift = 0; extern int sideAdjustment = 0; extern color commentColor = White; extern color spreadColor = Gold; extern color colorPriceUp = Lime; extern color colorPriceDown = Red; extern bool showOnRightTop = true; extern bool showMoreInfo = true; extern bool showPipProfit = true; color tradeValueColor=Gold; double oldPrice=0; int ordersTotal = 0; int multiplier = 10; extern bool AlertOn=true; //desktop Alert extern bool NotificationOn=true; //Mobile Alert bool EmailOn=false; //Email Alert //--- buffers double ExtLowHighBuffer[]; double ExtHighLowBuffer[]; double ExtOpenBuffer[]; double ExtCloseBuffer[]; double Ext4[],Ext3[],Ext2[],Ext1[]; double avgpips=0; double barpips=0;datetime LastAlertTime; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //|------------------------------------------------------------------| void OnInit(void) { IndicatorShortName("Heiken Ashi"); IndicatorDigits(Digits); //--- indicator lines SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1); SetIndexBuffer(0,ExtLowHighBuffer); SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2); SetIndexBuffer(1,ExtHighLowBuffer); SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3); SetIndexBuffer(2,ExtOpenBuffer); SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4); SetIndexBuffer(3,ExtCloseBuffer); SetIndexStyle(4,DRAW_ARROW,0,arrowsize,PipsColor4); SetIndexArrow(4,arrowcode); SetIndexStyle(5,DRAW_ARROW,0,arrowsize,PipsColor3); SetIndexArrow(5,arrowcode); SetIndexStyle(6,DRAW_ARROW,0,arrowsize,PipsColor2); SetIndexArrow(6,arrowcode); SetIndexStyle(7,DRAW_ARROW,0,arrowsize,PipsColor1); SetIndexArrow(7,arrowcode); //--- SetIndexLabel(0,"Low/High"); SetIndexLabel(1,"High/Low"); SetIndexLabel(2,"Open"); SetIndexLabel(3,"Close"); SetIndexDrawBegin(0,10); SetIndexDrawBegin(1,10); SetIndexDrawBegin(2,10); SetIndexDrawBegin(3,10); //--- indicator buffers mapping SetIndexBuffer(0,ExtLowHighBuffer); SetIndexBuffer(1,ExtHighLowBuffer); SetIndexBuffer(2,ExtOpenBuffer); SetIndexBuffer(3,ExtCloseBuffer); SetIndexBuffer(4,Ext4); SetIndexBuffer(5,Ext3); SetIndexBuffer(6,Ext2); SetIndexBuffer(7,Ext1); //Adapt to x digit Brokers if(Digits == 2 || Digits == 4) multiplier = 1; if(Digits == 3 || Digits == 5) multiplier = 10; if(Digits == 6) multiplier = 100; if(Digits == 7) multiplier = 1000; // Special case for gold silver. if((StringFind(Symbol(),"XAUUSD",0)!=-1)&&(Digits==3))multiplier = 100; if((StringFind(Symbol(),"XAUUSD",0)!=-1)&&(Digits==2))multiplier = 10; if((StringFind(Symbol(),"XAUUSD",0)!=-1)&&(Digits==1))multiplier = 1; if((StringFind(Symbol(),"XAGUSD",0)!=-1)&&(Digits==4))multiplier = 100; if((StringFind(Symbol(),"XAGUSD",0)!=-1)&&(Digits==3))multiplier = 10; if((StringFind(Symbol(),"XAGUSD",0)!=-1)&&(Digits==2))multiplier = 1; //--- initialization done } void OnDeinit(const int reason) { ObjectsDeleteAll(0, OBJ_LABEL); } //+------------------------------------------------------------------+ //| Heiken Ashi | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int i,pos; double haOpen,haHigh,haLow,haClose; //--- if(rates_total<=10) return(0); //--- counting from 0 to rates_total ArraySetAsSeries(ExtLowHighBuffer,false); ArraySetAsSeries(ExtHighLowBuffer,false); ArraySetAsSeries(ExtOpenBuffer,false); ArraySetAsSeries(ExtCloseBuffer,false); ArraySetAsSeries(open,false); ArraySetAsSeries(high,false); ArraySetAsSeries(low,false); ArraySetAsSeries(close,false); ArraySetAsSeries(Ext4,false); ArraySetAsSeries(Ext3,false); ArraySetAsSeries(Ext2,false); ArraySetAsSeries(Ext1,false); double top=WindowPriceMax(); double bottom=WindowPriceMin(); double addpoint=(top-bottom)*0.03; //--- preliminary calculation if(prev_calculated>1) pos=prev_calculated-1; else { //--- set first candle if(open[0]=(100+Pips4)*avgpips*Point*0.1) { Ext4[i]=haHigh+addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Red"); LastAlertTime=Time[0]; } } else if(haHigh-haClose>=(100+Pips3)*avgpips*Point*0.1) { Ext3[i]=haHigh+addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Orange"); LastAlertTime=Time[0]; } } else if(haHigh-haClose>=(100+Pips2)*avgpips*Point*0.1) { Ext2[i]=haHigh+addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Yellow"); LastAlertTime=Time[0]; } } else if(haHigh-haClose>=(100+Pips1)*avgpips*Point*0.1) { Ext1[i]=haHigh+addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Green"); LastAlertTime=Time[0]; } } } else { ExtLowHighBuffer[i]=haHigh; ExtHighLowBuffer[i]=haLow; if(haClose-haLow>=(100+Pips4)*avgpips*Point*0.1) { Ext4[i]=haLow-addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Red "); LastAlertTime=Time[0]; } } else if(haClose-haLow>=(100+Pips3)*avgpips*Point*0.1) { Ext3[i]=haLow-addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Orange "); LastAlertTime=Time[0]; } } else if(haClose-haLow>=(100+Pips2)*avgpips*Point*0.1) { Ext2[i]=haLow-addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Yellow "); LastAlertTime=Time[0]; } } else if(haClose-haLow>=(100+Pips1)*avgpips*Point*0.1) { Ext1[i]=haLow-addpoint; if(i==rates_total-1 && LastAlertTime!=Time[0]) { PlaySoundo("Wickthor Green "); LastAlertTime=Time[0]; } } } } color priceColor; double tradeValue = 0; i = 0; int j = 0; int total = 0; if (Bid > oldPrice) priceColor = colorPriceUp; else if (Bid < oldPrice) priceColor = colorPriceDown; else priceColor=Gold; oldPrice=Bid; string actualPrice = DoubleToStr(Bid, Digits); double spreadActual = (Ask - Bid) / Point/multiplier; double dayHigh = iHigh(NULL, PERIOD_D1, 0); double dayLow = iLow(NULL, PERIOD_D1, 0); string spreadValue = DoubleToStr(spreadActual, 1); string dayHighValue = DoubleToStr(dayHigh, Digits); string dayLowValue = DoubleToStr(dayLow, Digits); int candeleRestTime = Time[0] + 60 * Period() - TimeCurrent(); int candleRestTimeM = candeleRestTime % 60; candeleRestTime = (candeleRestTime - candeleRestTime % 60) / 60; string longSwap = DoubleToStr( MarketInfo(Symbol(),MODE_SWAPLONG), 2 ); string shortSwap = DoubleToStr( MarketInfo(Symbol(),MODE_SWAPSHORT), 2 ); double ma240 = iMA( NULL, PERIOD_H4, 240, 0, MODE_LWMA, PRICE_OPEN, 0 ); double distance = ( Bid - ma240 )/ Point/multiplier; string ma240Distance=DoubleToStr(distance,1); bool orderSelect; if (ordersTotal != OrdersTotal()) ObjectsDeleteAll(0, OBJ_LABEL); if (showMagnifiedPrice == true) { ObjectCreate("actualPrice", OBJ_LABEL, 0, 0, 0); ObjectSetText("actualPrice", "" + actualPrice + "", 30, "Tahoma", priceColor); ObjectSet("actualPrice", OBJPROP_CORNER, showOnRightTop); ObjectSet("actualPrice", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("actualPrice", OBJPROP_YDISTANCE, up_downShift + 25); } if (showMoreInfo == true) { if (showMagnifiedPrice == true) { ObjectCreate("spreadLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("spreadLabel", "Spread", 10, "Arial", commentColor); ObjectSet("spreadLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("spreadLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("spreadLabel", OBJPROP_YDISTANCE, up_downShift + 67); ObjectCreate("spreadValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("spreadValue", "" + spreadValue + "", 10, "Arial Bold", spreadColor); ObjectSet("spreadValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("spreadValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("spreadValue", OBJPROP_YDISTANCE, up_downShift + 67); ObjectCreate("dayHighLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayHighLabel", "DayHigh", 10, "Arial", commentColor); ObjectSet("dayHighLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayHighLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("dayHighLabel", OBJPROP_YDISTANCE, up_downShift + 82); ObjectCreate("dayHighValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayHighValue", "" + dayHighValue + "", 10, "Arial Bold", colorPriceUp); ObjectSet("dayHighValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayHighValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("dayHighValue", OBJPROP_YDISTANCE, up_downShift + 82); ObjectCreate("dayLowLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayLowLabel", "DayLow", 10, "Arial", commentColor); ObjectSet("dayLowLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayLowLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("dayLowLabel", OBJPROP_YDISTANCE, up_downShift + 97); ObjectCreate("dayLowValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayLowValue", "" + dayLowValue + "", 10, "Arial Bold", colorPriceDown); ObjectSet("dayLowValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayLowValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("dayLowValue", OBJPROP_YDISTANCE, up_downShift + 97); ObjectCreate("candleTimeLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("candleTimeLabel", "Candle will close in", 10, "Arial", commentColor); ObjectSet("candleTimeLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("candleTimeLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("candleTimeLabel", OBJPROP_YDISTANCE, up_downShift + 112); ObjectCreate("candleRestTimeValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("candleRestTimeValue", "" + candeleRestTime + ":" + candleRestTimeM + "", 10, "Arial Bold", spreadColor); ObjectSet("candleRestTimeValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("candleRestTimeValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("candleRestTimeValue", OBJPROP_YDISTANCE, up_downShift + 112); int shift=15; ObjectCreate("CurrentWickthorLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("CurrentWickthorLabel", "Current Wickthor", 10, "Arial", commentColor); ObjectSet("CurrentWickthorLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("CurrentWickthorLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("CurrentWickthorLabel", OBJPROP_YDISTANCE, up_downShift + 112+shift); ObjectCreate("CurrentWickthorValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("CurrentWickthorValue",DoubleToStr(currentPips,2) , 10, "Arial Bold", spreadColor); ObjectSet("CurrentWickthorValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("CurrentWickthorValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("CurrentWickthorValue", OBJPROP_YDISTANCE, up_downShift + 112+shift); shift=30; ObjectCreate("AvgWickthorLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("AvgWickthorLabel", "Avg Wickthor", 10, "Arial", commentColor); ObjectSet("AvgWickthorLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("AvgWickthorLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("AvgWickthorLabel", OBJPROP_YDISTANCE, up_downShift + 112+shift); ObjectCreate("AvgWickthorValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("AvgWickthorValue", DoubleToStr(avgpips,1), 10, "Arial Bold", spreadColor); ObjectSet("AvgWickthorValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("AvgWickthorValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("AvgWickthorValue", OBJPROP_YDISTANCE, up_downShift + 112+shift); ObjectCreate("swapLongLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapLongLabel", "Swap Long", 10, "Arial", commentColor); ObjectSet("swapLongLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapLongLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("swapLongLabel", OBJPROP_YDISTANCE, up_downShift + 127+shift); ObjectCreate("swapLongValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapLongValue", "" + longSwap + "", 10, "Arial Bold", spreadColor); ObjectSet("swapLongValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapLongValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("swapLongValue", OBJPROP_YDISTANCE, up_downShift + 127+shift); ObjectCreate("swapShortLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapShortLabel", "Swap Short", 10, "Arial", commentColor); ObjectSet("swapShortLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapShortLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("swapShortLabel", OBJPROP_YDISTANCE, up_downShift + 142+shift); ObjectCreate("swapShortValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapShortValue", "" + shortSwap + "", 10, "Arial Bold", spreadColor); ObjectSet("swapShortValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapShortValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("swapShortValue", OBJPROP_YDISTANCE, up_downShift + 142+shift); ObjectCreate("maDisstanceLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("maDisstanceLabel", "Distance from MA240", 10, "Arial", commentColor); ObjectSet("maDisstanceLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("maDisstanceLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("maDisstanceLabel", OBJPROP_YDISTANCE, up_downShift + 157+shift); ObjectCreate("maDisstanceValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("maDisstanceValue", "" + ma240Distance + "", 10, "Arial Bold", spreadColor); ObjectSet("maDisstanceValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("maDisstanceValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("maDisstanceValue", OBJPROP_YDISTANCE, up_downShift + 157+shift); if (showPipProfit == true) { total = OrdersTotal(); ordersTotal = total; j = 0; for (i = 0; i < total; i++) { orderSelect=OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (Symbol() == OrderSymbol()) { if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) continue; j++; if (OrderType() == OP_BUY) { tradeValue = (Bid - OrderOpenPrice()) / Point / multiplier; if (tradeValue>0) tradeValueColor=Lime; else tradeValueColor=Red; ObjectCreate("openTradeLabel" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("openTradeLabel" + i, "OpenTrades: " + j + " Pips: ", 10, "Arial", commentColor); ObjectSet("openTradeLabel" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("openTradeLabel" + i, OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("openTradeLabel" + i, OBJPROP_YDISTANCE, 15 * j + 157 +shift+ up_downShift); ObjectCreate("pipProfitValue" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("pipProfitValue" + i, DoubleToStr(tradeValue, 1), 10, "Arial Bold", tradeValueColor); ObjectSet("pipProfitValue" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("pipProfitValue" + i, OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("pipProfitValue" + i, OBJPROP_YDISTANCE, 15 * j + 157+shift + up_downShift); continue; } if (OrderType() == OP_SELL) { tradeValue = (OrderOpenPrice()- Ask) / Point / multiplier; if (tradeValue>0) tradeValueColor=Lime; else tradeValueColor=Red; ObjectCreate("openTradeLabel" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("openTradeLabel" + i, "OpenTrades: " + j + " Pips: ", 10, "Arial", commentColor); ObjectSet("openTradeLabel" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("openTradeLabel" + i, OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("openTradeLabel" + i, OBJPROP_YDISTANCE, 15 * j + 157 +shift+ up_downShift); ObjectCreate("pipProfitValue" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("pipProfitValue" + i, DoubleToStr(tradeValue, 1), 10, "Arial Bold", tradeValueColor); ObjectSet("pipProfitValue" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("pipProfitValue" + i, OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("pipProfitValue" + i, OBJPROP_YDISTANCE, 15 * j + 157 +shift+ up_downShift); } } } } } } if (showMoreInfo == true) { if (showMagnifiedPrice == false) { ObjectCreate("spreadLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("spreadLabel", "Spread", 10, "Arial", commentColor); ObjectSet("spreadLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("spreadLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("spreadLabel", OBJPROP_YDISTANCE, up_downShift + 25); ObjectCreate("spreadValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("spreadValue", "" + spreadValue + "", 10, "Arial Bold", spreadColor); ObjectSet("spreadValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("spreadValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("spreadValue", OBJPROP_YDISTANCE, up_downShift + 25); ObjectCreate("dayHighLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayHighLabel", "DayHigh", 10, "Arial", commentColor); ObjectSet("dayHighLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayHighLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("dayHighLabel", OBJPROP_YDISTANCE, up_downShift + 40); ObjectCreate("dayHighValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayHighValue", "" + dayHighValue + "", 10, "Arial Bold", colorPriceUp); ObjectSet("dayHighValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayHighValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("dayHighValue", OBJPROP_YDISTANCE, up_downShift + 40); ObjectCreate("dayLowLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayLowLabel", "DayLow", 10, "Arial", commentColor); ObjectSet("dayLowLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayLowLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("dayLowLabel", OBJPROP_YDISTANCE, up_downShift + 55); ObjectCreate("dayLowValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("dayLowValue", "" + dayLowValue + "", 10, "Arial Bold", colorPriceDown); ObjectSet("dayLowValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("dayLowValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("dayLowValue", OBJPROP_YDISTANCE, up_downShift + 55); ObjectCreate("candleTimeLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("candleTimeLabel", "Candle will close in", 10, "Arial", commentColor); ObjectSet("candleTimeLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("candleTimeLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("candleTimeLabel", OBJPROP_YDISTANCE, up_downShift + 70); ObjectCreate("candleRestTimeValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("candleRestTimeValue", "" + candeleRestTime + ":" + candleRestTimeM + "", 10, "Arial Bold", spreadColor); ObjectSet("candleRestTimeValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("candleRestTimeValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("candleRestTimeValue", OBJPROP_YDISTANCE, up_downShift + 70); // drawtxt("avg","avg. wickthor is "+DoubleToStr(avgpips,1),10,20); // drawtxt("current","current wickthor is "+DoubleToStr(currentPips,2),10,40); int shift=15; ObjectCreate("CurrentWickthorLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("CurrentWickthorLabel", "Current Wickthor", 10, "Arial", commentColor); ObjectSet("CurrentWickthorLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("CurrentWickthorLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("CurrentWickthorLabel", OBJPROP_YDISTANCE, up_downShift + 70+shift); ObjectCreate("CurrentWickthorValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("CurrentWickthorValue",DoubleToStr(currentPips,2) , 10, "Arial Bold", spreadColor); ObjectSet("CurrentWickthorValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("CurrentWickthorValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("CurrentWickthorValue", OBJPROP_YDISTANCE, up_downShift + 70+shift); shift=30; ObjectCreate("AvgWickthorLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("AvgWickthorLabel", "Avg Wickthor", 10, "Arial", commentColor); ObjectSet("AvgWickthorLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("AvgWickthorLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("AvgWickthorLabel", OBJPROP_YDISTANCE, up_downShift + 70+shift); ObjectCreate("AvgWickthorValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("AvgWickthorValue", DoubleToStr(avgpips,1), 10, "Arial Bold", spreadColor); ObjectSet("AvgWickthorValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("AvgWickthorValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("AvgWickthorValue", OBJPROP_YDISTANCE, up_downShift + 70+shift); ObjectCreate("swapLongLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapLongLabel", "Swap Long", 10, "Arial", commentColor); ObjectSet("swapLongLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapLongLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("swapLongLabel", OBJPROP_YDISTANCE, up_downShift + 85+shift); ObjectCreate("swapLongValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapLongValue", "" + longSwap + "", 10, "Arial Bold", spreadColor); ObjectSet("swapLongValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapLongValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("swapLongValue", OBJPROP_YDISTANCE, up_downShift + 85+shift); ObjectCreate("swapShortLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapShortLabel", "Swap Short", 10, "Arial", commentColor); ObjectSet("swapShortLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapShortLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("swapShortLabel", OBJPROP_YDISTANCE, up_downShift + 100+shift); ObjectCreate("swapShortValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("swapShortValue", "" + shortSwap + "", 10, "Arial Bold", spreadColor); ObjectSet("swapShortValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("swapShortValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("swapShortValue", OBJPROP_YDISTANCE, up_downShift + 100+shift); ObjectCreate("maDisstanceLabel", OBJ_LABEL, 0, 0, 0); ObjectSetText("maDisstanceLabel", "Distance from MA240", 10, "Arial", commentColor); ObjectSet("maDisstanceLabel", OBJPROP_CORNER, showOnRightTop); ObjectSet("maDisstanceLabel", OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("maDisstanceLabel", OBJPROP_YDISTANCE, up_downShift + 115+shift); ObjectCreate("maDisstanceValue", OBJ_LABEL, 0, 0, 0); ObjectSetText("maDisstanceValue", "" + ma240Distance + "", 10, "Arial Bold", spreadColor); ObjectSet("maDisstanceValue", OBJPROP_CORNER, showOnRightTop); ObjectSet("maDisstanceValue", OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("maDisstanceValue", OBJPROP_YDISTANCE, up_downShift + 115+shift); if (showPipProfit == true) { total = OrdersTotal(); ordersTotal = total; j = 0; for (i = 0; i < total; i++) { orderSelect=OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (Symbol() == OrderSymbol()) { if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) continue; j++; if (OrderType() == OP_BUY) { tradeValue = (Bid - OrderOpenPrice()) / Point / multiplier; if (tradeValue>0) tradeValueColor=Lime; else tradeValueColor=Red; ObjectCreate("openTradeLabel" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("openTradeLabel" + i, "OpenTrades: " + j + " Pips: ", 10, "Arial", commentColor); ObjectSet("openTradeLabel" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("openTradeLabel" + i, OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("openTradeLabel" + i, OBJPROP_YDISTANCE, 15 * j + 115+shift + up_downShift); ObjectCreate("pipProfitValue" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("pipProfitValue" + i, DoubleToStr(tradeValue, 1), 10, "Arial Bold", tradeValueColor); ObjectSet("pipProfitValue" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("pipProfitValue" + i, OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("pipProfitValue" + i, OBJPROP_YDISTANCE, 15 * j + 115+shift + up_downShift); continue; } if (OrderType() == OP_SELL) { tradeValue = (OrderOpenPrice()- Ask) / Point / multiplier; if (tradeValue>0) tradeValueColor=Lime; else tradeValueColor=Red; ObjectCreate("openTradeLabel" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("openTradeLabel" + i, "OpenTrades: " + j + " Pips: ", 10, "Arial", commentColor); ObjectSet("openTradeLabel" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("openTradeLabel" + i, OBJPROP_XDISTANCE, sideAdjustment + 58); ObjectSet("openTradeLabel" + i, OBJPROP_YDISTANCE, 15 * j + 115+shift + up_downShift); ObjectCreate("pipProfitValue" + i, OBJ_LABEL, 0, 0, 0); ObjectSetText("pipProfitValue" + i, DoubleToStr(tradeValue, 1), 10, "Arial Bold", tradeValueColor); ObjectSet("pipProfitValue" + i, OBJPROP_CORNER, showOnRightTop); ObjectSet("pipProfitValue" + i, OBJPROP_XDISTANCE, sideAdjustment + 10); ObjectSet("pipProfitValue" + i, OBJPROP_YDISTANCE, 15 * j + 115+shift + up_downShift); } } } } } } //--- done return(rates_total); } void drawtxt(string namee,string txt,int xx,int Yy) { string L_ss_5=namee+"txt"; if(ObjectFind(L_ss_5) == -1) { ObjectCreate(0, L_ss_5, OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0); ObjectSet(L_ss_5, OBJPROP_CORNER,CORNER_LEFT_LOWER ); ObjectSet(L_ss_5, OBJPROP_XDISTANCE, xx); ObjectSet(L_ss_5, OBJPROP_YDISTANCE, Yy); } ObjectSetText(L_ss_5, txt, 18, "Arial", clrWhite); } void PlaySoundo(string comm) { string comms; comms=Symbol()+"_"+PeriodToString(Period())+"_"+comm; if(AlertOn) Alert(comms); if(NotificationOn) { Sleep(3000); SendNotification(comms); } if(EmailOn) SendMail(comms,comms); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string PeriodToString(int Value) { switch(Value) { case 1: // M1 return("M1"); case 5: // M1 return("M5"); case 15: return("M15"); case 30: return("M30"); case 60: return("H1"); case 240: return("H4"); case 1440: return("D1"); case 10080: return("W1"); case 43200: return("MN1"); default: return((string)Value); } } //+------------------------------------------------------------------+