Indicator Help
if (counted_bars>0) counted_bars--; limit = Bars - counted_bars; for(int i=limit; i>=0; i--) { int shift1 = i, shift2 = i+Periods; double price1 = Close[shift1], price2 = Close[shift2];
- Contradictory information on IndicatorCounted() - MQL4 forum No need for the decrement. Limit = Bars - 1 - counted_bars.
- You're look back is Periods.Thus you need:
SetIndexDrawBegin(0,Periods);
When counted_bars=0, i=Bars-1 so Close[shift2] = Close[Bars-1+Periods] which is beyond the limit of the arrays.
// if (counted_bars>0) counted_bars--; // look back == Periods if (counted_bars < Periods) counted_bars = Periods; limit = Bars -1 - counted_bars; :
SlopeBuffer[i] = /*rise*/ (price1 - price2) * 10000 / /*run*/ (shift2-shift1);Don't hard code numbers. 10000 will not work on JPY or metals.
SlopeBuffer[i] = /*rise*/ (price1 - price2) /pips2dbl / /*run*/ (shift2-shift1); /////// //++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ OptInitialization(); if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(..., 0,0,...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0) Alert("OrderModify failed: ", GetLastError()); */
WHRoeder:
Don't hard code numbers. 10000 will not work on JPY or metals.
- Contradictory information on IndicatorCounted() - MQL4 forum No need for the decrement. Limit = Bars - 1 - counted_bars.
- You're look back is Periods.Thus you need:
When counted_bars=0, i=Bars-1 so Close[shift2] = Close[Bars-1+Periods] which is beyond the limit of the arrays.
Don't hard code numbers. 10000 will not work on JPY or metals.
Thanks!
dabbler:
WHRoeder:
You're look back is Periods.Thus you need:
ERROR MESSAGE 6:
"You are" <you're> found when possessive "your" expected.
Compilation aborted.
:-)
LOL.
WHRoeder coding too much, good thing he's sharing 'em.
:)
dabbler:
ERROR MESSAGE 6:
"You are" <you're> found when possessive "your" expected.
Compilation aborted.
:-)
WHRoeder:
What kind Black or Irish....
This is spam : https://www.mql5.com/en/forum/139579
COFFEE TO WAKE UP OWL NIGHT LONG
You can have 'em from java.com
Hey guys,
This is my first stab at trying to program an indicator - could someone please verify for me that it is doing what I think it should be doing?
It is supposed to calculate the slope of price over X amount of periods(rise: difference in last close and close X periods ago divided by run: amount of periods) and then display it as a line in a seperate window.
Is the code correct? Thanks