比特币通信协议 - 币圈消息

比特币通信协议篇11、二、TURN简介。在典型的情况下,TURN客户端连接到内网中,并且通过一个或者多个NAT到 详细

12
返回列表 发新帖

求助!多货币强弱指标,谢谢

  [复制链接]
11#
致远龙腾 发表于 2018-1-12 00:05:29 | 只看该作者
茫然之际,又有N人说,据说小 波可能有用,找来书翻翻,感觉无比艰深。而此时对技术分析已经信心动摇。某日遇一朋友,实战高手,一席交谈演示,发现,靠,实战中还是最好,关键是运用之妙了。
12#
致远龙腾 发表于 2018-1-12 01:17:21 | 只看该作者
茫然之际,又有N人说,据说小 波可能有用,找来书翻翻,感觉无比艰深。而此时对技术分析已经信心动摇。某日遇一朋友,实战高手,一席交谈演示,发现,靠,实战中还是最好,关键是运用之妙了。
13#
bykai 发表于 2018-1-12 02:08:43 | 只看该作者
谢谢分享谢谢分享谢谢分享谢谢分享
14#
xfzxds 发表于 2018-1-12 03:46:24 | 只看该作者

//+------------------------------------------------------------------+
//|                                        CSS CurrencySlopeStrength.mq4 |
//|                      Copyright 2012, Deltabron - Paul Geirnaerdt |
//|                                          http://www.deltabron.nl |
//+------------------------------------------------------------------+
//
// Parts based on CCFp.mq4, downloaded from mql4.com
//
#property copyright "Copyright 2012, Deltabron - Paul Geirnaerdt"
#property link      "http://www.deltabron.nl"
//----
#property indicator_separate_window
#property indicator_buffers 8
#define version            "v1.0.0"
//+------------------------------------------------------------------+
//| Release Notes                                                    |
//+------------------------------------------------------------------+
// v1.0.0 (alpha), 6/1/12
// * Added support to auto create symbolnames
// * Added 'maxBars' setting to limit number of history bars calculated and improve performance
// v1.0.0, 6/4/12
// * BUG: added (almost) unique identifier for objects to get multiple instances in one window (thanks, Verb)
// * New default for user setting 'symbolsToWeigh', it now has all symbols that the NanningBob 10.2 system looks at
#define EPSILON            0.00000001
#define CURRENCYCOUNT      8
//---- parameters
extern string  gen               = "----General inputs----";
extern bool    autoSymbols       = false;
extern string        symbolsToWeigh    = "GBPNZD,EURNZD,GBPAUD,GBPCAD,GBPJPY,GBPCHF,CADJPY,EURCAD,EURAUD,USDCHF,GBPUSD,EURJPY,NZDJPY,AUDCHF,AUDJPY,USDJPY,EURUSD,NZDCHF,CADCHF,AUDNZD,NZDUSD,CHFJPY,AUDCAD,USDCAD,NZDCAD,AUDUSD,EURCHF,EURGBP";
extern int     maxBars           = 0;
extern string  nonPropFont       = "Lucida Console";
extern bool    showOnlySymbolOnChart = true;
extern string  ind               = "----Indicator inputs----";
extern string  ind_tf            = "timeFrame M1,M5,M15,M30,H1,H4,D1,W1,MN1";
extern string  timeFrame         = "D1";
extern bool    showOnlyTimeframeOnChart = true;
extern string  cur               = "----Currency inputs----";
extern bool    USD               = true;
extern bool    EUR               = true;
extern bool    GBP               = true;
extern bool    CHF               = true;
extern bool    JPY               = true;
extern bool    AUD               = true;
extern bool    CAD               = true;
extern bool    NZD               = true;
extern string  col               = "----Colo(u)r inputs----";
extern color   Color_USD           = Green;
extern color   Color_EUR           = DeepSkyBlue;
extern color   Color_GBP           = Red;
extern color   Color_CHF           = Chocolate;
extern color   Color_JPY           = FireBrick;
extern color   Color_AUD           = DarkOrange;
extern color   Color_CAD           = Purple;
extern color   Color_NZD           = Teal;
// global indicator variables
string   indicatorName = "CurrencySlopeStrength";
string   shortName;
int      userTimeFrame;
string   almostUniqueIndex;
// indicator buffers
double   arrUSD[];
double   arrEUR[];
double   arrGBP[];
double   arrCHF[];
double   arrJPY[];
double   arrAUD[];
double   arrCAD[];
double   arrNZD[];
// symbol & currency variables
int      symbolCount;
string   symbolNames[];
string   currencyNames[CURRENCYCOUNT]        = { "USD", "EUR", "GBP", "CHF", "JPY", "AUD", "CAD", "NZD" };
double   currencyValues[CURRENCYCOUNT];      // Currency slope strength
double   currencyOccurrences[CURRENCYCOUNT]; // Holds the number of occurrences of each currency in symbols
color    currencyColors[CURRENCYCOUNT];
// object parameters
int      verticalShift = 10;
int      verticalOffset = 20;
int      horizontalShift = 50;
int      horizontalOffset = 10;
//----
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   initSymbols();
//---- indicators
   shortName = StringConcatenate(indicatorName, "  -  ", version, "  -  Timeframe: ", userTimeFrame, "   ");
   IndicatorShortName(shortName);
//----
   currencyColors[0] = Color_USD;
   SetIndexBuffer(0, arrUSD);
   SetIndexLabel(0, "USD");
   currencyColors[1] = Color_EUR;
   SetIndexBuffer(1, arrEUR);
   SetIndexLabel(1, "EUR");
   currencyColors[2] = Color_GBP;
   SetIndexBuffer(2, arrGBP);
   SetIndexLabel(2, "GBP");
   currencyColors[3] = Color_CHF;
   SetIndexBuffer(3, arrCHF);
   SetIndexLabel(3, "CHF");
   currencyColors[4] = Color_JPY;
   SetIndexBuffer(4, arrJPY);
   SetIndexLabel(4, "JPY");
   currencyColors[5] = Color_AUD;
   SetIndexBuffer(5, arrAUD);
   SetIndexLabel(5, "AUD");
   currencyColors[6] = Color_CAD;
   SetIndexBuffer(6, arrCAD);
   SetIndexLabel(6, "CAD");
   currencyColors[7] = Color_NZD;
   SetIndexBuffer(7, arrNZD);
   SetIndexLabel(7, "NZD");
//----
        SetLevelValue(1, 0.8);
        SetLevelValue(2, 0.4);
        SetLevelValue(3, 0.0);
        SetLevelValue(4, -0.4);
        SetLevelValue(5, -0.8);
//----
   string now = TimeCurrent();
   almostUniqueIndex = StringSubstr(now, StringLen(now) - 3);
   return(0);
}
//+------------------------------------------------------------------+
//| Initialize Symbols Array                                         |
//+------------------------------------------------------------------+
int initSymbols()
{
   int i;
   // Get extra characters on this crimmal's symbol names
   string symbolExtraChars = StringSubstr(Symbol(), 6, 4);
   // Trim user input
   symbolsToWeigh = StringTrimLeft(symbolsToWeigh);
   symbolsToWeigh = StringTrimRight(symbolsToWeigh);
   // Add extra comma
   if (StringSubstr(symbolsToWeigh, StringLen(symbolsToWeigh) - 1) != ",")
   {
      symbolsToWeigh = StringConcatenate(symbolsToWeigh, ",");   
   }   
   // Build symbolNames array as the user likes it
   if ( autoSymbols )
   {
      createSymbolNamesArray();
   }
   else
   {
      // Split user input
      i = StringFind(symbolsToWeigh, ",");
      while (i != -1)
      {
         int size = ArraySize(symbolNames);
         // Resize array
         ArrayResize(symbolNames, size + 1);
         // Set array
         symbolNames[size] = StringConcatenate(StringSubstr(symbolsToWeigh, 0, i), symbolExtraChars);
         // Trim symbols
         symbolsToWeigh = StringSubstr(symbolsToWeigh, i + 1);
         i = StringFind(symbolsToWeigh, ",");
      }
   }   
   symbolCount = ArraySize(symbolNames);
   ArrayInitialize(currencyOccurrences, 0.0);
   for ( i = 0; i  0 && MarketInfo ( tempSymbol, MODE_TRADEALLOWED ) )
      {
         ArrayResize( symbolNames, counter + 1 );
         symbolNames[counter] = tempSymbol;
         counter++;
      }
      FileSeek( hFileName, 1924, SEEK_CUR );
   }
   FileClose( hFileName );
   return ( 0 );
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   int windex = WindowFind ( shortName );
   if ( windex > 0 )
   {
      ObjectsDeleteAll ( windex );
   }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars  0)  counted_bars -= 10;
   limit = Bars - counted_bars;
   if ( maxBars > 0 )
   {
      limit = MathMin (maxBars, limit);   
   }   
   int i;
   for ( i = 0; i < CURRENCYCOUNT; i++ )
   {
      SetIndexStyle( i, DRAW_LINE, STYLE_SOLID, 2, currencyColors[i] );
   }   
   RefreshRates();
   for ( i = 0; i < limit; i++ )
   {
      int index;
      ArrayInitialize(currencyValues, 0.0);
      // Calc Slope into currencyValues[]  
      CalculateCurrencySlopeStrength(userTimeFrame, i);
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "USD" ) != -1 ) ) || ( !showOnlySymbolOnChart && USD ) )        
      {
         arrUSD[i] = currencyValues[0];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "EUR" ) != -1 ) ) || ( !showOnlySymbolOnChart && EUR ) )        
      {
         arrEUR[i] = currencyValues[1];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "GBP" ) != -1 ) ) || ( !showOnlySymbolOnChart && GBP ) )        
      {
         arrGBP[i] = currencyValues[2];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "CHF" ) != -1 ) ) || ( !showOnlySymbolOnChart && CHF ) )        
      {
         arrCHF[i] = currencyValues[3];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "JPY" ) != -1 ) ) || ( !showOnlySymbolOnChart && JPY ) )        
      {
         arrJPY[i] = currencyValues[4];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "AUD" ) != -1 ) ) || ( !showOnlySymbolOnChart && AUD ) )        
      {
         arrAUD[i] = currencyValues[5];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "CAD" ) != -1 ) ) || ( !showOnlySymbolOnChart && CAD ) )        
      {
         arrCAD[i] = currencyValues[6];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "NZD" ) != -1 ) ) || ( !showOnlySymbolOnChart && NZD ) )        
      {
         arrNZD[i] = currencyValues[7];
      }
      if ( i == 0 )
      {
         // Show ordered table
         ShowCurrencyTable();
      }   
   }//end block for(int i=0; i<limit; i++)
   return(0);
}
//+------------------------------------------------------------------+
//| GetSlope()                                                       |
//+------------------------------------------------------------------+
double GetSlope(string symbol, int tf, int shift)
{
   double atr = iATR(symbol, tf, 100, shift + 10) / 10;
   double gadblSlope = 0.0;
   if ( atr != 0 )
   {
      double dblTma = calcTma( symbol, tf, shift );
      double dblPrev = calcTma( symbol, tf, shift + 1 );
      gadblSlope = ( dblTma - dblPrev ) / atr;
   }
   return ( gadblSlope );
}//End double GetSlope(int tf, int shift)
//+------------------------------------------------------------------+
//| calcTma()                                                        |
//+------------------------------------------------------------------+
double calcTma( string symbol, int tf,  int shift )
{
   double dblSum  = iClose(symbol, tf, shift) * 21;
   double dblSumw = 21;
   int jnx, knx;
   for ( jnx = 1, knx = 20; jnx <= 20; jnx++, knx-- )
   {
      dblSum  += ( knx * iClose(symbol, tf, shift + jnx) );
      dblSumw += knx;
      if ( jnx <= shift )
      {
         dblSum  += ( knx * iClose(symbol, tf, shift - jnx) );
         dblSumw += knx;
      }
   }
   return( dblSum / dblSumw );
}// End calcTma()
//+------------------------------------------------------------------+
//| CalculateCurrencySlopeStrength(int tf, int shift                 |
//+------------------------------------------------------------------+
void CalculateCurrencySlopeStrength(int tf, int shift)
{
   int i;
   // Get Slope for all symbols and totalize for all currencies   
   for ( i = 0; i < symbolCount; i++)
   {
      double slope = GetSlope(symbolNames[i], tf, shift);
      currencyValues[GetCurrencyIndex(StringSubstr(symbolNames[i], 0, 3))] += slope;
      currencyValues[GetCurrencyIndex(StringSubstr(symbolNames[i], 3, 3))] -= slope;
   }
   for ( i = 0; i < CURRENCYCOUNT; i++ )
   {
      // average
      currencyValues[i] /= currencyOccurrences[i];
   }
}
//+------------------------------------------------------------------+
//| ShowCurrencyTable()                                              |
//+------------------------------------------------------------------+
void ShowCurrencyTable()
{
   int i;
   int tempValue;
   string objectName;
   string showText;
   int windex = WindowFind ( shortName );
   double tempCurrencyValues[CURRENCYCOUNT][2];
   for ( i = 0; i < CURRENCYCOUNT; i++ )
   {
      tempCurrencyValues[i][0] = currencyValues[i];
      tempCurrencyValues[i][1] = i;
   }
   // Sort currency to values
   ArraySort(tempCurrencyValues, WHOLE_ARRAY, 0, MODE_DESCEND);
   // Loop currency values and header output objects, creating them if necessary
   for ( i = 0; i < CURRENCYCOUNT; i++ )
   {
      objectName = almostUniqueIndex + "_css_obj_column_currency_" + i;
      if ( ObjectFind ( objectName ) == -1 )
      {
         if ( ObjectCreate ( objectName, OBJ_LABEL, windex, 0, 0 ) )
         {
            ObjectSet ( objectName, OBJPROP_CORNER, 1 );
            ObjectSet ( objectName, OBJPROP_XDISTANCE, horizontalShift * 0 + horizontalOffset + 50 );
            ObjectSet ( objectName, OBJPROP_YDISTANCE, (verticalShift + 2) * i + verticalOffset - 18 );
         }
      }
      tempValue = tempCurrencyValues[i][1];
      showText = currencyNames[tempValue];
      ObjectSetText ( objectName, showText, 8, nonPropFont, currencyColors[tempValue] );
      objectName = almostUniqueIndex + "_css_obj_column_value_" + i;
      if ( ObjectFind ( objectName ) == -1 )
      {
         if ( ObjectCreate ( objectName, OBJ_LABEL, windex, 0, 0 ) )
         {
            ObjectSet ( objectName, OBJPROP_CORNER, 1 );
            ObjectSet ( objectName, OBJPROP_XDISTANCE, horizontalShift * 0 + horizontalOffset - 55 + 50 );
            ObjectSet ( objectName, OBJPROP_YDISTANCE, (verticalShift + 2) * i + verticalOffset - 18 );
         }
      }
      showText = RightAlign(DoubleToStr(tempCurrencyValues[i][0], 2), 5);
      ObjectSetText ( objectName, showText, 8, nonPropFont, currencyColors[tempValue] );
   }
}
//+------------------------------------------------------------------+
//| Right Align Text                                                 |
//+------------------------------------------------------------------+
string RightAlign ( string text, int length = 10, int trailing_spaces = 0 )
{
   string text_aligned = text;
   for ( int i = 0; i < length - StringLen ( text ) - trailing_spaces; i++ )
   {
      text_aligned = " " + text_aligned;
   }
   return ( text_aligned );
}
15#
EUR168 发表于 2018-1-12 04:15:23 | 只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝1

帖子3

发布主题
阅读排行更多+

Powered by 顺水鱼MT4外汇EA网! X3.2© 2001-2017 顺水MT4外汇EA公司.( 陕ICP备17014341号-1