[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 198

 
SK. писал(а) >>

Have a look here .

Many thanks SK, Vinin!

A great example for workaraund.

Must have been worth the trouble to get so sophisticated. :-)

Looks like MQL4 knows how to "good" the programmer's time. :-)

 
SK. >> :

Look here .

Thank you, very useful article.

 
stera писал(а) >>

Thank you very much SK, Vinin!

granit77 wrote >>

Thank you, very useful article.

If you are interested in this topic, have a look at this article http://www.forextrade.ru/mqlabs/sozdaniie-indikatora-kaghi

It discusses a lot of details for horizontal lines, and shows the technical solution (alternation).

The vertical lines are also illustrated. But I still haven't understood some of the rules. For example, it is enough to change parity of ind. buffers, as the image wobbles (block 4-5, change numbers of buffers from 6 and 7 to 5 and 6, and to make the 5th one 7m).

 
Question from a beginner. Is it possible to write an EA in mql4 which implies automatic trading with opening and closing at a certain hour regularly? I want to test it. Mostly used rulang, but these ideas are apparently not feasible there.
 

What is the order of the indicators and experts?

I have 2 indicators on one chart.

And in aggregate, their execution time is sometimes much longer than the time between ticks.

Which indicator is executed first?

If they are not executed in parallel, perhaps it is reasonable to place them in different charts, of course, if there is no order of execution in different charts.

Which indicator or Expert Advisor is executed first if they are on the same chart, and if they are on different charts?

 

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i];

It's not working.


Please, tell me what to do. I don't know what to do.

 
Feonix >> :

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i];

It's not working.

Please, tell me what to do. I can't figure it out.

>> What to do? >> Show all code!

 
OneDepo >> :

What to do? Show all the code!

//+------------------------------------------------------------------+

//| Momentum.mq4 |

//| Copyright © 2004, MetaQuotes Software Corp. |

//| http://www.metaquotes.net/ |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2004, MetaQuotes Software Corp.

#property link "http://www.metaquotes.net/"


#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

//---- input parameters

extern int MomPeriod=14;

int ret;

double x[];

//---- buffers

double MomBuffer[];

double ocfor[];

double octen[];

//+------------------------------------------------------------------+

//| Custom indicator initialisation function |

//+------------------------------------------------------------------+

int init()

{

string short_name;

//---- indicator line

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,MomBuffer);

//---- name for DataWindow and indicator subwindow label

short_name="Mom("+MomPeriod+")";

IndicatorShortName(short_name);

SetIndexLabel(0,short_name);

//----

SetIndexDrawBegin(0,MomPeriod);

//----

return(0);

}

//+------------------------------------------------------------------+

//| Momentum |

//+------------------------------------------------------------------+

int start()

{

int i,counted_bars=IndicatorCounted();

//----

if(Bars<=MomPeriod) return(0);

//----

i=Bars;

while(i>=0)

{

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i];

i--;


}

return(0);

}

//+------------------------------------------------------------------+



If you replace Double x[]; with Double x;, everything works, but the point is to assign mombuffer[i]= x[i]

 
Feonix писал(а) >>

//+------------------------------------------------------------------+
//| Momentum.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//---- input parameters

extern int MomPeriod=14;

int ret;
double x[];

//---- buffers
double MomBuffer[];
double ocfor[];
double octen[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+

int init()
{
string short_name;
//---- indicator line
IndicatorBuffers( 2);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, MomBuffer);
SetIndexBuffer(1, x);

//---- name for DataWindow and indicator subwindow label
short_name="Mom("+ MomPeriod+")";
IndicatorShortName( short_name);
SetIndexLabel(0, short_name);

//----
SetIndexDrawBegin(0, MomPeriod);

//----
return(0);

}

//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+

int start()
{
int i, counted_bars=IndicatorCounted();

//----
if(Bars<= MomPeriod) return(0);
//----
i=Bars;

while( i>=0)
{
x[ i]=(Open[ i]-Close[ i]);
MomBuffer[ i]= x[ i];
i--;
}

return(0);
}

//+------------------------------------------------------------------+
You can do this
 
Feonix >> :

.

.

int start()

{

int i,counted_bars=IndicatorCounted();

//----

if(Bars<=MomPeriod) return(0);

//----

i=Bars;


ArrayResize(x, i+1);


while(i>=0)

{

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i];

i--;

}

return(0);

}



If you replace Double x[]; with Double x;, everything works, but the point is to assign mombuffer[i]= x[i].

You declared an array but didn't allocate memory for it.

Vinin gave one way of allocating memory, you can use the second, through the ArrayResize() function

Reason: