I'm trying to take an array of 28 pairs and color the text by each pairs assigned base color while it continually sorts, you can see where I made a sad attempt
- Bulk Operations - Trade - MetaTrader 5 for Android
- Merging changes - Projects and MQL5 Storage
- Bulk Operations - Trade - MetaTrader 5 for iPhone
I need this so I can see as the base pairs begin to group up, all of one color will begin to converge in one area of the sort, hope this makes sense.
xclr8tr
I need this so I can see as the base pairs begin to group up, all of one color will begin to converge in one area of the sort, hope this makes sense.
xclr8tr
This is what it looks like now, most of the code for this is not mine
This is what it looks like with my code added, pretty sad
There currently should be a full list of pairs with 4 different color combinations, eventually more color combos to cover the currency bases
//----------------------------------------------------------------------------- // Mn Volatility Meter | //----------------------------------------------------------------------------- #property copyright "Mn" #property indicator_chart_window extern int mDelay = 5, // Seconds delay before update mHours = 1, mSensitivity = 50; // to adjust bar length of left hand set extern color mTextCol = Yellow, mColB2 = CornflowerBlue, // colour of RH > 50% bars mColB = Plum; // colour of RH < 50% bars extern bool mAutoSort = true, mYesterdayClose = false; int mTextSize = 8; color mCol1 = Gold, mCol2 = Maroon; color mPairs1Col = Green, mPairs2Col = Red, mPairs3Col = Violet, mPairs4Col = Yellow; string mPairs1[7] = {"EURUSD", "GBPUSD", "AUDUSD", "AUDJPY", "EURJPY", "GBPJPY", "EURGBP"}; string mPairs2[7] = {"EURAUD", "EURNZD", "EURCAD", "EURCHF", "USDJPY", "NZDUSD", "GBPCHF"}; string mPairs3[7] = {"CADJPY", "USDCAD", "AUDNZD", "AUDCHF", "USDCHF", "AUDCAD", "CADCHF"}; string mPairs4[7] = {"CHFJPY", "GBPAUD", "GBPCAD", "GBPNZD", "NZDCAD", "NZDCHF", "NZDJPY"}; string mPairs[28] = {"EURUSD", "GBPUSD", "AUDUSD", "AUDJPY", "EURJPY", "GBPJPY", "EURGBP", "EURAUD", "EURNZD", "EURCAD", "EURCHF", "USDJPY", "NZDUSD", "GBPCHF", "CADJPY", "USDCAD", "AUDNZD", "AUDCHF", "USDCHF", "AUDCAD", "CADCHF", "CHFJPY", "GBPAUD", "GBPCAD", "GBPNZD", "NZDCAD", "NZDCHF", "NZDJPY"}; double mData[28][4], mTop, mBot; double mData1[7][1]; double mData2[7][1]; double mData3[7][1]; double mData4[7][1]; int mBrs, m1; //----------------------------------------------------------------------------- void init() { return(0); } //----------------------------------------------------------------------------- void deinit() { string mObj; for(int i = ObjectsTotal() - 1; i >= 0; i--) { mObj = ObjectName(i); if(StringSubstr(mObj, 0, 2) == "m.") ObjectDelete(mObj); } Comment(""); return(0); } //----------------------------------------------------------------------------- void start() { static int mTime, mStart, mBar; double mLen1pcnt, mLen1pcntB, mPrLength, mPrLengthB, mDayH, mDayL, mMove; mTop = WindowPriceMax(0); mBot = WindowPriceMin(0); mBrs = WindowBarsPerChart(); CreateObjs(); if(TimeCurrent() > mTime + mDelay) { for(int m = 0; m < 28; m++) { if(mYesterdayClose) mStart = iTime(NULL, 1440, 0); else mStart = iTime(NULL, 1, 0) - mHours * 3600; mBar = iBarShift(mPairs[m], 5, mStart); mData[m][0] = (iClose(mPairs[m], 1, 0) - iClose(mPairs[m], 5, mBar)) / iClose(mPairs[m], 5, mBar) * 100; mData[m][1] = m; mData[m][2] = iClose(mPairs[m], 5, 0); mDayH = iHigh(mPairs[m], 1440, 0); mDayL = iLow(mPairs[m], 1440, 0); mData[m][3] = ((iClose(mPairs[m], 5, 0) - mDayL) / (mDayH - mDayL)) * 100; } if(mAutoSort) ArraySort(mData, WHOLE_ARRAY, 0, MODE_DESCEND); for(int i = 0; i < 28; i++) { int mPipFact = 1; int mPrNo = mData[i][1]; int mDig = MarketInfo(mPairs[mPrNo], 12); double mPnt = MarketInfo(mPairs[mPrNo], 11); if(mDig == 3 || mDig == 5) mPipFact = 10; mLen1pcnt = (Time[m1] - Time[mBrs]) / 100; mLen1pcntB = (Time[0] - Time[m1-10]) / 100; mPrLength = NormalizeDouble(mLen1pcnt * MathAbs(mData[i][0] * mSensitivity), 0); mPrLengthB = NormalizeDouble(mLen1pcntB * (MathAbs(mData[i][3])), 0); ObjectSet("m.Rect"+i, OBJPROP_TIME2, Time[m1] - mPrLength); ObjectSet("m.RectB"+i, OBJPROP_TIME2, Time[m1-10] + mPrLengthB); ObjectSetText("m.Data"+i, DoubleToStr(mData[i][0], 2) + "%", mTextSize, "Arial", mTextCol); ObjectSet("m.Data"+i, OBJPROP_TIME1, Time[m1+3] - mPrLength - (240 * Period())); ObjectSetText("m.DataB"+i, DoubleToStr(mData[i][3], 0) + "%", mTextSize, "Arial", mTextCol); ObjectSet("m.DataB"+i, OBJPROP_TIME1, Time[m1-10] + mPrLengthB + (240 * Period())); if(mData[i][3] < 50) ObjectSet("m.RectB"+i, OBJPROP_COLOR, mColB); else ObjectSet("m.RectB"+i, OBJPROP_COLOR, mColB2); /*int mPair = mData[i][1]; ObjectSetText("m.Pr"+i, mPairs[mPair], mTextSize, "Arial Bold", mPairs1Col);*/ int mPair1 = mData[i][1]; ObjectSetText("m.Pr1"+i, mPairs1[mPair1], mTextSize, "Arial Bold", mPairs1Col); int mPair2 = mData[i][1]; ObjectSetText("m.Pr2"+i, mPairs2[mPair2], mTextSize, "Arial Bold", mPairs2Col); int mPair3 = mData[i][1]; ObjectSetText("m.Pr3"+i, mPairs3[mPair3], mTextSize, "Arial Bold", mPairs3Col); int mPair4 = mData[i][1]; ObjectSetText("m.Pr4"+i, mPairs4[mPair4], mTextSize, "Arial Bold", mPairs4Col); ObjectSetText("m.Cl"+i, DoubleToStr(mData[i][2], MathMin(4, mDig)), mTextSize, "Arial",mTextCol); double mMov = (iClose(mPairs[mPrNo], 1, 0) - iClose(mPairs[mPrNo], 5, mBar)) / mPnt / mPipFact; ObjectSetText("m.Pips"+i, DoubleToStr(mMov, MathMin(1, mDig)) + " Pips", mTextSize, "Arial", mTextCol); ChngBarCol((mData[i][0] * 100), i); } // for i mTime = TimeCurrent(); } return(0); } //----------------------------------------------------------------------------- void CreateObjs() { double mDepth = (mTop - mBot) / 56, mT, mT2; for(int i = 0; i < 28; i++) { m1 = mBrs / 2; mT = mTop - (mDepth * i * 2); mT2 = mT - mDepth; if(ObjectFind("m.Pr"+i) < 0) ObjectCreate("m.Pr"+i, OBJ_TEXT, 0, 0, 0, 0, 0); ObjectSet("m.Pr"+i, OBJPROP_TIME1, Time[m1 - 5]); ObjectSet("m.Pr"+i, OBJPROP_PRICE1, mT); if(ObjectFind("m.Data"+i) < 0) { ObjectCreate("m.Data"+i, OBJ_TEXT, 0, 0, 0, 0, 0); ObjectSet("m.Data"+i, OBJPROP_TIME1, Time[m1]); } ObjectSet("m.Data"+i, OBJPROP_PRICE1, mT); if(ObjectFind("m.DataB"+i) < 0) { ObjectCreate("m.DataB"+i, OBJ_TEXT, 0, 0, 0, 0, 0); } ObjectSet("m.DataB"+i, OBJPROP_PRICE1, mT); if(ObjectFind("m.Cl"+i) < 0) ObjectCreate("m.Cl"+i, OBJ_TEXT, 0, 0, 0, 0, 0); ObjectSet("m.Cl"+i, OBJPROP_TIME1, Time[mBrs - 7]); ObjectSet("m.Cl"+i, OBJPROP_PRICE1, mT); if(ObjectFind("m.Rect"+i) < 0) { ObjectCreate("m.Rect"+i, OBJ_RECTANGLE, 0, 0, 0, 0, 0); // ObjectSet("m.Rect"+i, OBJPROP_TIME2, Time[m1 + 5]); } ObjectSet("m.Rect"+i, OBJPROP_TIME1, Time[m1]); ObjectSet("m.Rect"+i, OBJPROP_PRICE1, mT); ObjectSet("m.Rect"+i, OBJPROP_PRICE2, mT2); ObjectSet("m.Rect"+i, OBJPROP_BACK, true); if(ObjectFind("m.RectB"+i) < 0) { ObjectCreate("m.RectB"+i, OBJ_RECTANGLE, 0, 0, 0, 0, 0); // ObjectSet("m.RectB"+i, OBJPROP_TIME2, Time[m1 - 20]); } ObjectSet("m.RectB"+i, OBJPROP_TIME1, Time[m1 - 10]); ObjectSet("m.RectB"+i, OBJPROP_PRICE1, mT); ObjectSet("m.RectB"+i, OBJPROP_PRICE2, mT2); ObjectSet("m.RectB"+i, OBJPROP_BACK, true); } // for i return(0); } //----------------------------------------------------------------------------- void ChngBarCol(double mVal, int mBx) { if(mVal >= 0 && mVal < 10) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, White); if(mVal > 10 && mVal < 20) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, LightCyan); if(mVal > 20 && mVal < 30) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, PowderBlue); if(mVal > 30 && mVal < 40) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, PaleTurquoise); if(mVal > 40 && mVal < 50) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, LightBlue); if(mVal > 50 && mVal < 60) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, SkyBlue); if(mVal > 60 && mVal < 70) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Turquoise); if(mVal > 70 && mVal < 80) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, DeepSkyBlue); if(mVal > 80 && mVal < 90) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, SteelBlue); if(mVal > 90 && mVal < 100) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Blue); if(mVal > 100 && mVal < 110) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MediumBlue); if(mVal > 110 && mVal < 120) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MediumBlue); if(mVal > 120 && mVal < 130) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MediumBlue); if(mVal > 130 && mVal < 140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MediumBlue); if(mVal > 140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MediumBlue); if(mVal < 0 && mVal > -10) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, White); if(mVal < -10 && mVal > -20) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Seashell); if(mVal < -20 && mVal > -30) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MistyRose); if(mVal < -30 && mVal > -40) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Pink); if(mVal < -40 && mVal > -50) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, LightPink); if(mVal < -50 && mVal > -60) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Plum); if(mVal < -60 && mVal >-70) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Violet); if(mVal < -70 && mVal > -80) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Orchid); if(mVal < -80 && mVal > -90) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, DeepPink); if(mVal < -90 && mVal > -100) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -100 && mVal > -110) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -110 && mVal > -120) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -120 && mVal > -130) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -130 && mVal > -140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); return(0); } //-----------------------------------------------------------------------------
Sorry having a hard time navigating this forum, above is what the state of the current code which makes for the sad indicator above.
xclr8tr
if(mVal < -140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red);
Supposed filter will always set color red if mVal< -140, since it is the last line it will always be red if mVal < -140.
it will override all previous <> lines and set to clr red, any value of mVal < -140 will turn out clr red.
it should be on top.
if(mVal < -140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < 0 && mVal > -10) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, White); if(mVal < -10 && mVal > -20) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Seashell); if(mVal < -20 && mVal > -30) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, MistyRose); if(mVal < -30 && mVal > -40) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Pink); if(mVal < -40 && mVal > -50) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, LightPink); if(mVal < -50 && mVal > -60) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Plum); if(mVal < -60 && mVal >-70) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Violet); if(mVal < -70 && mVal > -80) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Orchid); if(mVal < -80 && mVal > -90) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, DeepPink); if(mVal < -90 && mVal > -100) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -100 && mVal > -110) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -110 && mVal > -120) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -120 && mVal > -130) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); if(mVal < -130 && mVal > -140) ObjectSet("m.Rect"+mBx, OBJPROP_COLOR, Red); return(0); }
Supposed filter will always set color red if mVal< -140, since it is the last line it will always be red if mVal < -140.
it will override all previous <> lines and set to clr red, any value of mVal < -140 will turn out clr red.
it should be on top.
Hi Marco,
I checked it and that only affects the bars to the left of the symbol. I need to actually change the symbol colors.
xclr8tr
Hi Marco,
I checked it and that only affects the bars to the left of the symbol. I need to actually change the symbol colors.
xclr8tr
string mPairs1[7] = {"USDCHF", "USDJPY", "USDCAD", "EURUSD", "GBPUSD", "AUDUSD", "NZDUSD"}; string mPairs2[7] = {"EURUSD", "EURGBP", "EURCHF", "EURJPY", "EURCAD", "EURAUD", "EURNZD"}; string mPairs3[7] = {"CHFJPY", "USDCHF", "EURCHF", "GBPCHF", "CADCHF", "AUDCHF", "NZDCHF"}; string mPairs4[7] = {"AUDUSD", "AUDJPY", "AUDCHF", "AUDCAD", "AUDNZD", "EURAUD", "GBPAUD"}; string mPairs5[7] = {"USDJPY", "EURJPY", "GBPJPY", "CHFJPY", "CADJPY", "AUDJPY", "NZDJPY"}; string mPairs6[7] = {"GBPUSD", "GBPCHF", "GBPJPY", "GBPCAD", "GBPAUD", "GBPNZD", "EURGBP"}; string mPairs7[7] = {"CADCHF", "CADJPY", "USDCAD", "EURCAD", "GBPCAD", "AUDCAD", "NZDCAD"}; string mPairs8[7] = {"NZDUSD", "NZDCHF", "NZDJPY", "NZDCAD", "EURNZD", "GBPNZD", "AUDNZD"}; string mPairs[56] = {"USDCHF", "USDJPY", "USDCAD", "EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", I need to take this array and give it a color for each group as seen above here. ObjectSetText only allows 1 color per array I think??? "EURUSD", "EURGBP", "EURCHF", "EURJPY", "EURCAD", "EURAUD", "EURNZD", "CHFJPY", "USDCHF", "EURCHF", "GBPCHF", "CADCHF", "AUDCHF", "NZDCHF", "AUDUSD", "AUDJPY", "AUDCHF", "AUDCAD", "AUDNZD", "EURAUD", "GBPAUD", "USDJPY", "EURJPY", "GBPJPY", "CHFJPY", "CADJPY", "AUDJPY", "NZDJPY", "GBPUSD", "GBPCHF", "GBPJPY", "GBPCAD", "GBPAUD", "GBPNZD", "EURGBP", "CADCHF", "CADJPY", "USDCAD", "EURCAD", "GBPCAD", "AUDCAD", "NZDCAD", "NZDUSD", "NZDCHF", "NZDJPY", "NZDCAD", "EURNZD", "GBPNZD", "AUDNZD"}; mPairs1 = color Gray, mPairs2 = color Blue, mPairs3 = color Aqua, mPairs4 = color Violet, mPairs5 = color Yellow, mPairs6 = color Red, mPairs7 = color Green, mPairs8 = color Orange; double mData[56][4], mTop, mBot; Please help, this is my fourth day of working on this and I can't go on much longer, I just don't understand this part of it.
xclr8tr:
int mPair = mData[i][1];
ObjectSetText("m.Pr"+i, mPairs1[mPair], mTextSize, "Arial Bold", Red);
If I use this I get the picture below but that is only 1 of 8 color groups, There should be a total of 56 pairs with 8 color group sorting with the data
I am wondering why exactly it is needed to use a two dimensional array style when one of the indexes is only 1 place "wide".
double mData1[7][1]; double mData2[7][1]; double mData3[7][1]; double mData4[7][1];
since arrays, by default, are already 1 dimensional, at least as far as I remember.
I am wondering why exactly it is needed to use a two dimensional array style when one of the indexes is only 1 place "wide".
since arrays, by default, are already 1 dimensional, at least as far as I remember.
I was experimenting, anything to get it to work, i'll remove them.
It doesn't make any difference though, I'm just not doing something right or maybe its not possible, I've never seen it done...
Thanks
xclr8tr
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use