[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 27

 
volshebnik:
Yes, thank you very much for the great clarifications. I have implemented optimization in all TFs. I will let me know the results after optimization+testing on different segments.


You asked about the possibility to programmatically enumerate and optimize the possible TFs to get their indicator values in the Expert Advisor. This is possible in the following way - for example

Here are some code snippets from the Expert Advisor in the file where this operation is performed - everything is described there with comments.

......
extern int t_trend_period=7;
......

int trend_period=GetPeriod(t_trend_period); // это ф-ия для определения ТФ согласно заданному значению t_trend_period - заданному во внешней переменной (диапазон от 0 до 7)

double t_stoch_main=iStochastic(NULL,trend_period,t_Kperiod,t_Dperiod,t_slowing,MODE_SMA,0,MODE_MAIN,0);
......

// сама ф-ия выбота ТФ для оптимизации по всем периодам 
int GetPeriod(int period)
{int periodres;
 switch(period)
  {
   case 1: periodres=1;break;
   case 2: periodres=5;break;
   case 3: periodres=15;break;
   case 4: periodres=30;break;
   case 5: periodres=60;break;
   case 6: periodres=240;break;
   case 7: periodres=1440;break;
   default: periodres=1;break;
  }
return(periodres);
}

May someone else find it useful.

Files:
 

Please advise! How to make, let's say, a new bar opened in hourly timeframe (H1) and the time is counted for about 50 minutes in this bar, after 50 minutes there will be a signal. I heard about Sleep.

 
anton777:

Please advise! How to make, let's say, a new bar opened in hourly timeframe (H1) and the time is counted for about 50 minutes in this bar, after 50 minutes there will be a signal. I heard about Sleep.

int minutes=50; 

if(TimeCurrent()>=iTime(NULL,PERIOD_H1,0)+minutes*60){

   /// 

}
 

I have a strange thing - the custom indicator on the chart and inside the EA gives completely different numbers. The indicator is MQL analogue of LinearReg from MetaStock. It is written as follows

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Magenta

extern int  RPeriod = 20;

int shift = 0, cnt = 0,loopbegin = 0;
bool first = True;
int prevbars = 0;
double sum =0, WT = 0;
int i = 0;

double val1[];

int init()
{
SetIndexBuffer(0,val1);
   return(0);
}

int start()
{
   if (RPeriod<1) 
   {
   return(0);
   }
   loopbegin=Bars-RPeriod-1;
   for (shift=loopbegin; shift>=0; shift--)
   {
      sum=0;
      for (i=RPeriod; i>=1; i--)
      {
         sum=sum+(i-(RPeriod+1)/3)*Close[RPeriod-i+shift];
      }
      WT = sum*6/(RPeriod*(RPeriod+1));

           val1[shift] = WT;
        }
   return(0);
}
When it is attached to a chart it shows exactly the same results as MetaStock has. But as soon as it is attached to a trading Expert Advisor, its value is higher than 1.4 (at its indicator_chart_window property) at EURUSD, where the quotes are around 1.29. Naturally, the reproduced trading systems for MetaStock cannot work, it turns out that they always hold the same position. If I click on the EA results the line of this indicator remains far away but if I simply recompile it, the chart immediately becomes correct as in MetaStock. I can't figure out why there is such a difference.
 

Hello, dear experts!

I would like to ask for your help! I want to try to make my first Expert Advisor, with tasks ...
1-Pips
2-М5
3-Can set stop and takeaway parameters.
4 - Instead of takeoffs it would be possible (optional) to include position reversal every time this level is reached
To stop it manually, by hot keys, let's say.
5 - Absolutely no indukes.
So that's it. I hope I have not downloaded.
Actually I need at least some sources nitsy, or layout, well, that would not be very complicated I am so acrome scripts did not do anything, and that is, tokmo ready remade mostly for himself.
I hope for your help

 
Mr.Ross:

Hello, you guys!

I would like to ask for your help! I want to try to make my first Expert Advisor, with tasks ...
1-Pips
2-М5
3-Can set stop and takeaway parameters.
4 - Instead of takeoffs it would be possible (optional) to include position reversal every time this level is reached
To stop it manually, by hot keys, let's say.
5 - Absolutely no indukes.
So that's it. I hope I have not downloaded.
Actually I need at least some sources nitsy, or layout, well, that would not be very complicated I am so acrome scripts did not do anything, and that is, tokmo ready remade mostly for himself.
I hope for your help

https://www.mql5.com/ru/articles/1413
 
Mr.Ross:

I want to ask for your help!

We will help you if you do not understand the programming part, but do not forget: "Saving the drowning - the drowning themselves" = You show part of the code where there are unclear points, the code of 1.5 thousand lines - quit it and sort it out yourself ;)
 
Ilya81:

I have a weird thing

try to visually compare some simple indicator and data which the Expert Advisor receives via iCustom() from this indicator. I think MovingAverage is a good indicator for experiments

you must be using iCustom() function incorrectly

 
Integer:

Thank you so much!
 

If anyone works at instaforex mt4, maybe they have encountered a problem:

They have four digits on the demo, five digits on the real, but very strange - bid and ask are rounded to four digits.


here is such a code:

   if (Poz_Up)
      {
         ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,NormalizeDouble(Bid-300*Point,Digits),NormalizeDouble(Ask+300*Point,Digits),Komment,0,Green);
      }
   if (Poz_Dn)
      {
         ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,NormalizeDouble(Ask+300*Point,Digits),NormalizeDouble(Bid-300*Point,Digits),Komment,0,Green);
      }

i have a feeling that i dont know what to do with it. it gives out SL&TP when i open a position then 300pts, then 3000pts as if i'm trying to figure out what the Digits are each time i get a new one.

May somebody suggest how to solve this issue and has anybody faced similar situations or it is just me?