Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 356

 
Nauris Zukas:

Thank you, but then I would also have to scale the data (if I understand you correctly). It seems that scaling the data is the only solution.

Why scale anything? Simply use 2 buffers, put positive values in one and negative values in the other. If the calculation produces only positive values, you can multiply them by -1. But if the calculation produces both positive and negative values, then my suggestion does not fit.

Then you could make histograms of different widths. First the buffer which is displayed with a wide histogram is filled with value, and then the one which is displayed with a thin histogram is filled with value.

This will produce a histogram. Four buffers are used here.


 
Alexey Viktorov:

Why scale anything? Simply use 2 buffers, put positive values in one and negative values in the other. If the calculation produces only positive values, you can multiply them by -1. But if the calculation produces both positive and negative values, then my suggestion does not fit.

Then we can make histograms of different widths. The first buffer to be filled with value is that displayed in wide histogram, and then that displayed in thin histogram.

This will produce a histogram. Four buffers are used here.


Thanks, but it will not fit this variant as the buffers with lines will be for example in the range from 1.19653 to 1.19674 and the histogram will be from 0 to 250. Tics and spread in one window, that's why I wanted to make a second Y-axis.

 
Nauris Zukas:

Thank you, but it will not work, because the buffer with lines will be for example in the range from 1.19653 to 1.19674 and the histogram will be from 0 to 250. Tics and spread in one window, that's why I wanted to make a second Y-axis.

I agree, it won't fit. But!!! What would the scaling do? Maybe divide the histogram values by 100? Or multiply by 0.01...

 
Alexey Viktorov:

I agree, it won't fit. But!!! What would the scaling do? How about dividing the histogram values by 100? Or multiply by 0.01...

So far the following concept: we take max/min value from linear buffers and make max spread under these values, other spreads are scaled under max.

 
Artyom Trishkin:

So the broker is not allowing autotrading for your account, since everything is enabled and the EA does not open positions or place orders.

What does the log show when the EA tries to send a trade request to the server?

Orders are placed but IsTradeAllowed() is 0. How can this be?

 
Andrei:

Do you mean allow automatic trading? This is also enabled...

Does it make sense to call the broker's helpdesk

 
Andrei:

Orders are placed but IsTradeAllowed() is 0. How is this possible?


the account is competitive?

There are at least four parameters to check:

ACCOUNT_TRADE_EXPERT
ACCOUNT_TRADE_ALLOWED
TERMINAL_TRADE_ALLOWED
IsTradeAllowed(_Symbol,TimeCurrent())
 

Can you please tell me how to write code to compare current tick with previous tick for selected trade instrument?

I need to compare: if Tick (current) > Tick (previous), then proceed to the execution of such ticks, and vice versa, if Tick (current) < Tick (previous), then proceed to the calculation of ticks2.

Thus, I want to calculate how many ticks in each bar, on the selected chart and timeframe, are increasing the price and how many are decreasing it.

Please advise! I am writing my first training indicator, and my first program in my life :(

Did I make it correct?

int Tick;

int Tick2;

int start()

if((Bid - Bid[1]) > 0)

{

Tick++;

return;

}

else

{

Tick2++;

return;

}

 
YarTrade:

Could you please tell me how to write a code to compare current tick and previous tick for a selected trading instrument?

I need to compare: if Tick (current) > Tick (previous), then proceed to the execution of such ticks, and vice versa, if Tick (current) < Tick (previous), then proceed to the calculation of ticks2.

Thus, I want to calculate how many ticks in each bar, on the selected chart and timeframe, are increasing the price and how many are decreasing it.

Please advise! I am writing my first training indicator, and also my first program in my life :(

Am I making it right?

Try to write Date, Time, Bid and results of your calculations on each tick. Then upload it to Excel and check it. It hardly makes sense to reconcile every dozen lines of the program!

But look, you have return in each branch of conditional operator, i.e. it is always executed. So we take it out of the conditional operator:

int Tick=0, Tick2=0;       // Для вставки программы используйте кнопку SRC
double Bid1;

void OnInit()
{
  Bid1=Bid;
}

void start()   // Вместо start более модно писать OnTick
{
    if(Bid > Bid1) Tick++;                             
    else           Tick2++;
    Bid1=Bid;                          
}

Bid[1] - is it like that?

 
STARIJ:
// Вместо start более модно писать OnTick

:)