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

 
OK, if they don't, help me sort it out tonight.
 
Please tell me if it is possible to use the value of double, which is the result of the calculation, as a substitute int value for further calculations.
Example:
   ATR_Din=iATR(NULL,PERIOD_M5,14,1);
   Din_Per210= MathRound(6000*ATR_Din+210);
   Din_Per5  = MathRound(6000*ATR_Din+5);
   
   MA210_DIN  =iMA(NULL,PERIOD_M5,Din_Per210,0,MODE_SMA,PRICE_CLOSE,1);
   MA5_DIN    =iMA(NULL,PERIOD_H1,Din_Per5,0,MODE_SMA,PRICE_CLOSE,1);
   
Here my selected variables are of type double, but in iMA their value is used where an int value is needed (as a period of MA).
The question is: Is this usage correct or is it necessary to convert the values to int type ?
 
Hi all, could you please advise if you know if there is a script that will run an expert test on each of the optimisation results and save each test result in a separate file (htm report)?
 
Craft:
I don't mind, is there a working example or link?
Give me the code or give me a task and we'll correct it.
 
artmedia70:
Please tell me if it is possible to use the value of double, which is the result of the calculation, as a substitute int value for further calculations.
Example:
Here my selected variables are of type double, but in iMA their value is used where int value is needed (as period of MA).
So my question is: Is such usage correct or some conversion of values to int type is necessary ?
The conversion is done automatically, just cutting off fractional part. The only limitation I've encountered for such use is that double cannot be put in the array index
 
alsu:
The conversion is done automatically, just cutting off the fractional part. The only limitation to this usage I've seen is that double cannot be put in the array index
Thanks, that's reassuring... :)
One more question:
   MA200_DIN =iMA(NULL,PERIOD_M5,Din_Per200,0,MODE_SMA,PRICE_CLOSE,1);
   MA200_UP  =MA200_DIN+20*pt;
   MA200_DN  =MA200_DIN-20*pt;
   
   MA5_DIN  =iMA(NULL,PERIOD_H1,Din_Per5,0,MODE_SMA,PRICE_CLOSE,1);
   MA5_UP   =MA5_DIN+20*pt;
   MA5_DN   =MA5_DIN-20*pt;
Constructions
MA200_UP=MA200_DIN+20*pt; 
MA200_DN=MA200_DIN-20*pt; и 
MA5_UP=MA5_DIN+20*pt; 
MA5_DN=MA5_DIN-20*pt;
do not work. When displaying their values in the chart they all have the same value, e.g:
1.4118 for MA200_DIN, MA200_UP, MA200_DN and
1.4106 for MA5_DIN, MA5_UP, MA5_DN.
It turns out that formulas for calculation of levels +20 and -20 points do not work.
What am I doing wrong?
 
What does pt equal? Try outputting with NormalizeDouble()
 
OK, thanks, I've got it... I set pt=Point; after calculation of values...
As Matroskin said: You're a fool... :)
 
alsu:
Give us a code or set a task and we will correct it

In WelsLab, the analog of the problem looks like this:

MyATR = SMA.Series((((High-Low)/Low), PerB)[i-1] ;

if (BuyAtStop(i, (Open[i] + Open[i]*MyATR), "") ;

i.e. when a bar is opened, a Stop position is placed where Open [i] price of the current bar + trigger (the same Open price multiplied by MyATR calculated for the period PerB on the closed bars [i-1]) is opened once if the specified level is reached

This one shows what I want to get on mql4 using WellLab as an example.

I have studied the site materials and tried to make an analogue.

        MyATR = ((High[0] - Low[0])/Low[0]);
	 BT = Open[0] + Open[0]*iMAOnArray(MyATR ,0,PerB,0,MODE_SMA,1);
        ST = Open[0] - Open[0]*iMAOnArray((MyATR ,0,PerS,0,MODE_SMA,1);

   if (Ask >=  BT)                       // Если разница между
     {                                          // 
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
     }
   if (Bid <= ST)                       // Если разница между
     {                                          // 
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }

Result: Orders are piling up. Please advise what condition should be added (or changed) to make the orders be executed at a specified level once.

 

Note: the first parameter of the iMAOnArray function should be an array - and you have MyATR scalar. In order to get it right, you should:

1. declare double MyATR[];

2. set the array size to ArrayResize(MyATR,PerB);

3. fill the array for(i=1;i<=PerB;i++) MyATR[i-1]=(High[i]-Low[i])/Low[i]; index i starts with 1 since we need only closed bars

4. after this you can read iMAOnArray(MyATR,0,PerB,0,MODE_SMA,0); here the last parameter is 0 since shift ha1 has already been taken into account in step 3.


Check how it works, maybe the error is just in this

Reason: