Hi
I want to be able to evaluate the close value of a candle to see if it matches another variable.
For example, let’s say the close value of a candle is 12,347.0 and I have a level called sup1 at 12,347.8 that I care about. How can I match these to decimal points?
I don’t want to just ROUND the Close and sup1 (which in this case wouldn’t work as 12,347 would not match 12,348) Even if ROUND did get close, I want to evaluate the decimal points.
If Close = sup1+0.1 OR Close = sup1+0.2 OR Close = Sup1+0.3 …….. OR close = sup1-0.1 OR close = Sup1-0.2 OR Close = Sup1-0.3 ……. THEN DRAWHLINE(sup1)coloured(0,200,0)
I’m struggling to get the comparison working.
Thanks
Rob
Any pointers from anyone please?
Thanks
Rob
Thos will allow you to validate CLOSE as “touching the line” when it is within a 0.3-pip range below or above it:
IF close >= Sup1 - (0.3 * pipsize) AND close <= Sup1 + (0.3 * pipsize) THEN....
You can create a function-like indicator, like this one (I also attach the .ITF file to be imported), which needs to be installed by ProBuilder but shouldn’t added to charts, just kept within ProBuilder itself to be called by strategies:
//////////////////////////////////////////////////////////////////////////////////////////////
// MyRange
//
// indicator to be installed with ProBuilder and be called by strategies
//
// input:
// x = number to be checked against a range
// y = base to define a range (+/- z)
// z = range within which x will be validated or not
//
// returns:
// 0 = x is NOT within range z
// 1 = x is within above said range
//
IF x >= (y - z) AND x <= (y + z) THEN
Result = 1 //X is within range y-z through y+z
ELSE
Result = 0 //X is not within the above said range
ENDIF
RETURN Result
//////////////////////////////////////////////////////////////////////////////////////////////
This is a stupid strategy just to test it:
//////////////////////////////////////////////////////////////////////////////////////////////
// MyStrategy
//
x = close
y = close + (0.3 * pipsize)
z = 0.5 * pipsize
a = CALL MyRange[x,y,z] // true
//
x1 = close
y1 = close - (0.6 * pipsize)
z1 = 0.5 * pipsize
a1 = CALL MyRange[x1,y1,z1] //false
//
x2 = close
y2 = close + (0.9 * pipsize)
z2 = 0.5 * pipsize
a2 = CALL MyRange[x2,y2,z2] //false
//
GRAPH a
GRAPH a1
GRAPH a2
buy at -close limit
If you want to verify whether CLOSE is within +- 0.5 pips from the HIGHEST high of the previous 10 bars you may write:
condition = CALL MyRange[close,highest[10](high[1]),0.5 * pipsize]
Thanks Robert,
I will be working on this later!
Many thanks Roberto, your first answer has turned out to be the simplest in this case.
Thanks again, Robert