//+------------------------------------------------------------------+ //| smHiLO_CommonsInc_v2.mqh //+------------------------------------------------------------------+ #property copyright "Copyright 17.06.2016, SwingMan" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ /*------------------------------------------------------------------+ 17.06.2016 v2 - Functions for Automate Scalping Signals /+------------------------------------------------------------------*/ // ******************************************* // ******************************************* // DRAW Buttons // ******************************************* // ******************************************* //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Set_ChartProperties() { ChartSetInteger(chart_id,CHART_COLOR_BACKGROUND,clrBlack); //ChartSetInteger(chart_id,CHART_COLOR_FOREGROUND,clrBlack); ChartSetInteger(chart_id,CHART_COLOR_FOREGROUND,clrSilver); ChartSetInteger(chart_id,CHART_COLOR_CANDLE_BEAR,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_CANDLE_BULL,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_CHART_DOWN,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_CHART_UP,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_CHART_LINE,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_GRID,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_VOLUME,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_BID,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_ASK,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_LAST,clrNONE); ChartSetInteger(chart_id,CHART_COLOR_STOP_LEVEL,clrNONE); ChartSetInteger(chart_id,CHART_MODE,CHART_LINE); ChartSetInteger(chart_id,CHART_AUTOSCROLL,false); ChartSetInteger(chart_id,CHART_SHIFT,false); ChartSetInteger(chart_id,CHART_SHOW_GRID,false); ChartSetInteger(chart_id,CHART_SHOW_OHLC,false); ChartSetInteger(chart_id,CHART_SHOW_GRID,false); ChartSetInteger(chart_id,CHART_SHOW_BID_LINE,false); ChartSetInteger(chart_id,CHART_SHOW_ASK_LINE,false); ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false); ChartSetInteger(chart_id,CHART_SHOW_VOLUMES,false); ChartSetInteger(chart_id,CHART_SHOW_DATE_SCALE,false); ChartSetInteger(chart_id,CHART_SHOW_PRICE_SCALE,false); ChartSetInteger(chart_id,CHART_SHOW_TRADE_LEVELS,false); ChartSetInteger(chart_id,CHART_SHOW_ONE_CLICK,false); ChartSetString(chart_id,CHART_COMMENT,""); } ////+------------------------------------------------------------------+ ////| | ////+------------------------------------------------------------------+ //int Set_EAname() //{ ////-- EA name // if(!LabelCreate(0,objEA+"EAname",0,22,2,CORNER_RIGHT_UPPER,WindowExpertName(),"Consolas",8,clrOrange,0, // ANCHOR_RIGHT_UPPER,0,0,0,0)) // { // return(0); // } ////-- Auto Trading is 74=ON / 76=OFF // string sCode; // if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)) // sCode=CharToString(74); // else // sCode=CharToString(76); // if(!LabelCreate(0,objEA+"EAauto",0,2,0,CORNER_RIGHT_UPPER,sCode,"Wingdings",14,clrOrange,0, // ANCHOR_RIGHT_UPPER,0,0,0,0)) // { // return(0); // } // return(1); //} //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Draw_PairNameButtons(int xx,int &lastY,int x_size,int y_size) { int yy; //--- input parameters for buttons string InpName="Button"; // Button name ENUM_BASE_CORNER InpCorner=CORNER_LEFT_UPPER; // Chart corner for anchoring string InpFont="Consolas"; // Font Arial int InpFontSize=10; // Font size color InpColor=clrBlack; // Text color color InpBackColor=clrSilver; // Background color C'236,233,216' color InpBorderColor=clrNONE; // Border color bool InpState=false; // Pressed/Released bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenButtons; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; //-- draw buttons yy=y0-yStep; for(int ip=0;ip=0) InpBackColor=clrGray; InpName=objEA+"PairButton_"+pairName; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; yy=yy+yStep; sText=pairName; //--- create the button if(!ButtonCreate(0,InpName,0,xx,yy,x_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } lastY=yy; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Draw_BuySellButtons(int xx,int x_size,int y_size) { int yy; //--- input parameters for buttons string InpName="Button"; // Button name ENUM_BASE_CORNER InpCorner=CORNER_LEFT_UPPER; // Chart corner for anchoring string InpFont="Consolas"; // Font Arial int InpFontSize=11; // Font size color InpColor=clrBlack; // Text color color InpBackColor=clrSilver; // Background color C'236,233,216' color InpBorderColor=clrNONE; // Border color bool InpState=false; // Pressed/Released bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenButtons; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; //-- 1. draw BUY buttons ----------------------------------------------- yy=y0-yStep; sText="BUY"; for(int ip=0;ip=0) InpBackColor=clrGray; //string pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"OrderButton_BUY_"+pairName; yy=yy+yStep; //--- create the button if(!ButtonCreate(0,InpName,0,xx,yy,x_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } //-- 2. draw SELL buttons ---------------------------------------------- xx=xx+x_size+xStep; xPosition=xx; yy=y0-yStep; sText="SELL"; for(int ip=0;ip=0) InpBackColor=clrGray; //string pairName=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"OrderButton_SELL_"+pairName; yy=yy+yStep; //--- create the button if(!ButtonCreate(0,InpName,0,xx,yy,x_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } //-- 3. draw CLOSE buttons --------------------------------------------- xx=xx+x_size+xStep; xPosition=xx; yy=y0-yStep; sText="CLOSE"; for(int ip=0;ip=0) InpBackColor=clrGray; //string pairName=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"OrderButton_CLOSE_"+pairName; yy=yy+yStep; //--- create the button if(!ButtonCreate(0,InpName,0,xx,yy,x_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } //-- 4. draw CLOSE ALL buttons ----------------------------------------- xx=x0+xStep; //yy=yy+(int)1.5*yStep; yy=yy+2*yStep; int xb_size=x_size+x_size; InpColor=clrWhite; // Text color InpBackColor=clrCrimson; // Background color //--- create the button CLOSE ALL sText="CLOSE ALL "; InpName=objEA+"OrderButton_CLOSX_ALL"; if(!ButtonCreate(0,InpName,0,xx,yy,xb_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //--- create the button CLOSE ALL WINS InpBackColor=clrTomato; // Background color xx=xx+xb_size+5; sText="CLOSE ALL +"; InpName=objEA+"OrderButton_CLOSX_ALLwins"; if(!ButtonCreate(0,InpName,0,xx,yy,xb_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //--- create the button CLOSE ALL LOSS xx=xx+xb_size+5; sText="CLOSE ALL -"; InpName=objEA+"OrderButton_CLOSX_ALLloss"; if(!ButtonCreate(0,InpName,0,xx,yy,xb_size,y_size,InpCorner,sText,InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- 5. write manually, automatically ------------------------------- int InpX=x0+xStep; int InpY=yy+yStep; InpColor=clrTurquoise; double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_LEFT_UPPER; // Anchor type //-- Countertrend trading if(Trading_Style==Trading_Manually) sText="COUNT:manual trading"; else if(Trading_Style==Trading_Automatically) sText="COUNT:automatic trading"; //-- Scalping trading if(SCALP_Trading_Allowed) { if(SCALP_Trading_Style==Trading_Manually) sText=sText+" SCALP:manual trading"; else if(SCALP_Trading_Style==Trading_Automatically) sText=sText+" SCALP:automatic trading"; } InpName=objEA+"TradingStyle"; if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } // ******************************************* // ******************************************* // ENTRY CONDITIONS // ******************************************* // ******************************************* //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Check_EntryConditions() { color clrButtonBUY =clrDodgerBlue; color clrButtonSELL =clrOrangeRed; color clrButtonNONE =clrSilver; color clrButtonCLOSE =clrBrown; color clrButtonCLOSEPend=clrDarkGoldenrod; color clrPairOK=clrLawnGreen; color InpColor,buttonColor; string InpName; string pairNameSufix; bool sendOrderBUY=false,sendOrderSELL=false; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; //-- check new bars, set newSignal=0 datetime thisTime=iTime(pairNameSufix,PERIOD_M15,0); if(thisTime!=currentBarTime[ip]) { currentBarTime[ip]=thisTime; newSignal[ip]=0; } //-- 1. conditions SPREAD, ADX bool conditionSpread=(arrSpread[ip]<=MaximumAllowed_Spread); bool conditionADX =(arrADX[ip] >=ADX_MinimumAllowed); bool conditionTradingAllowed=(conditionSpread && conditionADX); //-- 2. conditions TREND, Higher/Lower OPEN position bool conditionTrendUP=(arrTrend[ip]>0 && arrHigherOpenSignal[ip]==1); bool conditionTrendDN=(arrTrend[ip]<0 && arrLowerOpenSignal[ip ]==1); //-- 3. Currency Strength Difference values bool conditionStrengthUP=(arrCurrencyStrengthSignal[ip]== 1); bool conditionStrengthDN=(arrCurrencyStrengthSignal[ip]==-1); //-- 4. Permited pairs to trade / Spread,ADX --------------------- if(conditionTradingAllowed) { InpColor=clrPairOK; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"PairButton_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } else { InpColor=clrButtonNONE; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"PairButton_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } datetime dExpirationTime=iTime(pairNameSufix,PERIOD_M15,0)+ExpirationTime_Minutes*60; string sExpirationTime=" Expiration: "+TimeToString(dExpirationTime); //-- 5.1 UP trend, only SELL Orders ------------------------------- if(conditionTradingAllowed && conditionTrendUP && conditionStrengthDN) { sendOrderSELL=true; InpColor=clrButtonNONE; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"OrderButton_BUY_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); InpName=objEA+"OrderButton_SELL_"+pairName; buttonColor=(color)ObjectGetInteger(0,InpName,OBJPROP_BGCOLOR,0); if(buttonColor!=clrButtonSELL && Alerts_Trading_Signals && newSignal[ip]==0) { newSignal[ip]=1; Alert("SELL signal for: "+pairNameSufix+" "+TimeToString(TimeCurrent())+" (Server)"+sExpirationTime); //Alert("SELL signal for: "+pairNameSufix+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } InpColor=clrButtonSELL; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } else //-- 5.2 DN trend, only BUY Orders -------------------------------- if(conditionTradingAllowed && conditionTrendDN && conditionStrengthUP) { sendOrderBUY=true; InpColor=clrButtonNONE; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"OrderButton_SELL_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); InpName=objEA+"OrderButton_BUY_"+pairName; buttonColor=(color)ObjectGetInteger(0,InpName,OBJPROP_BGCOLOR,0); if(buttonColor!=clrButtonBUY && Alerts_Trading_Signals && newSignal[ip]==0) { newSignal[ip]=1; Alert("BUY signal for: "+pairNameSufix+" "+TimeToString(TimeCurrent())+" (Server)"+sExpirationTime); //Alert("BUY signal for: "+pairNameSufix+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } InpColor=clrButtonBUY; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } else //-- 5.3 NONE Orders ---------------------------------------------- { InpColor=clrButtonNONE; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"OrderButton_BUY_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); InpName=objEA+"OrderButton_SELL_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } //######################################## //-- 6. send Countertrend Orders --------------------------- //######################################## ////#### TEST //if(pairNameSufix=="AUDUSD") //{ // sendOrderSELL=true; //} if(Trading_Style==Trading_Automatically && bTimeTradingGMT==true && (sendOrderBUY || sendOrderSELL)) { nActiveTrades=Get_ActiveTrades(); nPairOrders =Get_PairTrades(pairNameSufix); // ........................... bool tradingPlatformStatus=Check_TradingPlatformStatus(); // ........................... // //#### TEST //if(pairNameSufix=="USDJPY") //{ //int iii=2; // sendOrderSELL=true; sendOrderBUY=false; //} if(nActiveTradesMarketInfo(pairNameSufix,MODE_ASK)) { res=Order_Send("Count",pairNameSufix,commentEACount,MagicNumber, OP_BUYSTOP,Lots,entryPriceCount,stopLossCount,takeProfitCount,dExpirationTime); //OP_BUYSTOP,Lots,entryPriceCount,stopLossCount,takeProfitCount,0); if(res>0 && Alert_SendOrderConfirmation && Alerts_Trading_Signals) Alert("COUNTER BUYSTOP pending order sended for: "+pairNameSufix+ " at "+DoubleToString(entryPriceCount,nDigits)+" "+TimeToString(TimeCurrent())+" (Server)"+sExpirationTime); //" at "+DoubleToString(entryPriceCount,nDigits)+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } } else //-- Short entry ------------------------------- if(sendOrderSELL) { entryPriceCount=NormalizeDouble(arrHigherOpenValue[ip],nDigits); if(entryPriceCount0 && Alert_SendOrderConfirmation && Alerts_Trading_Signals) Alert("COUNTER SELLSTOP pending order sended for: "+pairNameSufix+ " at "+DoubleToString(entryPriceCount,nDigits)+" "+TimeToString(TimeCurrent())+" (Server)"+sExpirationTime); //" at "+DoubleToString(entryPriceCount,nDigits)+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } } } } //######################################## //-- color CLOSE Button for active orders --------------------- int ticket,orderType; // .................. bool bOrderAvailable=Check_ActiveOrder(pairNameSufix,ticket,orderType); // .................. if(bOrderAvailable==true) { if(orderType==OP_BUY || orderType==OP_SELL) InpColor=clrButtonCLOSE; else if(orderType==OP_BUYSTOP || orderType==OP_SELLSTOP || orderType==OP_BUYLIMIT || orderType==OP_SELLLIMIT) InpColor=clrButtonCLOSEPend; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"OrderButton_CLOSE_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } else if(bOrderAvailable==false) { InpColor=clrButtonNONE; if(StringFind(Except,pairName,0)>=0) InpColor=clrGray; InpName=objEA+"OrderButton_CLOSE_"+pairName; ObjectSetInteger(0,InpName,OBJPROP_BGCOLOR,InpColor); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Check_ScalpingTrading() { color clrTrendUP=clrDodgerBlue; color clrTrendDN=clrRed; //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Wingdings"; // Font int InpFontSize=12; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenLabels; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string pairNameSufix; string sText,textSlope; bool conditionScalpLong=false,conditionScalpShort=false; bool sendScalpingOrder=false; int res,nDigits; int yy=y0-yStep; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; //-- SCALPING allowed if(SCALP_Trading_Allowed) { //-- 1. conditions SPREAD, ADX bool conditionSpread=(arrSpread[ip]<=MaximumAllowed_Spread); bool conditionADX =(arrADX[ip] >=ADX_MinimumAllowed); bool conditionTradingAllowed=(conditionSpread && conditionADX); //### ACHTUNG, ob beide Spreads zwischen Max/Min liegen! //-- 2. conditions TREND bool conditionTrendUP=(arrTrend[ip]>0); bool conditionTrendDN=(arrTrend[ip]<0); //-- 2.1 conditions Open Position double mvgAvg=iMA(pairNameSufix,PERIOD_M15,MA_Period,0,MA_Mode,MA_Price,0); double dOpen=iOpen(pairNameSufix,PERIOD_M15,0); //-- 3.1 Currency Strength slope values bool conditionSlopeUPvalue=(arrCurrencySlopeValue[ip]== 1); bool conditionSlopeDNvalue=(arrCurrencySlopeValue[ip]==-1); //-- 3.2 Currency Strength slope signals bool conditionSlopeUPsignal=(arrCurrencySlopeSignal[ip]== 1); bool conditionSlopeDNsignal=(arrCurrencySlopeSignal[ip]==-1); //-- 4. Check trading conditions conditionScalpLong=(conditionTradingAllowed && conditionTrendUP && dOpen>mvgAvg && conditionSlopeUPsignal); conditionScalpShort=(conditionTradingAllowed && conditionTrendDN && dOpen0 && timeDiff>=SCALP_ConfirmationTime_Minutes*60 && slopeSignalSended[ip]==false && (conditionScalpLong || conditionScalpShort)) { if(Alerts_SCALPING_Signals) Alert(textSlope); slopeSignalSended[ip]=true; sendScalpingOrder=true; } //########################################## //-- 6. send SCALP Orders ------------------------------------- //########################################## if(SCALP_Trading_Style==Trading_Automatically && bTimeTradingGMT==true) //### { nActiveTrades=Get_ActiveTrades(); nPairOrders =Get_PairTrades(pairNameSufix); // ........................... bool tradingPlatformStatus=Check_TradingPlatformStatus(); // ........................... if(nActiveTrades0 && Alert_SendOrderConfirmation && Alerts_SCALPING_Signals) Alert("SCALPING BUY market order sended for: "+pairNameSufix+ " at "+DoubleToString(entryPrice,nDigits)+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } else if(conditionScalpShort) { entryPrice=NormalizeDouble(MarketInfo(pairNameSufix,MODE_BID),nDigits); res=Order_Send("Scalp",pairNameSufix,commentEASlope,MagicNumber, OP_SELL,Lots,entryPrice,stopLossScalp,takeProfitScalp,0); if(res>0 && Alert_SendOrderConfirmation && Alerts_SCALPING_Signals) Alert("SCALPING SELL market order sended for: "+pairNameSufix+ " at "+DoubleToString(entryPrice,nDigits)+" "+TimeToString(TimeCurrent(),TIME_MINUTES)); } } } //### } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_PairTrend() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenLabels; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; int yy; //-- write title xPosition=xPosition+4*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"PairTrendTitle"; sText="Trend"; InpColor=clrRed; //--- write spread title if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write Trend InpX=(int)(xPosition-1.5*xStep); xPositionTrendArrow=InpX; yy=y0-yStep; color clrTrendUP=clrDodgerBlue; //color clrTrendUP=clrTurquoise; //color clrTrendUP=clrGreen; color clrTrendDN=clrRed; string pairNameSufix; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"PairTrend_"+pairName; yy=yy+yStep; InpY=yy; double dTrend=iMA(pairNameSufix,PERIOD_M15,MA_Period,0,MA_Mode,MA_Price,0)- iMA(pairNameSufix,PERIOD_M15,MA_Period,0,MA_Mode,MA_Price,1); //--- write trend values InpFont="Wingdings"; InpFontSize=12; arrTrend[ip]=dTrend; if(dTrend>0) { InpColor=clrTrendUP; sText=CharToString(236); } else { InpColor=clrTrendDN; sText=CharToString(238); } if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_PairATR() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenLabels; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; int yy; //-- write title xPosition=xPosition+3*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"PairATRTitle"; sText="ATR"; InpColor=clrRed; //--- write spread title if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write ATR InpX=xPosition; yy=y0-yStep; string pairNameSufix; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"PairATR_"+pairName; double dATR=0; yy=yy+yStep; InpY=yy; if(MarketInfo(pairNameSufix,MODE_POINT)>0) dATR=iATR(pairNameSufix,PERIOD_M15,ATR_Period,1)/MarketInfo(pairNameSufix,MODE_POINT); arrATR[ip]=dATR; sText=DoubleToString(dATR,0); //--- write spread values InpColor=clrGoldenrod; if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_PairADX() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenLabels; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; int yy; //-- write title xPosition=xPosition+3*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"PairADXTitle"; sText="ADX"; InpColor=clrRed; //--- write spread title if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write ADX InpX=xPosition; yy=y0-yStep; color clrADXOK =clrLawnGreen; color clrADXNOK=clrDodgerBlue; string pairNameSufix; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"PairADX_"+pairName; yy=yy+yStep; InpY=yy; double dADX=iADX(pairNameSufix,PERIOD_M15,ADX_Period,PRICE_CLOSE,MODE_MAIN,0); arrADX[ip]=dADX; sText=DoubleToString(dADX,0); //--- write ADX values if(dADX>=ADX_MinimumAllowed) InpColor=clrADXOK; else InpColor=clrADXNOK; if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_PairSpreads() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=bHiddenLabels; // Hidden in the object list //bool InpHidden=true; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ string sText; int yy; //-- write title xPosition=xPosition+x_sizeButton1+3*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"PairSpreadTitle"; sText="Sprd"; InpColor=clrRed; //--- write spread title if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write spread values -------------------------------------------- InpX=xPosition; yy=y0-yStep; color clrSpreadOK=clrLawnGreen; //color clrSpreadNOK=clrDeepSkyBlue; color clrSpreadNOK=clrDodgerBlue; color clrButtonOK =clrLawnGreen; color clrButtonNOK=clrSilver; string pairNameSufix; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; InpName=objEA+"PairSpread_"+pairName; yy=yy+yStep; InpY=yy; double dSpread=MarketInfo(pairNameSufix,MODE_SPREAD); arrSpread[ip]=dSpread; sText=(string)dSpread; //--- write spread values if(dSpread<=MaximumAllowed_Spread) InpColor=clrSpreadOK; else InpColor=clrSpreadNOK; if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } // ////-- Write the CurrentTime // InpName=objEA+"TimeCurrent"; // InpColor=clrRed; // InpX=5; // InpY=12; // InpFont="Arial Black"; // Font // InpFontSize=10; // Font size // InpAnchor=ANCHOR_LEFT_UPPER; // sText=TimeToString(TimeCurrent())+" GMT: "+TimeToString(TimeGMT(),TIME_DATE|TIME_MINUTES|TIME_SECONDS); // // if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, // InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) // { // return; // } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_WinLossOrders() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=true; // Hidden in the object list // for Tests //bool InpSelection=true; // Highlight to move //bool InpHidden=false; // Hidden in the object list long InpZOrder=0; /* Priority for mouse click */ //-- variables string sText; int yy; //-- write title xPosition=xPosition+22*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"WinLoss"; sText="Buy Sell $$$"; InpColor=clrRed; //--- write spread title if(!LabelCreate(chart_id,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } color clrWin =clrTurquoise; color clrLoss=clrMagenta; color clrNO=clrWhite; double pairBUYvalue,pairSELLvalue,pairWinLoss; double pairBUYPips,pairSELLPips; double dLots; int InpX_Buy =xPosition-14*xStep; int InpX_Sell=InpX_Buy +6*xStep; int InpX_All =InpX_Sell+8*xStep; //-- write Win/Loss for BUY orders ---------------------------------- yy=y0-yStep; string pairNameSufix; double sumWinLoss=0; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; yy=yy+yStep; InpY=yy; //............... Get_WinLossValues(pairNameSufix,pairBUYvalue,pairSELLvalue,pairWinLoss,dLots); //............... sumWinLoss=sumWinLoss+pairWinLoss; //--- 1. write buy result ------------------------------------- InpName=objEA+"PairBuy_"+pairName; if(Show_WinLoss_Pips) { if(dLots>0 && MarketInfo(pairNameSufix,MODE_TICKVALUE)>0) pairBUYPips=pairBUYvalue/MarketInfo(pairNameSufix,MODE_TICKVALUE)/dLots; else pairBUYPips=0; sText=DoubleToString(pairBUYPips,0); } else sText=DoubleToString(pairBUYvalue,2); if(pairBUYvalue!=0) { if(pairBUYvalue>0) InpColor=clrWin; else InpColor=clrLoss; } else InpColor=clrNO; if(!LabelCreate(chart_id,InpName,0,InpX_Buy,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //--- 2. write sell result------------------------------------- InpName=objEA+"PairSell_"+pairName; if(Show_WinLoss_Pips) { if(dLots>0 && MarketInfo(pairNameSufix,MODE_TICKVALUE)) pairSELLPips=pairSELLvalue/MarketInfo(pairNameSufix,MODE_TICKVALUE)/dLots; else pairSELLPips=0; sText=DoubleToString(pairSELLPips,0); } else sText=DoubleToString(pairSELLvalue,2); if(pairSELLvalue!=0) { if(pairSELLvalue>0) InpColor=clrWin; else InpColor=clrLoss; } else InpColor=clrNO; if(!LabelCreate(chart_id,InpName,0,InpX_Sell,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //--- 3. write total result ----------------------------------- InpName=objEA+"PairWin_"+pairName; sText=DoubleToString(pairWinLoss,2); if(pairWinLoss!=0) { if(pairWinLoss>0) InpColor=clrWin; else InpColor=clrLoss; } else InpColor=clrNO; if(!LabelCreate(chart_id,InpName,0,InpX_All,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } //************************************** //-- check close all automatic orders //************************************** if(Trading_Style==Trading_Automatically || (SCALP_Trading_Allowed==true && SCALP_Trading_Style==Trading_Automatically)) { if(sumWinLoss>=Auto_Minimum_DailyProfit_Currency || sumWinLoss<=-Auto_Maximum_DailyLoss_Currency) { Order_CloseAll("ALLwins",false); Order_CloseAll("ALLloss",false); //dailyTradingOK=false; ??? für was wurde gedacht ??? } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Get_ActiveTrades() { int nActiveTradesX=0; int total=OrdersTotal(); if(total==0) return(0); for(int cnt=total-1;cnt>=0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS)==false) continue; if(OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUY || OrderType()==OP_SELL || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) nActiveTradesX++; } } return(nActiveTradesX); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Get_PairTrades(string pairName) { int nPairTradesX=0; int total=OrdersTotal(); if(total==0) return(0); for(int cnt=total-1;cnt>=0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS)==false) continue; if(OrderSymbol()==pairName && OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUY || OrderType()==OP_SELL || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) nPairTradesX++; } } return(nPairTradesX); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_WinLossValues(string pairName,double &pairWinValueX,double &pairLossValueX,double &pairWinLoss,double &dLotsX) { pairWinValueX =0; pairLossValueX=0; pairWinLoss =0; nActiveTrades =0; int total=OrdersTotal(); if(total==0) return; for(int cnt=total-1;cnt>=0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS)==false) continue; if(OrderSymbol()==pairName && OrderMagicNumber()==MagicNumber) { pairWinLoss=OrderProfit(); dLotsX=OrderLots(); if(OrderType()==OP_BUY) { pairWinValueX=pairWinLoss; nActiveTrades++; } else if(OrderType()==OP_SELL) { pairLossValueX=pairWinLoss; nActiveTrades++; } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Get_HighLowOpenValues() { //--- input parameters for labels/text string InpName="Label"; // Label name int InpX=150; // X-axis distance int InpY=150; // Y-axis distance string InpFont="Consolas"; // Font int InpFontSize=10; // Font size color InpColor=clrDodgerBlue; // Color double InpAngle=0.0; // Slope angle in degrees ENUM_ANCHOR_POINT InpAnchor=ANCHOR_RIGHT_UPPER; // Anchor type bool InpBack=false; // Background object bool InpSelection=false; // Highlight to move bool InpHidden=true; // Hidden in the object list long InpZOrder=0; //-- variables string objectName; double open0,close0,dHigherOpen,dLowerOpen; //datetime time0pen0,timeHigherOpen,timeLower0pen; string sHigherOpen,sLowerOpen; string sText; int yy; //== Get HIGHER OPENS =============================================== //-- write title xPosition=xPosition+7*xStep+5; InpX=xPosition; InpY=yTitles; InpName=objEA+"HigherOpen"; sText="HiOpen"; InpColor=clrRed; string pairNameSufix; if(!LabelCreate(0,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write higher values yy=y0-yStep; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; yy=yy+yStep; InpY=yy; InpName=objEA+"HigherOpen_"+pairName; //-- 1. current open ------------------------------------------ open0 =iOpen(pairNameSufix,PERIOD_M15,0); close0=iClose(pairNameSufix,PERIOD_M15,0); //-- 2. highest daily H1 open --------------------------------- datetime timeDailyOpen=iTime(pairNameSufix,PERIOD_D1,0); int currentDailyBars =iBarShift(pairNameSufix,PERIOD_H1,timeDailyOpen,true); int iBarHigherOpen=iHighest(pairNameSufix,PERIOD_H1,MODE_OPEN,currentDailyBars+1,0); //-- on H1 dHigherOpen =iOpen(pairNameSufix,PERIOD_H1,iBarHigherOpen); arrHigherOpenValue[ip]=dHigherOpen; if(open0>dHigherOpen && close0>dHigherOpen) { InpColor=clrRed; InpFont="Arial Black"; arrHigherOpenSignal[ip]=1; } else { InpColor=clrSilver; InpFont="Consolas"; arrHigherOpenSignal[ip]=0; } sText=DoubleToString(dHigherOpen,(int)MarketInfo(pairNameSufix,MODE_DIGITS)); //--- write spread title if(!LabelCreate(0,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } } //== Get LOWER OPENS ================================================ //-- write title xPosition=xPosition+7*xStep; InpX=xPosition; InpY=yTitles; InpName=objEA+"LowerOpen"; sText="LoOpen"; InpColor=clrRed; InpFont="Consolas"; if(!LabelCreate(0,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,sText,InpFont,InpFontSize, InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //-- write lower values yy=y0-yStep; for(int ip=0;ip=0) pairNameSufix=pairName; else pairNameSufix=Pair_Prefix+TradePair[ip]+Pair_Sufix; if(DontTrade_Pairs!="" && StringFind(DontTrade_Pairs,pairName,0)>=0) continue; yy=yy+yStep; InpY=yy; InpName=objEA+"LowerOpen_"+pairName; //-- 1. current open ------------------------------------------ open0 =iOpen(pairNameSufix,PERIOD_M15,0); close0=iClose(pairNameSufix,PERIOD_M15,0); datetime timeDailyOpen=iTime(pairNameSufix,PERIOD_D1,0); int currentDailyBars =iBarShift(pairNameSufix,PERIOD_H1,timeDailyOpen,true); int iBarLowerOpen=iLowest(pairNameSufix,PERIOD_H1,MODE_OPEN,currentDailyBars+1,0); //-- on H1 dLowerOpen =iOpen(pairNameSufix,PERIOD_H1,iBarLowerOpen); arrLowerOpenValue[ip]=dLowerOpen; double pairSpread=MarketInfo(pairNameSufix,MODE_SPREAD)*Point; if(open0