Compare Close to +0.1 through to 0.9 and -0.1 through to -0.9 of a variable
Forums › ProRealTime English forum › ProBuilder support › Compare Close to +0.1 through to 0.9 and -0.1 through to -0.9 of a variable
- This topic has 6 replies, 2 voices, and was last updated 6 years ago by robdav.
-
-
04/25/2018 at 3:29 PM #69151
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
05/01/2018 at 9:10 AM #6954305/01/2018 at 9:47 AM #69547Thos will allow you to validate CLOSE as “touching the line” when it is within a 0.3-pip range below or above it:
1IF close >= Sup1 - (0.3 * pipsize) AND close <= Sup1 + (0.3 * pipsize) THEN....1 user thanked author for this post.
05/02/2018 at 10:18 AM #69624You 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:
123456789101112131415161718192021//////////////////////////////////////////////////////////////////////////////////////////////// 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) THENResult = 1 //X is within range y-z through y+zELSEResult = 0 //X is not within the above said rangeENDIFRETURN Result//////////////////////////////////////////////////////////////////////////////////////////////This is a stupid strategy just to test it:
MyStrategy test12345678910111213141516171819202122//////////////////////////////////////////////////////////////////////////////////////////////// MyStrategy//x = closey = close + (0.3 * pipsize)z = 0.5 * pipsizea = CALL MyRange[x,y,z] // true//x1 = closey1 = close - (0.6 * pipsize)z1 = 0.5 * pipsizea1 = CALL MyRange[x1,y1,z1] //false//x2 = closey2 = close + (0.9 * pipsize)z2 = 0.5 * pipsizea2 = CALL MyRange[x2,y2,z2] //false//GRAPH aGRAPH a1GRAPH a2buy at -close limit05/02/2018 at 10:26 AM #6962705/02/2018 at 11:49 AM #6963305/08/2018 at 5:49 PM #70008Many thanks Roberto, your first answer has turned out to be the simplest in this case.
Thanks again, Robert
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on