[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 1129

 

Please explain why nothing is displayed in the indicator window as a result.

Code:

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double Buf_0[];

int init()
{
//---- indicators

SetIndexBuffer(0,Buf_0);
SetIndexStyle(0,DRAW_LINE, STYLE_SOLID,2);
//----
return(0);
}

int start()
{
int i, counted_bars=IndicatorCounted();
i=Bars-counted_bars-1;


while(i>=0)
{
Buf_0[i]=Close[i]/Close[i+1];
i--;
}
return(0);
}
//+------------------------------------------------------------------+

 
Abzasc:
Where ??? is exactly right?


This condition should filter if (up>=1|down>=1), alerts, at least one of them must be greater than zero, but it is not.

Here's

 
Dimka-novitsek:


This condition should filter if (up>=1||down>=1), the alerts, at least one of them, must be greater than zero, but they are not.

Here


int start()
{int y;
y= WindowFirstVisibleBar();Alert ("y",y);
for (y=1; y>=0;y--) // первое выражение 
{ double up=iFractals(Symbol(),PERIOD_M15,MODE_UPPER,y);
double down=iFractals(Symbol(),PERIOD_M15,MODE_LOWER,y);
if (up>=1||down>=1){
Alert("Previous upper fractal is:", up, " Previous lower fractal is:", down);Alert ("y",y);}}

return(0);
}
 
Galion:


You just split the editor window into two parts :) OK, let's forget about the double click. Have you set syntax highlighting for MQL4 files? If no, then after opening a file with MQL-code in the editor you have to press Syntax - and at the very bottom of the list select MQL4 - the highlighting will be exactly the same as in MetaEditor

 
But I don't understand where I'm going wrong?
 
No, but ignoring it or putting y=1 in it doesn't change anything, I checked!
 
Dimka-novitsek:
But I don't understand where I'm going wrong?

Removed the excess.

int start()
{int y;
y= WindowFirstVisibleBar();Alert ("y",y);
// for (y=5;y>=0;y--)
//{ 
double up=iFractals(Symbol(),PERIOD_M15,MODE_UPPER,y);
double down=iFractals(Symbol(),PERIOD_M15,MODE_LOWER,y);
if (up>=1||down>=1){
Alert("Previous upper fractal is:", up, " Previous lower fractal is:", down);Alert ("y",y);}
//}
//----

//----
return(0);
}

and it's like this.

That's it?

 
dzhini:

I probably did not put the question correctly. Trading is done on an hour timeframe and it is unknown when a trade will happen, but it needs to be one during the day. I would like to make this feature switchable. Maybe somebody has such a piece of code?


You don't need to look for a piece of code - you can spend your whole life looking for it and not find anything. You should look for a way to build a code fragment by yourself. The code I gave you is not for stupid copying, but for you to understand it from beginning to end, especially as it is very simple. This is how this code works. It goes through the list of market orders and sums their amount with history orders opened today. If the sum is greater than zero, the orders have already been opened today and trading is not allowed. If you need a switch which allows you to take into account how many orders can be opened today, you can add it to the code with a simple operation. Your problem is that you don't have the algorithm of your program, you don't understand how and in what sequence your program should work. Make up an algorithm, otherwise your head will be a mess.

 
Well, talked to you and immediately understood everything )))) looked tweaked - you were right (I couldn't jump out of my problem solving algorithm). Thanks for all the tips. Now I've figured out all the proposed options: which one works in which cases.
 
dzhini:
Well, talked to you and immediately understood everything )))) looked tweaked - you were right (I couldn't jump out of my problem solving algorithm). Thanks for all the tips. Now I've got all the proposed options figured out: which one works in which cases.

Please note that the order search loops I have shown you don't consider the order master - this is such a characteristic by which the EA can distinguish its own orders from other orders. This is a number which can be assigned to an order when it is opened by an EA - all of its orders have the same number (or, if necessary, different numbers generated automatically). If the trader opens orders manually, the magic number always equals zero! This means that if we add magic = 0 to the EA, the EA will interfere with manual trades of the trader. If you want the EA to leave the trader's orders untouched and manipulate only its own orders, you should set the wizard to a different value than zero. In this case the Expert Advisor will consider all orders that do not have such a magik as someone else's and will not touch them.
Reason: