//+------------------------------------------------------------------+ //| AllPivots_v5.2 600+.mq4 | //| Copyright © 2018, TrendLaboratory | //| http://finance.groups.yahoo.com/group/TrendLaboratory | //| E-mail: igorad2003@yahoo.co.uk | //+------------------------------------------------------------------+ #property copyright "Copyright © 2018, TrendLaboratory" #property link "http://finance.groups.yahoo.com/group/TrendLaboratory" #property link "http://newdigital-world.com/forum.php" #property description "Before using, please read the manual carefully http://newdigital-world.com/trading-tools/1649-allpivots-2.html#post4562" #property indicator_chart_window #property strict enum ENUM_TIMEFRAME { Current = 0, // Current M1 = 1, // M1 M5 = 5, // M5 M15 = 15, // M15 M30 = 30, // M30 H1 = 60, // H1 H4 = 240, // H4 D1 = 1440, // D1 W1 = 10080, // W1 MN1 = 43200, // MN1 YR1 = 525600 // YR1 }; enum ENUM_PIVOTS { floor_piv, // Floor (BasePrice=Previous Typical) camarilla, // Camarilla (BasePrice=Previous Close) demark, // Demark's Pivots fibo_rel, // Fibo relative or Avg Range Levels fibo_abs, // Fibo absolute(in pips) woodie, // Woodie's Pivots(BasePrice=Previous Weighted Open) dots // DOTS Method Levels(BasePrice=Current Open) }; enum ENUM_RANGE { hilo_r, // High/Low Range updn_r, // UpRange=High-BasePrice, DnRange=BasePrice-Low close_r // Range=Close-Close[1] }; enum ENUM_BASEPRICE { close, // Previous Close open, // Current Open curmedian, // Current Median high, // Previous High low, // Previous Low median, // Previous Median typical, // Previous Typical wclose, // Previous Weighted Close wopen // Previous Weighted Open }; enum ENUM_DESCPLACE { off, // off left, // on the left middle, // in the middle right // on the right }; //---- input parameters input string set1 = ""; //==== Main settings: ==== input ENUM_TIMEFRAME TimeFrame = D1; //TimeFrame input string UniqueName = "Floor"; //Unique Name input int Length = 1; //Length in periods(eg. 2= 2 days) input ENUM_PIVOTS PivotMode = floor_piv; //Pivot Mode input string PivotValues = "0;1;2;3;4"; //Pivot values(ratios) input ENUM_BASEPRICE BasePrice = typical; //Base Price input int BaseHourShift = 0; //Base Hour Shift(eg.0-start of the day) input bool ShowMedians = false; //Show Medians input ENUM_RANGE RangeMode = hilo_r; //Range Mode input int AvgPeriod = 1; //Range Avg Period input int SessionStartHour = 0; //Session Start Hour(eg. 9 for DAX,0-for Forex) input int SessionEndHour = 0; //Session End Hour(eg. 22 for DAX,0-for Forex) input int NumberOfDigits = 4; //Number of digits after decimal point input string set2 = ""; //==== Visual settings: ==== input bool ShowGradientColor = true; //Show Gradient Colors input color MainPivotColor = clrWhite; //Main Pivot Color input int MainPivotWidth = 2; //Main Pivot Width input color UpperLevelColor = clrYellowGreen; //Upper Level Color input color LowerLevelColor = clrFireBrick; //Lower Level Color input ENUM_LINE_STYLE LineStyle = STYLE_SOLID; //Line Style input int LineWidth = 1; //Line Width input ENUM_LINE_STYLE MedianStyle = STYLE_DOT; //Median Style input int MedianWidth = 0; //Median Width input bool ShowPivotValues = false; //Show Pivot Values input string FontName = "Arial"; //Font Name input int FontSize = 8; //Font Size input ENUM_DESCPLACE DescriptionPlace = left; //Description Place input bool ShowComment = false; //Show Comments input bool ShowPeriodSeparators = true; //Show Period Separators input color PeriodSeparatorsColor = clrGray; //Period Separators Color //---- indicator buffers double pp[], r1[], r2[], r3[], r4[], r5[], r6[], s1[], s2[], s3[], s4[], s5[], s6[]; int fcnt, TF, shift, pivotshift[], size, upLineR, upLineG, upLineB, dnLineR, dnLineG, dnLineB, ppLineR, ppLineG, ppLineB, counter, digits, prev_width, prev_first; bool firstTime; datetime pivottime[], prevTime, sstart, send, time1, time2; double point, ratios[], P, R[], S[], pivotprice[], uprange[], dnrange[], prevhigh[], prevlow[], open[], prevclose[], prevopen[], high[], low[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { firstTime = true; IndicatorBuffers(13); SetIndexBuffer( 0,pp); SetIndexStyle(0,DRAW_NONE); SetIndexBuffer( 1,r1); SetIndexBuffer( 2,r2); SetIndexBuffer( 3,r3); SetIndexBuffer( 4,r4); SetIndexBuffer( 5,r5); SetIndexBuffer( 6,r6); SetIndexBuffer( 7,s1); SetIndexBuffer( 8,s2); SetIndexBuffer( 9,s3); SetIndexBuffer(10,s4); SetIndexBuffer(11,s5); SetIndexBuffer(12,s6); TF = TimeFrame; size = StrToDoubleArray(PivotValues,ratios,";"); switch(PivotMode) { case 1: size = 7; break; case 2: size = 2; break; case 5: size = 5; break; case 6: size = 5; break; } ArrayResize(R,size); ArrayResize(S,size); colorToRGB(UpperLevelColor,upLineR,upLineG,upLineB); colorToRGB(LowerLevelColor,dnLineR,dnLineG,dnLineB); colorToRGB(MainPivotColor ,ppLineR,ppLineG,ppLineB); if(NumberOfDigits == 4) point = Point*MathPow(10,Digits%2); else point = Point; digits = countDigits(point); SymbolInfoSessionTrade(Symbol(),4,0,sstart,send); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Comment(""); ObjectsDeleteAll(0,UniqueName); ChartRedraw(); } //+------------------------------------------------------------------+ //| AllPivots_v5.0 600+ | //+------------------------------------------------------------------+ int start() { int limit = 0, arraysize, anchor = 0, upColor1, upColor2, upColor3, dnColor1, dnColor2, dnColor3, counted_bars = IndicatorCounted(); double x, coeff, mr, ms; datetime tftime[], currentTime, starthour, desctime = 0, mtfTime; string ratio0, ratioR, ratioS, rname, sname; if(TF == YR1) mtfTime = StrToTime((string)Year() + ".01.01") + BaseHourShift*3600; else mtfTime = iTime(NULL,TF,0) + BaseHourShift*3600; currentTime = TimeCurrent(); int width_inbars = ChartWidthInBars(0); int first_bar = ChartFirstVisibleBar(0); if(first_bar < 0 || width_inbars < 0) return(0); if((currentTime > mtfTime && mtfTime > prevTime)|| width_inbars != prev_width || first_bar != prev_first || firstTime) { ObjectsDeleteAll(0,UniqueName); if(TF == YR1 || TF == MN1 || TF == W1 || TF == D1) { int i = 0; int cnt = 0; while(i <= Bars - 2 && cnt < Length+AvgPeriod) { bool d1_condition = false; if(TimeDay(Time[i]) != TimeDay(Time[i+1])) { if(TimeDayOfWeek(Time[i]) < 2) { if(TimeDayOfWeek(Time[i+1]) == 5 || TimeDayOfWeek(Time[i+1]) == 4) d1_condition = true; } else d1_condition = true; } if((TF == YR1 && (TimeYear(Time[i]) != TimeYear(Time[i+1])||(i == 0 && TimeMonth(Time[i]) == 12 && TimeYear(Time[i]) != TimeYear(TimeCurrent()))))|| (TF == MN1 && TimeMonth(Time[i]) != TimeMonth(Time[i+1]))|| (TF == W1 && TimeDayOfWeek(Time[i]) < TimeDayOfWeek(Time[i+1]))|| (TF == D1 && d1_condition)) { ArrayResize(tftime,cnt+1); tftime[cnt] = Time[i]; cnt++; } i++; } } if(TF >= D1) arraysize = ArraySize(tftime); else arraysize = Length + AvgPeriod; ArrayResize(pivottime ,arraysize); ArrayResize(pivotshift,arraysize); ArrayResize(pivotprice,arraysize); ArrayResize(open ,arraysize); ArrayResize(high ,arraysize); ArrayResize(low ,arraysize); ArrayResize(prevhigh ,arraysize); ArrayResize(prevlow ,arraysize); ArrayResize(prevclose ,arraysize); ArrayResize(prevopen ,arraysize); ArrayResize(pivotprice,arraysize); ArrayResize(uprange ,arraysize); ArrayResize(dnrange ,arraysize); for(shift=0;shift= D1) { starthour = tftime[shift] + SessionStartHour*3600; pivottime[shift] = (datetime)(starthour + BaseHourShift*3600); } else { starthour = iTime(NULL,TF,shift) + SessionStartHour*3600; pivottime[shift] = Time[iBarShift(NULL,0,starthour) - BaseHourShift*60/Period()]; } pivotshift[shift] = iBarShift(NULL,0,(datetime)pivottime[shift],false); if(ShowPeriodSeparators && shift < Length) { PlotLine(UniqueName+" "+EnumToString(TimeFrame)+"["+(string)shift+"]",(datetime)pivottime[shift],0,(datetime)pivottime[shift],100,PeriodSeparatorsColor,0,2,true,false); } } for(shift=0;shift prevopen[shift]) x = 2*prevhigh[shift] + prevlow[shift] + prevclose[shift]; else x = prevhigh[shift] + prevlow[shift] + 2*prevclose[shift]; pivotprice[shift] = x/4; } else pivotprice[shift] = basePrice(BasePrice,open[shift],high[shift],low[shift],prevopen[shift],prevhigh[shift],prevlow[shift],prevclose[shift]); } for(shift=0;shift=0;shift--) { double upR1 = 0, dnR1 = 0, upRavg = 0, dnRavg = 0; for(int i=0;i= 10080) time2 = tftime[shift] + TF*60 + SessionEndHour*3600; else time2 = iTime(NULL,TF,shift) + SessionEndHour*3600; } } else time2 = (datetime)pivottime[shift-1]; int weeks = 0; switch(DescriptionPlace) { case 0: desctime = 0; break; case 1: desctime = time1; if(time1 < Time[first_bar] && time2 > Time[first_bar]) desctime = MathMax(time1,Time[first_bar]); anchor = ANCHOR_LEFT_UPPER; break; case 2: if(shift == 0 || (shift > 0 && time1 < Time[first_bar])) { desctime = (time1 + time2)/2; if(time1 < Time[first_bar]) { desctime = Time[first_bar]; while(iBarShift(NULL,0,desctime) > first_bar - width_inbars/2 && desctime < Time[0] && !IsStopped()) { desctime += Period()*60; if(desctime > Time[0]) desctime = Time[0]; } if(desctime > Time[(iBarShift(NULL,0,Time[first_bar]) + iBarShift(NULL,0,time2))/2]) desctime = Time[(iBarShift(NULL,0,Time[first_bar]) + iBarShift(NULL,0,time2))/2]; } else if(time1 >= Time[first_bar] && desctime > (Time[0] + (width_inbars - first_bar)*Period()*60)) { desctime = (time1 + (Time[0] + (width_inbars - first_bar)*Period()*60))/2; } if(desctime > time2) desctime = (MathMax(time1,Time[first_bar]) + MathMin(time2,desctime))/2; } else desctime = time1 + 30*Period()*(iBarShift(NULL,0,time1) - iBarShift(NULL,0,time2)); anchor = ANCHOR_UPPER; break; case 3: desctime = Time[0] + (width_inbars - first_bar)*Period()*60; if(time1 < Time[first_bar] || time2 > desctime) { if(first_bar - width_inbars < 0) desctime = MathMin(time2,desctime); else desctime = MathMax(time1,Time[first_bar-width_inbars]); if(desctime > time2) desctime = time2; } else desctime = time2; anchor = ANCHOR_RIGHT_UPPER; break; } for(int i=0;i= 0) R[i] = NormalizeDouble( 2*P - prevlow[shift] ,digits); if(i >= 2 && findInArray(ratios,i) >= 0) R[i] = NormalizeDouble((i - 1)*P + (prevhigh[shift] - (i - 1)*prevlow[shift]),digits); break; case 1: if(prevlow[shift] == 0) continue; if(i == 1 && findInArray(ratios,1) >= 0) R[i] = NormalizeDouble(P + upRavg*1.1/12,digits); if(i == 2 && findInArray(ratios,2) >= 0) R[i] = NormalizeDouble(P + upRavg*1.1/6 ,digits); if(i == 3 && findInArray(ratios,3) >= 0) R[i] = NormalizeDouble(P + upRavg*1.1/4 ,digits); if(i == 4 && findInArray(ratios,4) >= 0) R[i] = NormalizeDouble(P + upRavg*1.1/2 ,digits); if(i == 5 && findInArray(ratios,5) >= 0) R[i] = NormalizeDouble((prevhigh[shift]/prevlow[shift]*prevclose[shift] + (P + upRavg*1.1/2))/2,digits); if(i == 6 && findInArray(ratios,6) >= 0) R[i] = NormalizeDouble( prevhigh[shift]/prevlow[shift]*prevclose[shift],digits); break; case 2: if(i == 1 && findInArray(ratios,1) >= 0) R[i] = NormalizeDouble(2*P - prevlow[shift],digits); break; case 3: if(ratios[i] > 0) R[i] = NormalizeDouble(P + ratios[i]*upRavg,digits); break; case 4: if(ratios[i] > 0) R[i] = NormalizeDouble(P + ratios[i]*point,digits); break; case 5: if(i == 1 && findInArray(ratios,1) >= 0) R[i] = NormalizeDouble(2*P - prevlow[shift] ,digits); if(i == 2 && findInArray(ratios,2) >= 0) R[i] = NormalizeDouble( P + ( prevhigh[shift] - prevlow[shift]),digits); if(i == 3 && findInArray(ratios,3) >= 0) R[i] = NormalizeDouble(2*P + ( prevhigh[shift] - 2*prevlow[shift]),digits); if(i == 4 && findInArray(ratios,4) >= 0) R[i] = NormalizeDouble(2*P + (2*prevhigh[shift] - 3*prevlow[shift]),digits); break; case 6: if(upRavg >= uprange[shift]) { if(i == 1 && findInArray(ratios,1) >= 0) R[i] = NormalizeDouble(P + 0.250*uprange[shift],digits); if(i == 2 && findInArray(ratios,2) >= 0) R[i] = NormalizeDouble(P + 0.500*uprange[shift],digits); if(i == 3 && findInArray(ratios,3) >= 0) R[i] = NormalizeDouble(P + 0.700*uprange[shift],digits); if(i == 4 && findInArray(ratios,4) >= 0) R[i] = NormalizeDouble(P - 0.068*uprange[shift],digits); } else { if(i == 1 && findInArray(ratios,1) >= 0) R[i] = NormalizeDouble(P + 0.120*uprange[shift],digits); if(i == 2 && findInArray(ratios,2) >= 0) R[i] = NormalizeDouble(P + 0.250*uprange[shift],digits); if(i == 3 && findInArray(ratios,3) >= 0) R[i] = NormalizeDouble(P + 0.330*uprange[shift],digits); if(i == 4 && findInArray(ratios,4) >= 0) R[i] = NormalizeDouble(P - 0.03264*uprange[shift],digits); } break; } if(i == 0) { P = NormalizeDouble(pivotprice[shift],digits); if(findInArray(ratios,0) >= 0) { R[i] = P; if(ShowPivotValues) ratio0 = "("+DoubleToStr(ratios[0],3)+")"; else ratio0 = ""; PlotLine(UniqueName+" PP["+(string)shift+"]",time1,P,time2,P,MainPivotColor,MainPivotWidth,LineStyle,false,false); if(desctime > 0) PlotText(UniqueName+" value PP["+(string)shift+"]","PP "+DoubleToStr(P,digits)+" "+EnumToString(TimeFrame)+ratio0,desctime,P,FontSize,FontName,0,MainPivotColor,anchor,false); } continue; } upColor1 = (int)(upLineR + coeff*(ppLineR - upLineR)); upColor2 = (int)(upLineG + coeff*(ppLineG - upLineG)); upColor3 = (int)(upLineB + coeff*(ppLineB - upLineB)); if(ShowPivotValues) ratioR = "("+DoubleToStr(ratios[i],3)+")"; else ratioR = ""; if(i > 0 && R[i] > 0) { if(PivotMode == 1) rname = "H"+(string)i; else if(PivotMode == 6) { if(i == 1) rname = "Buy"; if(i == 2) rname = "BT1"; if(i == 3) rname = "BT2"; if(i == 4) rname = "BSL"; } else rname = "R"+(string)i; PlotLine(UniqueName+" "+rname+"["+(string)shift+"]",time1,R[i],time2,R[i],rgbToColor(upColor1,upColor2,upColor3),LineWidth,LineStyle,false,false); if(desctime > 0) PlotText(UniqueName+" value "+rname+"["+(string)shift+"]",rname+" "+DoubleToStr(R[i],digits)+" "+EnumToString(TimeFrame)+ratioR,desctime,R[i],FontSize,FontName,0,rgbToColor(upColor1,upColor2,upColor3),anchor,false); } if(ShowMedians && i > 0 && R[i] > 0) { if(i == 1) mr = (R[i] + P)/2; else mr = (R[i] + R[i-1])/2; PlotLine(UniqueName+" m"+rname+"["+(string)shift+"]",time1,mr,time2,mr,rgbToColor(upColor1,upColor2,upColor3),MedianWidth,MedianStyle,false,false); if(desctime > 0) PlotText(UniqueName+" value m"+rname+"["+(string)shift+"]","m"+rname+(string)(i-1)+" "+DoubleToStr(mr,digits)+" "+EnumToString(TimeFrame),desctime,mr,FontSize,FontName,0,rgbToColor(upColor1,upColor2,upColor3),anchor,false); } //---- Supports switch(PivotMode) { case 0: if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble( 2*P - prevhigh[shift] ,digits); if(i >= 2 && findInArray(ratios,i) >= 0) S[i] = NormalizeDouble((i - 1)*P - ((i - 1)*prevhigh[shift] - prevlow[shift]),digits); break; case 1: if(prevlow[shift] == 0) continue; if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble(P - dnRavg*1.1/12,digits); if(i == 2 && findInArray(ratios,2) >= 0) S[i] = NormalizeDouble(P - dnRavg*1.1/6 ,digits); if(i == 3 && findInArray(ratios,3) >= 0) S[i] = NormalizeDouble(P - dnRavg*1.1/4 ,digits); if(i == 4 && findInArray(ratios,4) >= 0) S[i] = NormalizeDouble(P - dnRavg*1.1/2 ,digits); if(i == 5 && findInArray(ratios,5) >= 0) S[i] = NormalizeDouble((2*prevclose[shift] - prevhigh[shift]/prevlow[shift]*prevclose[shift] + (P - dnRavg*1.1/2))/2,digits); if(i == 6 && findInArray(ratios,6) >= 0) S[i] = NormalizeDouble( 2*prevclose[shift] - R[6],digits); break; case 2: if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble(2*P - prevhigh[shift],digits); break; case 3: if(ratios[i] > 0) S[i] = NormalizeDouble(P - ratios[i]*dnRavg,digits); break; case 4: if(ratios[i] > 0) S[i] = NormalizeDouble(P - ratios[i]*point,digits); break; case 5: if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble(2*P - prevhigh[shift] ,digits); if(i == 2 && findInArray(ratios,2) >= 0) S[i] = NormalizeDouble( P - ( prevhigh[shift] - prevlow[shift]),digits); if(i == 3 && findInArray(ratios,3) >= 0) S[i] = NormalizeDouble(2*P - (2*prevhigh[shift] - prevlow[shift]),digits); if(i == 4 && findInArray(ratios,4) >= 0) S[i] = NormalizeDouble(2*P - (3*prevhigh[shift] - 2*prevlow[shift]),digits); break; case 6: if(dnRavg >= dnrange[shift]) { if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble(P - 0.250*dnrange[shift],digits); if(i == 2 && findInArray(ratios,2) >= 0) S[i] = NormalizeDouble(P - 0.500*dnrange[shift],digits); if(i == 3 && findInArray(ratios,3) >= 0) S[i] = NormalizeDouble(P - 0.700*dnrange[shift],digits); if(i == 4 && findInArray(ratios,4) >= 0) S[i] = NormalizeDouble(P + 0.068*dnrange[shift],digits); } else { if(i == 1 && findInArray(ratios,1) >= 0) S[i] = NormalizeDouble(P - 0.120*dnrange[shift] ,digits); if(i == 2 && findInArray(ratios,2) >= 0) S[i] = NormalizeDouble(P - 0.250*dnrange[shift] ,digits); if(i == 3 && findInArray(ratios,3) >= 0) S[i] = NormalizeDouble(P - 0.330*dnrange[shift] ,digits); if(i == 4 && findInArray(ratios,4) >= 0) S[i] = NormalizeDouble(P + 0.03264*dnrange[shift],digits); } break; } dnColor1 = (int)(dnLineR + coeff*(ppLineR - dnLineR)); dnColor2 = (int)(dnLineG + coeff*(ppLineG - dnLineG)); dnColor3 = (int)(dnLineB + coeff*(ppLineB - dnLineB)); if(ShowPivotValues) ratioS = "(-"+DoubleToStr(ratios[i],3)+")"; else ratioS = ""; if(S[i] > 0) { if(PivotMode == 1) sname = "L" + (string)i; else if(PivotMode == 6) { if(i == 1) sname = "Sell"; if(i == 2) sname = "ST1"; if(i == 3) sname = "ST2"; if(i == 4) sname = "SSL"; } else sname = "S" + (string)i; PlotLine(UniqueName+" "+sname+"["+(string)shift+"]",time1,S[i],time2,S[i],rgbToColor(dnColor1,dnColor2,dnColor3),LineWidth,LineStyle,false,false); if(desctime > 0) PlotText(UniqueName+" value "+sname+"["+(string)shift+"]",sname+" "+DoubleToStr(S[i],digits)+" "+EnumToString(TimeFrame)+ratioS,desctime,S[i],FontSize,FontName,0,rgbToColor(dnColor1,dnColor2,dnColor3),anchor,false); } if(ShowMedians && i > 0 && S[i] > 0) { if(i == 1) ms = (S[i] + P)/2; else ms = (S[i] + S[i-1])/2; PlotLine(UniqueName+" m"+sname+"["+(string)shift+"]",time1,ms,time2,ms,rgbToColor(dnColor1,dnColor2,dnColor3),MedianWidth,MedianStyle,false,false); if(desctime > 0) PlotText(UniqueName+" value m"+sname+"["+(string)shift+"]","m"+sname+(string)(i-1)+" "+DoubleToStr(ms,digits)+" "+EnumToString(TimeFrame),desctime,ms,FontSize,FontName,0,rgbToColor(dnColor1,dnColor2,dnColor3),anchor,false); } } if(shift == 0 && ShowComment) Comment("\n\n","Average: upRange = ",upRavg/point," dnRange =",dnRavg/point); } if(currentTime > mtfTime) prevTime = mtfTime; else prevTime = mtfTime - 1; firstTime = false; prev_first = first_bar; prev_width = width_inbars; } //----- int bar = 0; for(int i=0;i z1 + 1) a[i] = StrToNumber(StringSubstr(str,z1 + 1,z2 - z1 - 1)); if(z2 >= StringLen(str) - 1) break; z1 = z2; } return(strcnt); } string StringRight(string str, int n=1) //+------------------------------------------------------------------+ // Returns the rightmost N characters of STR, if N is positive // Usage: string x=StringRight("ABCDEFG",2) returns x = "FG" // // Returns all but the leftmost N characters of STR, if N is negative // Usage: string x=StringRight("ABCDEFG",-2) returns x = "CDEFG" { if (n > 0) return(StringSubstr(str,StringLen(str) - n,n)); if (n < 0) return(StringSubstr(str,-n,StringLen(str) - n)); return(""); } double StrToNumber(string str) //+------------------------------------------------------------------+ // Usage: strips all non-numeric characters out of a string, to return a numeric (double) value // valid numeric characters are digits 0,1,2,3,4,5,6,7,8,9, decimal point (.) and minus sign (-) // Example: StrToNumber("the balance is $-34,567.98") returns the numeric value -34567.98 { int dp = -1; int sgn = 1; double snum = 0.0; for (int i=0; i= "0" && s <= "9") { if (dp >= 0) dp++; if (dp > 0) snum = snum + StrToInteger(s)/MathPow(10,dp); else snum = snum*10 + StrToInteger(s); } } return(snum*sgn); } int StringFindCount(string str, string str2) //+------------------------------------------------------------------+ // Returns the number of occurrences of STR2 in STR // Usage: int x = StringFindCount("ABCDEFGHIJKABACABB","AB") returns x = 3 { int c = 0; for (int i=0; i>8)&0x000000FF; clrB = (clr>>16)&0x000000FF; } double basePrice(int mode,double o,double h, double l,double prevo,double prevh, double prevl,double prevc) { switch(mode) { case 0: return(prevc); case 1: return(o); case 2: return((h+l)/2); case 3: return(prevh); case 4: return(prevl); case 5: return((prevh+prevl)/2); case 6: return((prevh+prevl+prevc)/3); case 7: return((prevh+prevl+2*prevc)/4); case 8: return((prevh+prevl+2*o)/4); } return(0); } double findInArray(double& array[],double value) { for(int i=0;i