English

## Help on getting 25% of bar range

 7 traderbino 2014.11.07 00:54   Hello my trading logic requires to check if the close of the bar is equal to 25% of the bar's range. Can somebody check if I am doing it right? below is a snippet of my code ```// For long trade if(iClose(NULL,0,0) >= (0.25 * ( iHigh(NULL,0,0) - iLow(NULL,0,0) ) + iLow(NULL, 0, 0)) // OpenBuyOrder if(iClose(NULL,0,0) <= (0.25 * ( iHigh(NULL,0,0) - iLow(NULL,0,0) ) - iLow(NULL, 0, 0)) // OpenSellOrder ``` Although this is  working okay I just want to get some advice if there's a better way of doing it :)TIA
 1211 deysmacro 2014.11.07 01:43 #   ```// For long trade if(iClose(NULL,0,0) >= (0.25 * ( iHigh(NULL,0,0) - iLow(NULL,0,0) ) + iLow(NULL, 0, 0)) // OpenBuyOrder if(iClose(NULL,0,0) <= (0.25 * ( iHigh(NULL,0,0) - iLow(NULL,0,0) ) - iLow(NULL, 0, 0)) // OpenSellOrder```I think you don't need =
 Moderator3516 GumRai 2014.11.07 01:48 #   You are working with open bars, you do realise that?`if(iClose(NULL,0,0) <= (0.25 * ( iHigh(NULL,0,0) - iLow(NULL,0,0) ) - iLow(NULL, 0, 0)) // OpenSellOrder`  I don't think that this works as it will certainly return a negative valueAlso, as I am not sure exactly what you are trying to do, you may get both a buy and sell order from the same bar
 7 traderbino 2014.11.07 03:41 #   GumRai: You are working with open bars, you do realise that?  I don't think that this works as it will certainly return a negative valueAlso, as I am not sure exactly what you are trying to do, you may get both a buy and sell order from the same bar  Hi @Gumrai basically my signal for a trade is to buy if the close of the previous bullish bar is 25% of the it's range and sell if its a bearish bar. Having said that the code snippet should have been. ```if(iClose(NULL,0,1) >= (0.25 * ( iHigh(NULL,0,1) - iLow(NULL,0,1) ) + iLow(NULL, 0, 1)) // OpenBuyOrder if(iClose(NULL,0,1) <= (0.25 * ( iHigh(NULL,0,1) - iLow(NULL,0,1) ) - iLow(NULL, 0, 1)) // OpenSellOrder```