Stoploss & Takeprofit lines indicator

 

I've been setting my stoploss and takeprofit based on price volume. So I created this indicator that determines the high and low for some number of bars and uses that spread to place two moving horizontal lines indicating where the stoploss and takeprofit will be if a trade is opened. I think it helps to have a good visualization of where the stoploss and takeprofit will be. It's been working for me -- let me know what you think?

I am also going to create two scripts one to Buy and the other to Sell. The scripts will place the stoploss and take profit at the indicator lines. The scripts will also have automatic money management. Now all I need to do is get the direction right. ; -)

I know I'm giving you my hand slapped because this indicator will only work with a five digit broker.

extern int barsBack = 20; // look back 20 bars

int start()
{
   double theHighest = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, barsBack, 1)); // get the highest price
   double theLowest = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, barsBack, 1)); // get the lowest price
   double highToLow = (theHighest - theLowest) / 2; // find the middle

   if (highToLow < 0.0010) // I'm not willing to trade less than 10 pips
      highToLow = 0.0010; // only good for a five digit broker
   else if (highToLow > 0.0040) // don't like to go over 40 pips
      highToLow = 0.0040;
     
   ObjectCreate("highLine", OBJ_HLINE, 0, Time[1], Bid + 0.002); // draw the high line
   ObjectSet("highLine", OBJPROP_PRICE1, Bid + highToLow);
   ObjectSet("highLine", OBJPROP_COLOR, DarkOrchid);
   ObjectCreate("lowLine", OBJ_HLINE, 0, Time[1], Bid - 0.002); // draw the line
   ObjectSet("lowLine", OBJPROP_PRICE1, Bid - highToLow);
   ObjectSet("lowLine", OBJPROP_COLOR, DarkOrchid);
   return(0);
}
 
MisterDog:

1. I've been setting my stoploss and takeprofit based on price volume.

2. I know I'm giving you my hand slapped because this indicator will only work with a five digit broker.

1. can you explain what you mean by "price volume" ?

2. I think what you have written will work just fine on a 4 digit Broker . . . just don't expect it to work on 2/3 digit pairs . . . e.g. EURJPY

 
RaptorUK:
2. I think what you have written will work just fine on a 4 digit Broker . . . just don't expect it to work on 2/3 digit pairs . . . e.g. EURJPY
Agreed. And easy to fix
// if (highToLow < 0.0010) // I'm not willing to trade less than 10 pips
   double pips10 = 10 * pips2dbl;
   if (highToLow < pips10) // I'm not willing to trade less than 10 pips
 
RaptorUK:

1. can you explain what you mean by "price volume" ?

2. I think what you have written will work just fine on a 4 digit Broker . . . just don't expect it to work on 2/3 digit pairs . . . e.g. EURJPY


Volume? Your right the word "volume" mean something else in trading. I meant to say, looking at some number of bars back (usually 20 bars) I find the difference between the highest and lowest price. Perhaps the right word is "range". The point of this feature is, when the market is making small moves I'm only asking for small profits. But when it's making large moves I'm asking for more from it.
 
MisterDog:

Volume? Your right the word "volume" mean something else in trading. I meant to say, looking at some number of bars back (usually 20 bars) I find the difference between the highest and lowest price. Perhaps the right word is "range". The point of this feature is, when the market is making small moves I'm only asking for small profits. But when it's making large moves I'm asking for more from it.
Great, thank you . . :-) range is a much better word ;-)