Hi Jag,
I suppose because 22 is number of working days per month.
Regards,
Igor
Printable View
Thanks Igor. This is resolved now.
Hi igorad! Can you check the mt5 version? It's working but can't get the right values in the buffers. I tried to adjust them in the source code but the indicator keeps all the values to 0.0 all the time(I see it in Data Window). Maybe I'm missing something obvious but seems like I can't put any value in the buffers.
Thanks in advance! :-)
Hi ape_epa,
Please check out the updated AllPivots indicator for MT5 which can be used in EAs.
Attachment 29961
In the EA settings you should add the following piece of code:
Also before the settings you should add the needed ENUMs from the indicator.Code:input string pivotsInputs = "===== AllPivots settings: =====";
input ENUM_TIMEFRAME pivotsTimeFrame = D1; // TimeFrame
input string pivotsUniqueName = "Floor"; // Unique Name
input int pivotsLength = 1; // Length in periods(eg. 2= 2 days)
input ENUM_PIVOTS pivotsMode = floor_piv; // Pivot Mode
input string pivotsValues = "0;1;2;3;4"; // Pivot values(ratios)
input ENUM_BASEPRICE pivotsBasePrice = prevtypical; // Base Price
input int pivotsBaseHourShift = 0; // Base Hour Shift(eg.0-start of the day)
input bool pivotsShowMedians = false; // Show Medians
input ENUM_RANGE pivotsRangeMode = hilo_r; // Range Mode
input int pivotsAvgPeriod = 1; // Avg Period in bars
input int pivotsSessionStartHour = 0; // Session Start Hour(eg. 9 for DAX,0-for Forex)
input int pivotsSessionEndHour = 0; // Session End Hour(eg. 22 for DAX,0-for Forex)
input int pivotsNumberOfDigits = 4; // Number of digits after decimal point
input bool pivotsShowPivots = true; // Show Pivots
input int pivotsEntryMode = 1; // Entry Mode: 0-off,1-r1/s1,2-r2/s2,3-r3/s3
bool ShowGradientColor = true; //Show Gradient Colors
color MainPivotColor = clrWhite; //Main Pivot Color
int MainPivotWidth = 2; //Main Pivot Width
color UpperLevelColor = clrYellowGreen; //Upper Level Color
color LowerLevelColor = clrFireBrick; //Lower Level Color
ENUM_LINE_STYLE LineStyle = STYLE_SOLID; //Line Style
int LineWidth = 1; //Line Width
ENUM_LINE_STYLE MedianStyle = STYLE_DOT; //Median Style
int MedianWidth = 0; //Median Width
bool ShowPivotValues = false; //Show Pivot Values(true/false)
string FontName = "Arial"; //Font Name
int FontSize = 8; //Font Size
ENUM_DESCPLACE DescriptionPlace = left; //Description Place
bool ShowComment = false; //Show Comments
bool ShowPeriodSeparators = true; //Show Period Separators
color PeriodSeparatorsColor = clrGray; //Period Separators Color
In the OnInit() should be added:Code:enum ENUM_TIMEFRAME
{
Current = 0, // Current
M1 = 1, // M1
M2 = 2, // M2
M3 = 3, // M3
M4 = 4, // M4
M5 = 5, // M5
M10 = 10, // M10
M12 = 12, // M12
M15 = 15, // M15
M30 = 30, // M30
H1 = 60, // H1
H2 = 120, // H2
H3 = 180, // H3
H4 = 240, // H4
H6 = 360, // H6
H8 = 480, // H8
H12 = 720, // H12
D1 = 1440, // D1
W1 = 10080, // W1
MN1 = 43200, // MN1
YR1 = 525600 // YR1
};
enum ENUM_PIVOTS
{
off_piv, // Off
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
{
prevclose, // Previous Close
curopen, // Current Open
curmedian, // Current Median
prevhigh, // Previous High
prevlow, // Previous Low
prevmedian, // Previous Median
prevtypical, // Previous Typical
prevwclose, // Previous Weighted Close
prevwopen // Previous Weighted Open
};
enum ENUM_DESCPLACE
{
off, // off
left, // on the left
middle, // in the middle
right // on the right
};
As an example to call the AllPivots you should use the function:Code:if(pivotsMode != off_piv)
{
handle_pivots = iCustom(_Symbol,0,"AllPivots_v5_1","",pivotsTimeFrame,pivotsUniqueName,pivotsLength,pivotsMode-1,pivotsValues,pivotsBasePrice,pivotsBaseHourShift,pivotsShowMedians,pivotsRangeMode,pivotsAvgPeriod,pivotsSessionStartHour,pivotsSessionEndHour,pivotsNumberOfDigits,
"",pivotsShowPivots,ShowGradientColor,MainPivotColor,MainPivotWidth,UpperLevelColor,LowerLevelColor,LineStyle,LineWidth,MedianStyle,MedianWidth,
ShowPivotValues,FontName,FontSize,DescriptionPlace,ShowComment,ShowPeriodSeparators,PeriodSeparatorsColor);
if(handle_pivots == INVALID_HANDLE)
{
if(DebugModeOn) Print("Error in loading of AllPpivots. LastError = ",GetLastError());
return(-1);
}
ArrayResize(pp,1); ArraySetAsSeries(pp,true);
ArrayResize(r1,1); ArraySetAsSeries(r1,true);
ArrayResize(r2,1); ArraySetAsSeries(r2,true);
ArrayResize(r3,1); ArraySetAsSeries(r3,true);
ArrayResize(r4,1); ArraySetAsSeries(r4,true);
ArrayResize(r5,1); ArraySetAsSeries(r5,true);
ArrayResize(r6,1); ArraySetAsSeries(r6,true);
ArrayResize(s1,1); ArraySetAsSeries(s1,true);
ArrayResize(s2,1); ArraySetAsSeries(s2,true);
ArrayResize(s3,1); ArraySetAsSeries(s3,true);
ArrayResize(s4,1); ArraySetAsSeries(s4,true);
ArrayResize(s5,1); ArraySetAsSeries(s5,true);
ArrayResize(s6,1); ArraySetAsSeries(s6,true);
}
Regards,Code:double pp[], r1[], r2[], r3[], r4[], r5[], r6[],
s1[], s2[], s3[], s4[], s5[], s6[];
MqlRates rates[];
int allPivots(int mode)
{
ArraySetAsSeries(rates,true);
int copied = CopyRates(_Symbol,0,0,2,rates);
if(CopyBuffer(handle_pivots, 0,0,1,pp) < 0) return(0);
if(CopyBuffer(handle_pivots, 1,0,1,r1) < 0) return(0);
if(CopyBuffer(handle_pivots, 2,0,1,r2) < 0) return(0);
if(CopyBuffer(handle_pivots, 3,0,1,r3) < 0) return(0);
if(CopyBuffer(handle_pivots, 4,0,1,r4) < 0) return(0);
if(CopyBuffer(handle_pivots, 5,0,1,r5) < 0) return(0);
if(CopyBuffer(handle_pivots, 6,0,1,r6) < 0) return(0);
if(CopyBuffer(handle_pivots, 7,0,1,s1) < 0) return(0);
if(CopyBuffer(handle_pivots, 8,0,1,s2) < 0) return(0);
if(CopyBuffer(handle_pivots, 9,0,1,s3) < 0) return(0);
if(CopyBuffer(handle_pivots,10,0,1,s4) < 0) return(0);
if(CopyBuffer(handle_pivots,11,0,1,s5) < 0) return(0);
if(CopyBuffer(handle_pivots,12,0,1,s6) < 0) return(0);
if(mode == 0) return(0);
switch(mode)
{
case 1: if(rates[0].close < s1[0] && s1[0] > 0) return( mode);
if(rates[0].close > r1[0] && r1[0] > 0) return(-mode);
break;
case 2: if(rates[0].close < s2[0] && s2[0] > 0) return( mode);
if(rates[0].close > r2[0] && r2[0] > 0) return(-mode);
break;
case 3: if(rates[0].close < s3[0] && s3[0] > 0) return( mode);
if(rates[0].close > r3[0] && r3[0] > 0) return(-mode);
break;
}
return(0);
}
Igor
@igorad: thank you for the indicator and for the detailed explanation. The indicator is good and usable in EAs. But I want to know why the buffers still contain zeros in all candles/positions but the first. Since the line is plotted to the chart why the buffers can't be filled accordingly? I still have the buffer with correct values on last bar but the other bars have 0.000000
Sorry to bother you again, but AllPivots mt5 version doesn't work as expected. I can use it flawlessly in live and back tester with visual mode turned on. But if I turn off the visual mode the buffers are empty(of the last candle). Can you try it please and check?
I put a simple Print statement that print the value of pp[0]. In live and in back tester with visual mode turned ON it prints the correct value but in tester with visual mode torned off it prints 0.0.
Not very funny because that way I can't really optimize anything.