Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 827

 
alexeymosc:

Hello! I don't understand why an error is coming up when declaring an array outside of functions.

Error: '[' - invalid index value

How do I declare a two-dimensional non-dynamic array with variables as indexes?

I tried setting const instead of static. I also tried [][]. Still an error (

Poke a tutorial where to look up this question once and for all, please.

Because despite the sequence of assigning values to variables, they remain uninitialized until the program is run. So, until you run int Oninit(), the variable you use is not initialized. Move this line to Oninit() and everything should work...
 

I have a simple code that does not open orders.

In my log it says: '1419717': order buy 0.01 EURUSD opening at market sl: 1.13720 tp: 1.13842 failed [Invalid S/L or T/P].

Here (on the forum) I got a tip: "Stops and Takei should be normalized!

I do not understand what this phrase means?

The compiler doesn't generate any errors or warnings. During testing everything works. I just don't know where and what to read anymore.

If this is too long to explain, please send me the link where I can read about how to normalize stoploss and takeprofit.

Thanks in advance.

double Lots=0.01;
double TakeProfit=100;
double StopLoss=10;
int tk=0;

void start()
{
   if (OrdersTotal()==0)
      {
         tk=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,0,0,0,Green);
         if(tk<0) 
         {
            Print("OrderSend завершилась с ошибкой #",GetLastError());
         }
         else         
         {
            Print("Функция OrderSend успешно выполнена");
         }
      }
}
 
AlexeyVik:
Because despite the sequence of assigning values to variables, they remain uninitialized until the program starts. That is, until you run int Oninit(), the variable you use as the array's dimension is not initialized. Move this line to Oninit() and everything should work...

AlexeyVik, thank you!

That's what I'll do. I didn't think about Oninit, but I guess it's true.

 

Please give me a hint ))))

There is some amount of graphical objects on the chart.

A new bar has finished forming. What is the easiest way to determine if it has touched any object?

(I do not want to search for prices of all objects and compare if the price range of the latest bar has touched any of them).

In other words, the price and date range how to determine if there is any graphic object in these coordinates.

 
favidu:

I have a simple code that does not open orders.

In my log it says: '1419717': order buy 0.01 EURUSD opening at market sl: 1.13720 tp: 1.13842 failed [Invalid S/L or T/P].

Here (on the forum) I got a tip: "Stops and Takei should be normalized!

I do not understand what this phrase means?

The compiler doesn't generate any errors or warnings. During testing everything works. I just don't know where and what to read anymore.

If this is too long to explain, please send me the link where I can read about how to normalize stoploss and takeprofit.

Thank you in advance.

NormalizeDouble() dig in the reference book. But if your broker does not allow you to expose stops at the time of opening a market order, you should enter them in zeros and expose them separately, at the second step. There are examples in the kodobase.


tk=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,NormalizeDouble(Bid-StopLoss*Point,_Digits),NormalizeDouble(Ask+TakeProfit*Point,_Digits),0,0,0,Green);
 
evillive:

NormalizeDouble() dig into the reference. But if the broker doesn't allow you to place stops at the time of opening a market order, you should enter them in zeros and place them separately, at the second step. There are examples in the kodobase.


Thank you very much.
 

Guys, push me in the right direction...

For example:

#property strict
#property indicator_chart_window
#property indicator_buffers             0

int init() {

        return(0);
}

int start() {
        if (!GlobalVariableCheck(StringConcatenate("ID_", Symbol()))) {
                long id = ChartID();
                Print (id);
                GlobalVariableSet(StringConcatenate("ID_", Symbol()), id);
        }
        return(0);
}

It never saves what it prints...

Something like this:

Result

CHANDNT?

 
Well, as soon as I posted that, the server went to 404 =)
 

Temporarily wrote high bits separately low bits separately.

It seems that a global variable of type double does not fit long.

Although it says here that there should be no problem except for situations where"if an integer is greater than 9223372036836854774784 or less than -9223372036854774784".

But agree, the chart ID = 130659893770676840 is less than 9223372036854774784 by a full digit at least.


P.S. If anyone can explain my mistake or is it a glitch, thanks in advance. I'll keep checking back here.

 

Please advise

How can I save the results of EA test in mt4? Into a folder or in HTML format too)?

Reason: