Having periodic problems with my codes at times ,the code below doesnt work correctly, can someone help me out i am trying to detect if a candle is bearish or not

 

Having periodic problems with my codes at times ,the code below doesnt work correctly, can someone help me out i am trying to detect if a candle is bearish or not

Code:

bool isBearish(int index)
  {
   if(tradingTimePrices[index].open<tradingTimePrices[index].close)
      return true;
   return false;
  }

 
kudston:

Having periodic problems with my codes at times ,the code below doesnt work correctly, can someone help me out i am trying to detect if a candle is bearish or not

Code:


Check that the Array tradingTimePrices if filled correctly, neither empty (<_Point) nor with random numbers.
 
kudston:

Having periodic problems with my codes at times ,the code below doesnt work correctly, can someone help me out i am trying to detect if a candle is bearish or not

Code:


Where/when does it not work like an example, the code is looking okay
 
kudston #:

Please, insert code correctly: when editing a post, click   Code and paste your code in the popup window (the first time I edited your post and inserted the code correctly)
 
Vladimir Karputov #:
Please, insert code correctly: when editing a post, click    and paste your code in the popup window (the first time I edited your post and inserted the code correctly)
thanks
 
  1. Your code
    bool isBearish(int index)
      {
       if(tradingTimePrices[index].open<tradingTimePrices[index].close)
          return true;
       return false;
      }
    Simplified
    bool isBearish(int index)
      {
       return tradingTimePrices[index].open<tradingTimePrices[index].close;
      }
              Increase Order after stoploss - MQL4 programming forum #1.3 (2017)

  2.       case 2:
             if(opens[index]<closes[index]) return true;
             break;
          case 1:
             if(opens[index] < closes[index]) return true;

    No difference between case one and case two.

  3. Where in OnTick to you call isBullish? Where is your new bar test? Where is your new bar test for multiple timeframes?

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

    detecting a new bar without removing ability to detect tick in multiple timeframe - Easy Trading Strategy - MQL4 programming forum #8 (2021.08)

 
William Roeder #:
  1. Your code
    Simplified
              Increase Order after stoploss - MQL4 programming forum #1.3 (2017)

  2. No difference between case one and case two.

  3. Where in OnTick to you call isBullish? Where is your new bar test? Where is your new bar test for multiple timeframes?

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

    detecting a new bar without removing ability to detect tick in multiple timeframe - Easy Trading Strategy - MQL4 programming forum #8 (2021.08)than

    William Roeder #:
    1. Your code
      Simplified
                Increase Order after stoploss - MQL4 programming forum #1.3 (2017)

    2. No difference between case one and case two.

    3. Where in OnTick to you call isBullish? Where is your new bar test? Where is your new bar test for multiple timeframes?

      For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
                MT4: New candle - MQL4 programming forum #3 (2014)
                MT5: Accessing variables - MQL4 programming forum #3 (2022)

      I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
                Running EA once at the start of each bar - MQL4 programming forum (2011)

      detecting a new bar without removing ability to detect tick in multiple timeframe - Easy Trading Strategy - MQL4 programming forum #8 (2021.08)

thanks alot this solved it 

Reason: