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

 
I'll say as a coder who mainly writes on request: a couple of dozens of "extra" lines of code (when you understand what you've written there and you're confident in it), it's never redundant, at least in terms of reliability of the system as a whole, and respectively lesser number of returns and problems in communicating with the customer.
 
FAQ:
I'm going to say as a coder, mostly custom-made: A couple of dozens of "extra" lines of code (when you understand what you've written there and you're confident in it) is never redundant, at least in terms of reliability of the system as a whole, and consequently fewer callbacks and problems in dealing with the customer.

I see. Thank you. I have already made the changes.

But all the same, it was interesting to me that it turns out that the opening can also be done with a "sloppy" volume... not quite as it should be, but the fact is...

 
sergeev:

The FAQ says it right. You can't rely on "defaults". Because I remember that 131 error (wrong lot) often came up, if you don't do a normalization before sending an order.
Maybe now the MMOs have done their own default lot checking on the servers when sending an order for execution.

So you should always do your own price and lot normalization before sending.

This is a good coding rule for you, and a guarantee of less hassle with potential problems in the future.

Understood, thank you.

"Since I remember that 131 errors (wrong lot) often appeared if I didn't do any normalization before sending the order" - that's not the case now.

I accidentally checked it myself, when I "forgot" to enable the lot normalization feature.

 
Roman.:

I see. Thank you. I've already made the changes.

But it was still interesting to me that it's possible to open with a "sloppy" volume... not quite as it should be, but the fact is...


Before the introduction of the five digits, no one asked the question of normalisation at all - everything worked as it was.
 
Good afternoon everyone!
The question is as follows, the first time the indicator is started it is displayed
by alphabra-cadabra (pic.1). After further scrolling on the history all is normal (fig.2).

Can you tell me what's the problem? Below if you need the code.

#property indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Tomato
#property  indicator_color2  Red
#property  indicator_color3  Blue
#property indicator_level1 0
#property indicator_levelcolor Gray
#property indicator_levelstyle 2

extern int Period_MA = 5;
extern int MA_Line1 = 13;
extern int MA_Line2 = 34;
 
double Brs[],BrsMA1[],BrsMA2[],MathArr[],MathArr1;
int i=0,j=0;
double hvostUp,hvostDn,rast,S;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,Brs);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,BrsMA1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,BrsMA2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexLabel(0,"Bars_");
   SetIndexLabel(1,"Bars_MA1");
   SetIndexLabel(2,"Bars_MA2");
     
   ArrayResize(MathArr,Period_MA);
   
 //---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Bars_MA");

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit(){return(0);}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start() {  

int ncount=IndicatorCounted();
int limit=Bars-ncount-1;

for (int i=0; i<limit; i++)
{

if (High[i+2]>High[i+1] && Low[i+2]>Low[i+1])
{
hvostUp=(High[i+2]-High[i+1])/Point;
hvostDn=(Low[i+2]-Low[i+1])/Point;
rast=(High[i+2]-Low[i+1])/Point;
S=rast-hvostUp-hvostDn;
}

if (High[i+2]<High[i+1] && Low[i+2]<Low[i+1])
{
hvostUp=(MathAbs(High[i+2]-High[i+1]))/Point;
hvostDn=(MathAbs(Low[i+2]-Low[i+1]))/Point;
rast=(High[i+1]-Low[i+2])/Point;
S=rast-hvostUp-hvostDn;
}

if (High[i+2]>=High[i+1] && Low[i+2]<=Low[i+1])
{
S=(High[i+1]-Low[i+1])/Point;
rast=(High[i+2]-Low[i+2])/Point;
}

if (High[i+2]<=High[i+1] && Low[i+2]>=Low[i+1])
{
S=(High[i+2]-Low[i+2])/Point;
rast=(High[i+1]-Low[i+1])/Point;
}

if (High[i+2]<=Low[i+1] || Low[i+2]>=High[i+1])
{
S=0;
rast=1;
}

if(j>=Period_MA-1)j=0;
j++;
 MathArr[j]=(S/rast*100);
 
Brs[i]=iMAOnArray(MathArr,0,Period_MA,0,0,0);
BrsMA1[i]=iMAOnArray(Brs,0,MA_Line1,0,0,0);
BrsMA2[i]=iMAOnArray(Brs,0,MA_Line2,0,0,0);
}   
  return(0);
}

Fig.1

Fig. 2

Files:
bars_ma_1.mq4  4 kb
 
It would be nice to automate this process, i.e. to do this job beforehand instead of waiting for profit to trigger. i looked through all of the posted scripts, i found a similar one, but they say it doesn't work. it' s for clarity. Or let's make a function that when a TP or SL triggers, the script opens all just closed orders, only in a pending form. Many traders know what they are going to do in a certain situation and it's very convenient to do that before the situation happens.
 
sting-igor:
It would be nice to automate this process, i.e. to do this job beforehand instead of waiting for profit to trigger. i looked through all of the posted scripts, i found a similar one, but they say it doesn't work. it' s for clarity. Or let's make a function that when a TP or SL triggers, the script opens all just closed orders, only in a pending form. Many traders know what they are going to do in a certain situation and it's very convenient to do that before the situation happens.

You're in the right place :Work
 
Fox_RM:
Good afternoon everyone!
The question is as follows, the first time the indicator is started it is displayed
by alphabra-cadabra (pic.1). After further scrolling on the history all is normal (fig.2).

Can you tell me what's the problem? Below if you need the code.

Fig.1

Fig. 2


I'm sorry that the question was asked a second time.

Compare your variant with this

It still doesn't work correctly, but it's better

Edited the indicator again

Files:
 
FAQ:

You go this way:Work
Doesn't anyone have one?
 
sting-igor:
Doesn't anyone have one?


DigCode Base

If you can't find one, then order one.

Reason: