[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 55

 
mr_Johns:

if((b_mod) && (priceB > Ask)) OrderModify(b_ticket,priceB,priceS,0,0,Brown);
if((s_mod) && (priceS < Bid)) OrderModify(s_ticket,priceS,priceB,0,0,Brown);


Here we should consider MarketInfo(Symbol(),MODE_STOPLEVEL) i.e.

priceB >= Ask+ MarketInfo(Symbol(),MODE_STOPLEVEL)*Point

priceS < =Bid- MarketInfo(Symbol(),MODE_STOPLEVEL)*Point




No. This question was already solved above. The function simply worked during the test on each tick and a new price was not obtained so quickly. But when the price did not change, the error occurred.
 
hoz:

Well, if you pass elements to a function of type double orint, it can also do the same operations, but without any perversions. Why complicate your life?

If a function has a type, it is assumed that the function returns a value of that type.

int test() {
  int res;
  
  // какие-то действия
  
  return(res);
}

Your function does not return anything.

 
hoz:

No. This question has already been solved above. The function simply worked during the test on each tick and the new price was not obtained so quickly. But when the price did not change, the error popped up.

What do you mean no? If the condition

priceB >= Ask+ MarketInfo(Symbol(),MODE_STOPLEVEL)*Point

is not met and priceB >Ask (as in the code)

you will get an error.

In order not to modify the order when the price has not had time to change, we should enter the condition priceB!=OrderOpenPrice()

 
MikeM:
I would writeHour()>=18, and throw out the minutes altogether.
And that's the right thing to do. I used the function for other purposes and mechanically transferred it here.
//---не давать коду советника работать в пятницу с 18-00 по серверному времени 
   if(DayOfWeek()==5 && Hour()>=18){
      
      return(0);  
   } 
 
Can you please advise whether you can write an indicator in which lines will be drawn in one timeframe, and the data for its drawing will be taken from another timeframe? the purpose: to visualize the last bar re-drawing. how to do it?
 
lottamer:
Can you advise whether it is possible to write an indicator that will draw lines in one timeframe, and the data for its drawing will be taken from another timeframe? The purpose: to visualize the re-drawing of the last bar.

It's elementary Watson... In each case, instead of Period() use PERIOD_M15 (the timeframe from which you want to receive data)... And put the indicator on the current chart. I.e., forcibly set the timeframe from which you want to take data.
 
Sepulca:

It's elementary Watson... In each case, instead of Period() use PERIOD_M15 (the timeframe from which you want to get data)... And put the indicator on the current chart. That is, forcibly set the timeframe from which you want to take data.


It would be easy, if I was writing an Expert Advisor.

but there's an indicator. I haven't written them before.

I've looked at a standard stochastic as an example. I've read the indicator primer.

i have never read anything about periods. it seems to mean that bars are considered in the timeframe to which the indicator has been applied.

this is the reason of my question.....

 
lottamer:


This would be easy if I was writing an EA.

but there's an indicator. I haven't written them before.

I've looked at a standard stochastic as an example. I've read the indicator primer.

i have never read anything about periods. it seems to mean that bars are considered in the timeframe to which the indicator has been applied.

this is the reason for my question....


In standard stochastic:

double iStochastic( string symbol, int timeframe, int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int mode, int shift)

If you write your own unique indicator, use int iBars( string symbol, int timeframe) instead of Bars

https://docs.mql4.com/ru/series/iBars

 
Sepulca:


In a standard stochastic:

double iStochastic( string symbol, int timeframe, int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int mode, int shift)

If you write your own unique indicator, use int iBars( string symbol, int timeframe) instead of Bars

https://docs.mql4.com/ru/series/iBars


the problem seemed easily solved.

replaced all Bars withiBars (viaint iB; iB=iBars("EUROUSD",PERIOD_M5);) No errors.

but no chart. An empty window appears.

Clearly something is missing.

Can the indicator draw 12 lines on one bar? Because there are 12 pentameters at 1 o'clock and each one draws its own line.

 
lottamer:


The problem seemed to be easily solved.

replaced all Bars withiBars (viaint iB; iB=iBars("EUROUSD",PERIOD_M5);) no errors.

But no chart. An empty window appears.

Clearly something is missing.

Can the indicator draw 12 lines on one bar? For example, there are 12 pentameters at 1 o'clock and each one draws its own line.


The same applies to Close - iClose, Open - iOpen, Time - iTime Volume - iVolume, etc.

The indicator may draw up to 8 lines from 0 to 7 https://docs.mql4.com/ru/customind/indicatorbuffers.