/* !xMeter Indy v07.mq4 Price Meter System™ ©GPL This is an indicator based on the EA called !xMeter_EA.mq4 by Robert Hill (5/16/2007) traderak20@gmail.com / v07 2/26/2008 Major code overhaul to allow for up to eight currencies to be set using the input parameters 2/26/2008 Added input parameters for currencies and colors 2/26/2008 Added function createCurrencyArray() to determine input currencies 2/26/2008 Added function createPairArray() to set pairs based based on input currencies 2/26/2008 Updated main functionality to deal with flexible number of currencies and pairs 2/26/2008 Moved main calculation to function calculateBuffers() 2/26/2008 Renamed file from !xMeter_EA Major_5 Indy v02.mq4 to !xMeter Indy v07.mq4 traderak20@gmail.com / v02 1/30/2008 Changed currencies to major 5 (EUR, USD, GBP, CHF, JPY). The meter uses all 10 possible pairs 1/30/2008 Replaced GetPoint() function with built-in function MarketInfo(string symbol,MODE_POINT) 1/30/2008 Default symbol names are now without "m", for IBFX accounts the "m" is added afterwards 1/30/2008 Changed the display of grades from a scale of 5 steps to 10 (10 were already calculated anyway) 1/30/2008 Some minor changes to variable names, clean-up of code and cosmetic. 1/30/2008 Renamed file from !xMeter_EA.mq4 to !xMeter_EA Major_5 Indy v02.mq4 */ /* traderak20@gmail.com - 2/26/2008 / v07 In v07 you can specify up to eight currencies. For the indicator to be accurate all possible combinations of the currencies that you specify must be available in your marketwatch window (for eight currencies that's 28 pairs). If even a single pair is missing, the lines drawn will not be a 100% accurate! The indicator is optimised to calculate only the buffers that are required. However if you input eight currencies it will draw all eight buffers based on 28 pairs (up from 5 currencies and 10 pairs in v02). To prevent the indicator from consuming too much processor power (and if you use the indicator for trading rather than historical analysis) you could shorten the number of bars in the history. Bear in mind that with applySmoothing set to TRUE and a smoothingPeriod of 14, you will need a minimum lead of about 250 bars to get a reliable output. A longer smoothing period requires more bars. Setting showAllCurrencies to FALSE will not speed up the indicator since this only affects the display of the indicator lines while all buffers still require to be calculated. traderak20@gmail.com - 1/30/2008 / v02 This indicator can be used in addition to the expert advisor created by Robert Hill. The EA provides better real-time information since it's updating continuously and doesn't need a tick on the current chart as input. This indicator can then be used to gain more insight in the history of the strength of currencies. The indicator may slow down your computer for a bit when set to view the entire history of your chart. To allow you look at only certain parts of the history, I have added three parameters: setStartDateTime, setEndDateTime, maxHistoryBars These parameters can be set separately or combined in a number of ways: * use only maxHistoryBars, leave start date and end date empty: ---------------H++++0 * set start date + end date (maxHistoryBars is ignored): ----S+++++++E-------0 * use start date + maxHistoryBars, leave end date empty: ----S++++H----------0 * set maxHistoryBars + end date, leave start date empty: -------H++++E-------0 * set only a start date, leave end date and maxHistoryBars empty: ----S+++++++++++++++0 * set only an end date, leave start date and maxHistoryBars empty: ++++++++++++E-------0 * leave the start date, end date and maxHistoryBars empty to view the whole history: ++++++++++++++++++++0 */ #property copyright "x Meter System™ ©GPL" #property link "forex-tsd dot com" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 11 #property indicator_buffers 8 #property indicator_color1 CLR_NONE #property indicator_color2 CLR_NONE #property indicator_color3 CLR_NONE #property indicator_color4 CLR_NONE #property indicator_color5 CLR_NONE #property indicator_color6 CLR_NONE #property indicator_color7 CLR_NONE #property indicator_color8 CLR_NONE //---- input parameters extern string currency_0 = "EUR"; extern string currency_1 = "USD"; extern string currency_2 = "GBP"; extern string currency_3 = "CHF"; extern string currency_4 = "JPY"; extern string currency_5 = ""; extern string currency_6 = ""; extern string currency_7 = ""; extern color currencycolor_0 = DodgerBlue; extern color currencycolor_1 = ForestGreen; extern color currencycolor_2 = FireBrick; extern color currencycolor_3 = Sienna; extern color currencycolor_4 = Purple; extern color currencycolor_5 = Orange; extern color currencycolor_6 = LightSeaGreen; extern color currencycolor_7 = DarkKhaki; extern bool showAllCurrencies = TRUE; // TRUE = show all five indicator lines, FALSE = show only the currencies from this chart extern bool AccountIsIBFXmini = FALSE; extern string setStartDateTime = ""; // Use standard date format. 2007.5.25 Optionally add time as well: 2007.5.25 16:00 extern string setEndDateTime = ""; // Use standard date format. 2007.7.31 Optionally add time as well: 2007.5.25 16:00 extern int maxHistoryBars = 500; // This value is ignored if both a start and end datetime are given extern bool lookBackStartMidnight = TRUE; // TRUE = calculate with high, low and range since midnight // FALSE = calculate with high, low and range from rolling lookback period (in hours) extern int lookBackPeriod = 12; extern bool applySmoothing = FALSE; // Apply smoothing to get a less choppy picture (with more lag obviously) extern int smoothingPeriod = 14; //---- buffers double Buffer_0[]; double Buffer_1[]; double Buffer_2[]; double Buffer_3[]; double Buffer_4[]; double Buffer_5[]; double Buffer_6[]; double Buffer_7[]; //---- Set global variables int numberOfCurrencies; int numberOfPairs; string aCurrency[]; string aPair[]; int startBar_TF1, endBar_TF1; //+------------------------------------------------------------------+ // indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- Check input currencies and add valid currencies to the currency array createCurrencyArray(); //---- Calculate number of pairs possible and store all pairs in an array createPairArray(); //---- Set start/end bar setStartEndBar(startBar_TF1, endBar_TF1); IndicatorBuffers(numberOfCurrencies); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); //---- indicator line if ( numberOfCurrencies >= 1 ) SetIndexBuffer(0,Buffer_0); if ( numberOfCurrencies >= 2 ) SetIndexBuffer(1,Buffer_1); if ( numberOfCurrencies >= 3 ) SetIndexBuffer(2,Buffer_2); if ( numberOfCurrencies >= 4 ) SetIndexBuffer(3,Buffer_3); if ( numberOfCurrencies >= 5 ) SetIndexBuffer(4,Buffer_4); if ( numberOfCurrencies >= 6 ) SetIndexBuffer(5,Buffer_5); if ( numberOfCurrencies >= 7 ) SetIndexBuffer(6,Buffer_6); if ( numberOfCurrencies >= 8 ) SetIndexBuffer(7,Buffer_7); bool showBuffer_0, showBuffer_1, showBuffer_2, showBuffer_3; bool showBuffer_4, showBuffer_5, showBuffer_6, showBuffer_7; if ( StringFind(Symbol(), aCurrency[0], 0) != -1) showBuffer_0 = TRUE; if ( StringFind(Symbol(), aCurrency[1], 0) != -1) showBuffer_1 = TRUE; if ( StringFind(Symbol(), aCurrency[2], 0) != -1) showBuffer_2 = TRUE; if ( StringFind(Symbol(), aCurrency[3], 0) != -1) showBuffer_3 = TRUE; if ( StringFind(Symbol(), aCurrency[4], 0) != -1) showBuffer_4 = TRUE; if ( StringFind(Symbol(), aCurrency[5], 0) != -1) showBuffer_5 = TRUE; if ( StringFind(Symbol(), aCurrency[6], 0) != -1) showBuffer_6 = TRUE; if ( StringFind(Symbol(), aCurrency[7], 0) != -1) showBuffer_7 = TRUE; if ( showAllCurrencies == TRUE || showBuffer_0 == TRUE ) SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,currencycolor_0); else SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_1 == TRUE ) SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,currencycolor_1); else SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_2 == TRUE ) SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1,currencycolor_2); else SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_3 == TRUE ) SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1,currencycolor_3); else SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_4 == TRUE ) SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1,currencycolor_4); else SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_5 == TRUE ) SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1,currencycolor_5); else SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_6 == TRUE ) SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,1,currencycolor_6); else SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( showAllCurrencies == TRUE || showBuffer_7 == TRUE ) SetIndexStyle(7,DRAW_LINE,STYLE_SOLID,1,currencycolor_7); else SetIndexStyle(7,DRAW_LINE,STYLE_SOLID,0,CLR_NONE); if ( numberOfCurrencies >= 1 ) SetIndexLabel(0,aCurrency[0]); if ( numberOfCurrencies >= 2 ) SetIndexLabel(1,aCurrency[1]); if ( numberOfCurrencies >= 3 ) SetIndexLabel(2,aCurrency[2]); if ( numberOfCurrencies >= 4 ) SetIndexLabel(3,aCurrency[3]); if ( numberOfCurrencies >= 5 ) SetIndexLabel(4,aCurrency[4]); if ( numberOfCurrencies >= 6 ) SetIndexLabel(5,aCurrency[5]); if ( numberOfCurrencies >= 7 ) SetIndexLabel(6,aCurrency[6]); if ( numberOfCurrencies >= 8 ) SetIndexLabel(7,aCurrency[7]); if ( numberOfCurrencies >= 1 ) SetIndexDrawBegin(0,0); if ( numberOfCurrencies >= 2 ) SetIndexDrawBegin(1,0); if ( numberOfCurrencies >= 3 ) SetIndexDrawBegin(2,0); if ( numberOfCurrencies >= 4 ) SetIndexDrawBegin(3,0); if ( numberOfCurrencies >= 5 ) SetIndexDrawBegin(4,0); if ( numberOfCurrencies >= 6 ) SetIndexDrawBegin(5,0); if ( numberOfCurrencies >= 7 ) SetIndexDrawBegin(6,0); if ( numberOfCurrencies >= 8 ) SetIndexDrawBegin(7,0); //---- If you change the name of this window, //---- you must also update the WindowFind() function further down IndicatorShortName("Price Meter System™ ©GPL -"); //---- return(0); } //+------------------------------------------------------------------+ // indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { deleteLegendObjects(); return(0); } //+------------------------------------------------------------------+ // indicator start function | //+------------------------------------------------------------------+ int start() { //---- Date, time and counter variables int counted_bars = IndicatorCounted(); int timeFrame_1 = Period(); int barShift_TF1; //---- Minimum 100 bars in chart if ( iBars(Symbol(), timeFrame_1) <= 100 ) return(0); //---- Check for possible errors if ( counted_bars < 0 ) return(-1); //---- The last counted bar will be recounted if( counted_bars > 0 ) counted_bars--; //---- Main calculation loop for ( barShift_TF1 = startBar_TF1; barShift_TF1 >= endBar_TF1; barShift_TF1-- ) { calculateBuffers(timeFrame_1, startBar_TF1, barShift_TF1); } deleteLegendObjects(); if ( numberOfCurrencies >= 1 ) createLegendObjects("objTextBuffer_0",500,2,aCurrency[0],10,"Arial",currencycolor_0); if ( numberOfCurrencies >= 2 ) createLegendObjects("objTextBuffer_1",535,2,aCurrency[1],10,"Arial",currencycolor_1); if ( numberOfCurrencies >= 3 ) createLegendObjects("objTextBuffer_2",570,2,aCurrency[2],10,"Arial",currencycolor_2); if ( numberOfCurrencies >= 4 ) createLegendObjects("objTextBuffer_3",605,2,aCurrency[3],10,"Arial",currencycolor_3); if ( numberOfCurrencies >= 5 ) createLegendObjects("objTextBuffer_4",640,2,aCurrency[4],10,"Arial",currencycolor_4); if ( numberOfCurrencies >= 6 ) createLegendObjects("objTextBuffer_5",675,2,aCurrency[5],10,"Arial",currencycolor_5); if ( numberOfCurrencies >= 7 ) createLegendObjects("objTextBuffer_6",710,2,aCurrency[6],10,"Arial",currencycolor_6); if ( numberOfCurrencies >= 8 ) createLegendObjects("objTextBuffer_7",745,2,aCurrency[7],10,"Arial",currencycolor_7); return(0); } //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //---- This function checks the input currencies and adds them to the currency array void createCurrencyArray() { int i = 0; string addM; //---- Make naming compatible with IBFX mini accounts if (AccountIsIBFXmini) addM = "m"; else addM = ""; //---- Check if input currencies exist against USD and add valid currencies to the currency array if ( currency_0 == "USD" || ( MarketInfo(currency_0+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_0+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_0; i++; } if ( currency_1 == "USD" || ( MarketInfo(currency_1+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_1+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_1; i++; } if ( currency_2 == "USD" || ( MarketInfo(currency_2+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_2+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_2; i++; } if ( currency_3 == "USD" || ( MarketInfo(currency_3+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_3+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_3; i++; } if ( currency_4 == "USD" || ( MarketInfo(currency_4+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_4+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_4; i++; } if ( currency_5 == "USD" || ( MarketInfo(currency_5+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_5+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_5; i++; } if ( currency_6 == "USD" || ( MarketInfo(currency_6+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_6+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_6; i++; } if ( currency_7 == "USD" || ( MarketInfo(currency_7+"USD"+addM,MODE_BID)>0 || MarketInfo("USD"+currency_7+addM,MODE_BID)>0 ) ) { ArrayResize(aCurrency,i+1); aCurrency[i] = currency_7; i++; } //---- Count number of valid currencies in array numberOfCurrencies = ArraySize(aCurrency); return(0); } //-------------------------------------------------------------------------------------------------------------- //---- This function creates an array of all pairs possible from the currencies in the currency array void createPairArray() { int i = 0, j, k; string addM, pair1, pair2; //---- Create array of all possible pairs for ( j = 0; j < numberOfCurrencies - 1; j++ ) { //---- Make naming compatible with IBFX mini accounts if (AccountIsIBFXmini) addM = "m"; else addM = ""; for ( k = j + 1; k < numberOfCurrencies; k++ ) { pair1 = aCurrency[j]+aCurrency[k] + addM; if ( MarketInfo(pair1,MODE_BID) > 0 ) { ArrayResize(aPair,i+1); aPair[i] = pair1; i++; } pair2 = aCurrency[k]+aCurrency[j] + addM; if ( MarketInfo(pair2,MODE_BID) > 0 ) { ArrayResize(aPair,i+1); aPair[i] = pair2; i++; } } } //---- Count number of valid pairs in array numberOfPairs = ArraySize(aPair); return(0); } //-------------------------------------------------------------------------------------------------------------- //---- Set the start/end bar for the indicator based on setStartDateTime, setEndDateTime and maxHistoryBars void setStartEndBar(int& startbar, int& endbar) { int maxbars = iBars(Symbol(), Period()) - IndicatorCounted() - 1; if ( setStartDateTime != "" && setEndDateTime != "" ) { if ( StrToTime(setStartDateTime) > StrToTime(setEndDateTime) ) { string tempTimeString = setStartDateTime; setStartDateTime = setEndDateTime; setEndDateTime = tempTimeString; } startbar = iBarShift(Symbol(), Period(), StrToTime(setStartDateTime), false); endbar = iBarShift(Symbol(), Period(), StrToTime(setEndDateTime), false); } if ( setStartDateTime != "" && setEndDateTime == "" && maxHistoryBars > 0) { startbar = iBarShift(Symbol(), Period(), StrToTime(setStartDateTime), false); //---- Don't let endbar be smaller than most recent bar endbar = MathMax(startbar - maxHistoryBars,0); } if ( setStartDateTime != "" && setEndDateTime == "" && maxHistoryBars <= 0) { startbar = iBarShift(Symbol(), Period(), StrToTime(setStartDateTime), false); endbar = 0; } if ( setStartDateTime == "" && setEndDateTime != "" && maxHistoryBars > 0) { endbar = iBarShift(Symbol(), Period(), StrToTime(setEndDateTime), false); //---- Don't go let startbar be bigger than the maximum bars available in this chart startbar = MathMin( endbar + maxHistoryBars, maxbars ); } if ( setStartDateTime == "" && setEndDateTime != "" && maxHistoryBars <= 0) { startbar = maxbars; endbar = iBarShift(Symbol(), Period(), StrToTime(setEndDateTime), false); } if ( setStartDateTime == "" && setEndDateTime == "" && maxHistoryBars > 0) { startbar = maxHistoryBars; endbar = 0; } if ( setStartDateTime == "" && setEndDateTime == "" && maxHistoryBars <= 0) { startbar = maxbars; endbar = 0; } return(0); } //-------------------------------------------------------------------------------------------------------------- //---- This function calculates all the buffer values void calculateBuffers(int timeframe, int startbar, int barshift) { //---- Price Meter System variables double aMeter[]; ArrayResize(aMeter,numberOfCurrencies); double aHigh[]; ArrayResize(aHigh,numberOfPairs); double aLow[]; ArrayResize(aLow,numberOfPairs); double aClose[]; ArrayResize(aClose,numberOfPairs); double aRatio_1[]; ArrayResize(aRatio_1,numberOfPairs); double aRatio_2[]; ArrayResize(aRatio_2,numberOfPairs); double aRange[]; ArrayResize(aRange,numberOfPairs); double aLookup_1[]; ArrayResize(aLookup_1,numberOfPairs); double aLookup_2[]; ArrayResize(aLookup_2,numberOfPairs); double point; int i, j, k, m; string mySymbol; int highBar, lowBar; string subPair1, subPair2; int calculationMethod; double highSubPair1, highSubPair2, lowSubPair1, lowSubPair2, closeSubPair1, closeSubPair2; double highBarsArray[], lowBarsArray[]; //---- Set lookback period to start at midnight if ( lookBackStartMidnight == TRUE ) lookBackPeriod = TimeHour( iTime(mySymbol, timeframe, barshift) ) + 1; //---- Initialize all pairs required value for ( i = 0; i < numberOfPairs; i++ ) { mySymbol = aPair[i]; //---- Get point info for symbol point = MarketInfo(mySymbol,MODE_POINT); //---- Find highest and lowest bar during the lookback period highBar = iHighest(mySymbol, timeframe, MODE_HIGH, lookBackPeriod, barshift); lowBar = iLowest(mySymbol, timeframe, MODE_LOW, lookBackPeriod, barshift); //---- Set high, low and close aHigh[i] = iHigh(mySymbol, timeframe, highBar); aLow[i] = iLow(mySymbol, timeframe, lowBar); aClose[i] = iClose(mySymbol, timeframe, barshift); //---- Calculate range over the lookback period aRange[i] = MathMax( (aHigh[i] - aLow[i]) / point,1); //---- Calculate pair's ratio and inverse ratio aRatio_1[i] = ( aClose[i] - aLow[i]) / aRange[i] / point; aRatio_2[i] = ( aHigh[i] - aClose[i]) / aRange[i] / point; //---- Set a pair's grade and inverse grade aLookup_1[i] = iLookup( aRatio_1[i] * 100 ); aLookup_2[i] = iLookup( aRatio_2[i] * 100 ); } //---- Calculate and normalize all values to display in graph for ( j = 0; j < numberOfCurrencies; j++ ) { aMeter[j] = 0; m = 0; for ( k = 0; k < numberOfPairs; k++ ) { if ( StringFind(aPair[k], aCurrency[j], 0) == 0 ) { aMeter[j] += aLookup_1[k]; m++; } if ( StringFind(aPair[k], aCurrency[j], 0) == 3 ) { aMeter[j] += aLookup_2[k]; m++; } } aMeter[j] = NormalizeDouble(aMeter[j]/m,1); } //---- Show values without smoothing if (barshift == startbar || applySmoothing == FALSE) { if ( numberOfCurrencies >= 1 ) Buffer_0[barshift] = aMeter[0]; if ( numberOfCurrencies >= 2 ) Buffer_1[barshift] = aMeter[1]; if ( numberOfCurrencies >= 3 ) Buffer_2[barshift] = aMeter[2]; if ( numberOfCurrencies >= 4 ) Buffer_3[barshift] = aMeter[3]; if ( numberOfCurrencies >= 5 ) Buffer_4[barshift] = aMeter[4]; if ( numberOfCurrencies >= 6 ) Buffer_5[barshift] = aMeter[5]; if ( numberOfCurrencies >= 7 ) Buffer_6[barshift] = aMeter[6]; if ( numberOfCurrencies >= 8 ) Buffer_7[barshift] = aMeter[7]; } //---- Show values with smoothing else { if ( numberOfCurrencies >= 1 ) Buffer_0[barshift] = (Buffer_0[barshift + 1] * (smoothingPeriod-1) + aMeter[0]) / smoothingPeriod; if ( numberOfCurrencies >= 2 ) Buffer_1[barshift] = (Buffer_1[barshift + 1] * (smoothingPeriod-1) + aMeter[1]) / smoothingPeriod; if ( numberOfCurrencies >= 3 ) Buffer_2[barshift] = (Buffer_2[barshift + 1] * (smoothingPeriod-1) + aMeter[2]) / smoothingPeriod; if ( numberOfCurrencies >= 4 ) Buffer_3[barshift] = (Buffer_3[barshift + 1] * (smoothingPeriod-1) + aMeter[3]) / smoothingPeriod; if ( numberOfCurrencies >= 5 ) Buffer_4[barshift] = (Buffer_4[barshift + 1] * (smoothingPeriod-1) + aMeter[4]) / smoothingPeriod; if ( numberOfCurrencies >= 6 ) Buffer_5[barshift] = (Buffer_5[barshift + 1] * (smoothingPeriod-1) + aMeter[5]) / smoothingPeriod; if ( numberOfCurrencies >= 7 ) Buffer_6[barshift] = (Buffer_6[barshift + 1] * (smoothingPeriod-1) + aMeter[6]) / smoothingPeriod; if ( numberOfCurrencies >= 8 ) Buffer_7[barshift] = (Buffer_7[barshift + 1] * (smoothingPeriod-1) + aMeter[7]) / smoothingPeriod; } return(0); } //-------------------------------------------------------------------------------------------------------------- //---- This function will return a grade value for a pair based on its power int iLookup(double ratio) { //---- Grade table for currency's power int aTable[10] = {0,3,10,25,40,50,60,75,90,97}; int index; if (ratio <= aTable[0]) index = 0; else if (ratio < aTable[1]) index = 0; else if (ratio < aTable[2]) index = 1; else if (ratio < aTable[3]) index = 2; else if (ratio < aTable[4]) index = 3; else if (ratio < aTable[5]) index = 4; else if (ratio < aTable[6]) index = 5; else if (ratio < aTable[7]) index = 6; else if (ratio < aTable[8]) index = 7; else if (ratio < aTable[9]) index = 8; else index = 9; return(index); } //-------------------------------------------------------------------------------------------------------------- //---- Create the objects that serve as legend for the indicator buffers void createLegendObjects(string name, int xcoor, int ycoor, string text, int fsize, string ftype, color fcolor) { //---- Variable used to determine this window's index. Required for painting legend objects in correct window int wIndex = WindowFind("Price Meter System™ ©GPL -"); ObjectCreate(name,OBJ_LABEL,wIndex,0,0); ObjectSet(name,OBJPROP_CORNER,0); ObjectSet(name,OBJPROP_XDISTANCE,xcoor); ObjectSet(name,OBJPROP_YDISTANCE,ycoor); ObjectSetText(name,text,fsize,ftype,fcolor); return(0); } //-------------------------------------------------------------------------------------------------------------- void deleteLegendObjects() { ObjectDelete("objTextBuffer_0"); ObjectDelete("objTextBuffer_1"); ObjectDelete("objTextBuffer_2"); ObjectDelete("objTextBuffer_3"); ObjectDelete("objTextBuffer_4"); ObjectDelete("objTextBuffer_5"); ObjectDelete("objTextBuffer_6"); ObjectDelete("objTextBuffer_7"); return(0); } //-------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: