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

 
Stepan241 >> :

I am trying to write an indicator. The idea is simple: we're going to average (strength of bulls - strength of bears). Naturally, for a certain period of time.



int start()
{
int i=Bars-IndicatorCounted()-1;
while(i>=0)
{
Bears_array[i]=iBearsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);
Bulls_array[i]=iBullsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);
MA_Bears[i]=iMAOnArray(Bears_array,0,MA_Period,0,MODE_EMA,i);
MA_Bulls[i]=iMAOnArray(Bulls_array,100,MA_Period,0,MODE_SMA,i);
Buf_0[i]=MA_Bulls[i];
i--;
}
return;
}

I display only smoothed bulls Buf_0[i]=MA_Bears[i]; it is done to control at a certain stage of index plotting. Not even EXACTLY. If I smooth them with a period of 1, they in fact must repeat embedded bulls. Hence, I concluded that something is wrong in the line MA_Bulls[i]=iMAOnArray(Bulls_array,100,MA_Period,0,MODE_SMA,i); I don't understand what exactly...HELP me!!!! It's been 3 days of looking through manuals and documentation. THANK YOU!


First, form the data arrays of bulls and bears and then iron them with the next cycle, but you have not formed it yet and already applied smoothing, there is no data what to smooth?

 
Urain писал(а) >>

First form the data arrays of bulls and bears and then use the next cycle to iron them, because you haven't formed it yet and are already using smoothing, and there is no data to smooth?

Translation from

int start()
{
  int i, limit=Bars-IndicatorCounted()-1;
  for ( i= limit; i>=0; i--){
    Bears_array[ i]=iBearsPower(NULL,0, PeriodPower,PRICE_CLOSE, i);
    Bulls_array[ i]=iBullsPower(NULL,0, PeriodPower,PRICE_CLOSE, i);
  }
  for ( i= limit; i>=0; i--){
    MA_Bears[ i]=iMAOnArray( Bears_array,0, MA_Period,0,MODE_EMA, i); 
    MA_Bulls[ i]=iMAOnArray( Bulls_array,100, MA_Period,0,MODE_SMA, i); 
  }
  return;
}
 

costy_ писал(а) >>

extern string xxxxxxxxxxxxx="x=0 сегодня х=1 вчера итд";
extern int х=0;
int середина=(iHigh(0,PERIOD_D1, х)-iLow(0,PERIOD_D1, х))/2;
if(Bid> середина)...;
if(Ask< середина)...;


extern datetime some_time=D'14:56';
int середина_some_time=(iHigh(0,0,iBarShift(0,0, some_time))-iLow(0,0,iBarShift(0,0, some_time)))/2;
if(Bid> середина_some_time)...;
if(Ask< середина_some_time)...;

Thank you very much, I'm getting closer. One point is not quite clear.

'14:56' - date literal string is incomplete this is the warning I got from the computer.

As far as I understand, it still wants the date, but I don't need a specific date. What I need is to compare the current price every day with the price at a certain time on the same day. Please clarify the point.

 
alsu >> :

Why do you need to call them through iCast at all? Is it for unification? Write a separate indicator-wrapper for each of them and call them through iCustom...

The problem is, I've changed these two indicators (AO and AC) and now I want bars to be coloured according to modified indicators. Or is there any other way to do it? I just started MQL recently...

 
Necron >> :

The problem is that I have redone the two indicators (AO and AC), and now I want the bars to be coloured according to the modified indicators. Or is there any other way to do it? I just started to learn MQL recently...

So, what you have redone and call it, what's the problem? For example, if the modified indicators are called AO, AC, the call will be

iCustom(0,0,"AO",0,shift);
iCustom(0,0,"AС",0,shift);

or you can add your own parameters

 
future >> :

Thank you very much, I'm getting closer. One point is not quite clear.

'14:56' - date literal string is incomplete this is the warning I got from the computer.

As far as I understand, it still wants the date, but I don't need a specific date. What I need is to compare the current price every day with the price at a certain time on the same day. Please clarify the point.


string час="15";
string мин="15";
datetime some_time=D'Year().Month().Day() час:мин';//попробуй так ____ но на тестере не будет работать, так как текущие год месяц и день 
привяжитесь к барам так проще вместо iBarShift(0,0, some_time) номер бара
 

costy_ писал(а) >>

future >>:

Thank you very much, I'm getting closer

.

One point is not quite clear.

'14:56' - date literal string is incomplete - this is the warning I got from the computer.

I understand it still wants the date, but I don't need a specific date, I need to compare the current price every day with the price of a certain time of the same day

.

Please clarify the point.


string час="15";
string мин="15";
datetime some_time=D'Year().Month().Day() час:мин';//попробуй так ____ но на тестере не будет работать, так как текущие год месяц и день 
привяжитесь к барам так проще вместо iBarShift(0,0, some_time) номер бара

However, I want to know if it is possible to maintain the binding to a certain time. In MQL4, how do you say the Bid price at 14.00 of each trading day?

 

skifodessa 05.12.2009 14:07


Good afternoon all.

Please tell me how to calculate the number of crossings of price of a certain level. I want my order to open after 3 (4,5...), but not after the first crossing.

Thank you.
------------------------------------------------------------

You could try the algorithm


If (Price of current bar>leveland price of previous bar<level)then {counter increment by one}

If (counter>3) then {open order; reset counter to zero}

Now let us write the same in the usual language (I am writing only blocks. You can insert them in the necessary places)

Extern int Chet=10; // after how many crossings to open the order

Extern double Uroven=1.6566; // after the price has crossed which level to start counting.

In the start function, the conditions will be approximately as follows

int k;

if(Open[0]>Uroven && Open[1]<Uroven)k=k+1;// here we consider an UP crossing

if(k>Chet){OrderSend(.......);k=0};

In general, the question is not very difficult. The book on MCL explains the basics of ALGORITHMICS

 

FOR Vinin wrote >>.

Thanks for the tip, but it won't help. Because you've just replaced the While loop with a FOR loop.

FOR Urain wrote(a) >>

The next two lines are just forming the right array.

Bears_array[i]=iBearsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);
Bulls_array[i]=iBullsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);

Urain You must have thought that the iMAOnArray function should pass an array that has already been formed. Forming it with the FOR loop didn't help. Because it's not the array you pass to this function (iMAOnArray), but its NAME. And the array is processed PERSONALLY.

by changing i in the string MA_Bears[i]=iMAOnArray(Bears_array,0,MA_Period,0,MODE_SMA,i);

I've solved the problem. It is much deeper than it seems. If you apply this processing only in the Expert Advisor, there are no problems, but if you build a chart using it, you will get a hitch anyway. The point is that the arrays are indexed inversely. The function iMAOnArray has direct (left to right) indexing, while the chart is indexed from right to left. Thanks to Garfich for this explanation.



 
Stepan241 >> :

FOR Vinin wrote >>.

Thanks for the tip, but it won't help. Because you've just replaced the While loop with a FOR loop.

FOR Urain wrote(a) >>

The next two lines are just forming the right array.

Bears_array[i]=iBearsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);
Bulls_array[i]=iBullsPower(NULL,0,PeriodPower,PRICE_CLOSE,i);

Urain You must have thought that the iMAOnArray function should pass an array that has already been formed. Forming it with the FOR loop didn't help. Because it's not the array you pass to this function (iMAOnArray), but its NAME. And the array is processed BEYOND.

by changing i in the string MA_Bears[i]=iMAOnArray(Bears_array,0,MA_Period,0,MODE_SMA,i);

I've solved the problem. It is much deeper than it seems. If you apply this processing only in the Expert Advisor, there are no problems, but if you use it to build a chart, you will get a hitch anyway. The point is that the arrays are indexed inversely. The function iMAOnArray has direct (left to right) indexing, while the chart is indexed from right to left. Thanks to Garfich for this explanation.

I don't know what the problem was, but Vinin wrote it correctly (it doesn't matter for or while), the main thing is that first the loop forms an array of data and then the next loop forms an iMA from it,

and the string Bears_array[i]=iBearsPower(NULL,0,PeriodPower,PRICE_CLOSE,i); fills only one i-th value of the array

without a loop, the array will not be generated.

Reason: