IB indicator counter

 
ib example

Hi

cant seem to make my indicator work

if i have an inside bar , i want the indicator to display on graph the number of times price hits the high and low of the candle before it reaches its target of 1:1 R:R 

atteched is i want it to work and the indicator i tried to write, its a problem with inPosition calculation of course but i dont know what to change

any advice will do

thanks

Files:
 

ignore the first indicator

i meant the "insideqbarnv2.mq4"

 
  1. if (MarketInfo(Symbol() ,Bid > entryBuyStop)
    Perhaps you should read the manual. MarketInfo - Market Info - MQL4 Reference The second argument is one of Symbol Properties - Environment State - Standard Constants, Enumerations and Structures - MQL4 Reference True or False isn't one of them. And if you meant,
    if (MarketInfo(Symbol() ,Bid) > entryBuyStop)
    1.2345 isn't one of them either.

  2. up[i] = Low[i] - iATR(Symbol(),0,500,i)/3;
    Your image shows the top and bottom of the bar and twice that range. What does ATR have to do with it?
  3. Once you find a IB where do you set the count to zero?
  4. Once you find a IB where do you see if the target has been hit?
  5. Once you find a IB where do you count if High > High[IB]
 
WHRoeder:
  1. Perhaps you should read the manual. MarketInfo - Market Info - MQL4 Reference The second argument is one of Symbol Properties - Environment State - Standard Constants, Enumerations and Structures - MQL4 Reference True or False isn't one of them. And if you meant,1.2345 isn't one of them either.

  2. Your image shows the top and bottom of the bar and twice that range. What does ATR have to do with it?
  3. Once you find a IB where do you set the count to zero?
  4. Once you find a IB where do you see if the target has been hit?
  5. Once you find a IB where do you count if High > High[IB]

HI WHRoeder,

thanks for your answer,

such a novice mistake, i did meant the second

1. (MarketInfo(Symbol() ,MODE_BID) > entryBuyStop ) isn't comparable?, isn't MarketInfo returns a double?

2. the ATR is just so when createObject draws it will do it far from the candle, i've found the code somewhere ,guess it isn't necessary

3. I've declared inPosition variable set to zero in the global  declaration sector or should it be in init() function I'm not sure (tried both)

either way  i've set it to zero once the target hits

4. Im saving the target prices in buyTp and sellTp which are the lines of  twice the range

5. line 68, its supposed to : if price   breaks either sell or buy stop inPosition increases by one until it reaches the targets and then it sets to zero again

 if (MarketInfo(Symbol() ,MODE_BID) > entryBuyStop || MarketInfo(Symbol(), MODE_ASK) < entrySellStop) {
                inPosition++;
Files:
 
  1. MarketInfo(Symbol() ,MODE_BID) is the same as the predefined variable Bid. Why use a function call?
  2. Why would you compare the current price, you want to know wether a candle exceeded your stop, not wether the current price does.
 
because there could be a multiplies breaks of the two lines(high and low of the inside bar day) in a single candle
 
ji2gy: because there could be a multiplies breaks of the two lines(high and low of the inside bar day) in a single candle
Not multiple, but many (as in dozens) as price goes through a level. And if you miss ticks, your count will be wrong. But that's not what your image asked for.
 

yes, you're right

i need to count once every time price  breaks a line, until price breaks the other line , or until  the target lines are hit

thanks

Reason: