Errors, bugs, questions - page 1974

 

Compilation error

class B {};
class A {
template<typename T> void f() const {} //1
template<typename T> void f()       {} //2
        void g() const { f<B>(); } //error: 'f<B>' - call non-const method for constant object
};
And if you swap lines (1) and (2), it's fine. What's the difference?
 

Execution error

class B {};
struct A {
template<typename T> void f()       { Print( __FUNCSIG__ ); } //2
template<typename T> void f() const { Print( __FUNCSIG__ ); } //1
        void g()       { f<B>(); }
};
void OnStart()
{
        A a;
        a.g();
}
As a result, method const (1) is called instead of const (2). If you swap lines (1) and (2) (but not indices), it is not const - as expected
 

Hello! Can you tell me why a simple condition is not fulfilled?

if ( Bid > High[iHighest(Symbol(),0,MODE_HIGH,30,1)] )

The error log doesn't show up. I've written Comment(Bid); and noticed that when Bid becomes higher than High[...], its commenting stops.

And condition of this kind is fulfilled:

if ( Bid > High[10] )
 
giros:

Hi, Can you tell me why the simplest condition is not fulfilled:

The error log doesn't show up. Prescribed Comment(Bid); and noticed that when Bid becomes more than High[...], its commenting stops.

And the condition of this kind is fulfilled:


Please attach the whole code, there are no errors in what you have shown...

 
Vladimir Pastushak:

Attach the whole code, there are no errors in what you've shown...

I simplified the code as much as possible to find the error, the error is exactly in the line of comparison condition Bid > High[...].
Here is the whole code, and even it is not executed, you can copy and check it:

void OnTick()
  {
   if ( Bid > High[iHighest(Symbol(),0,MODE_HIGH,20,1)] )
      {int Buy = OrderSend(Symbol(),OP_BUY,1,Ask,30,0,0,NULL,12345,0,clrBlue);}
  }
 
giros:

I simplified the code as much as possible to find the error, the error is exactly in the line of comparison condition Bid > High[...].
Here is all code, and even it is not executed, you can copy and check it:


And what result do you expect ?

 
giros:

I have simplified the code to find the error. The error is in the line of comparison condition Bid > High[...].
Here is the whole code, and even it is not executed, you can copy and check it:


Your condition sounds like this

If the bid price will be higher than the biggest high of the last 20 candles excluding the zero bar. And then open orders without stopping.


If your current bid price is lower than the biggest high, no action...

 
Vladimir Pastushak:

What result are you waiting for?

Specifically in this case I'm waiting for a buy order to be opened.

Generally I am waiting for the operator {...} to be executed.

 
giros:

Specifically in this case I am waiting for a buy order to be opened.

In general case I am waiting for - execution of operator {...}.


Read your condition carefully

 
giros:

Specifically in this case I am waiting - for a buy order to open.

In general case I am waiting for operator {...}.


I have your condition working clearly, orders are opening...

Reason: