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

 
boris.45:
How do I get in touch with you? I have a lot of questions and would like some advice.
When you ask a question to someone, click on "reply" in the bottom right corner of the post of the person to whom you are addressing. Otherwise, people will wonder who your question is addressed to... :)
 
Can you tell me if it is possible to send a disconnect command to the EA from the script?
 
granit77:
I would replace a switch with a ready-made array, why assign predefined values every time?

Thanks, but could you be more specific? Because the predefined values here are timeframes, but the code following the cases for different indicators will be different... Probably, it's easier to lay out a little more code... :) In general I am very slow today - I couldn't sleep last night and I am still in limbo...

int AnaliseFunc (string sy, int tf)
{
   
   CurAsk   =MarketInfo(Symbol(),MODE_ASK);
   CurBid   =MarketInfo(Symbol(),MODE_BID);
   OpnPrice =iOpen(NULL,PERIOD_M5,0);
   OpnPrice1=iOpen(NULL,PERIOD_M5,1);
   ClsPrice1=iClose(NULL,PERIOD_M5,1);
         
   if (sy=="" || sy=="0") sy=Symbol();
double
   BB_1  =iCustom(sy,tf,"BB_MA",13,1,1,1),
   BB_2  =iCustom(sy,tf,"BB_MA",13,1,1,2),
   BB_3  =iCustom(sy,tf,"BB_MA",13,1,1,3),
   AO1   =iAO(sy,tf,1),
   AO2   =iAO(sy,tf,2),
   AO3   =iAO(sy,tf,3),
   AC1   =NormalizeDouble(iAC(sy,tf,1),8)*1000,
   AC2   =NormalizeDouble(iAC(sy,tf,2),8)*1000,
   AC3   =NormalizeDouble(iAC(sy,tf,3),8)*1000,
   AC4   =NormalizeDouble(iAC(sy,tf,4),8)*1000,
   AC5   =NormalizeDouble(iAC(sy,tf,5),8)*1000,
   SpMan1=iCustom(sy,tf,"SpearmanRankCorr",14,1000,30,true,0,1),
   SpMan2=iCustom(sy,tf,"SpearmanRankCorr",14,1000,30,true,0,2),
   DeM_1 =iDeMarker(sy,tf,14,1),
   DeM_2 =iDeMarker(sy,tf,14,2),
   Mom_1 =iMomentum(sy,tf,14,PRICE_CLOSE,1),
   Mom_2 =iMomentum(sy,tf,14,PRICE_CLOSE,2),
   Mom_3 =iMomentum(sy,tf,14,PRICE_CLOSE,3);
   
//---------------- Проверка на разворот BB_MA -------------------------------------------------------   
   
   if (BB_1>BB_2 && BB_2<=BB_3 && BB_1<0)                               // Найден разворот BB вверх
      {
      switch (tf)
         {
            case 1:     TrBBTurnUP_M1 =true;  TrBBTurnDN_M1=false;      // Флаг разворота вверх на М1
            case 5:     TrBBTurnUP_M5 =true;  TrBBTurnDN_M5=false;      // Флаг разворота вверх на М5
            case 15:    TrBBTurnUP_M15=true;  TrBBTurnDN_M15=false;     // Флаг разворота вверх на М15 
            case 30:    TrBBTurnUP_M30=true;  TrBBTurnDN_M30=false;     // Флаг разворота вверх на М30 
            case 60:    TrBBTurnUP_H1 =true;  TrBBTurnDN_H1=false;      // Флаг разворота вверх на H1
            case 240:   TrBBTurnUP_H4 =true;  TrBBTurnDN_H4=false;      // Флаг разворота вверх на H4
            case 1440:  TrBBTurnUP_D1 =true;  TrBBTurnDN_D1=false;      // Флаг разворота вверх на D1
            case 10080: TrBBTurnUP_W1 =true;  TrBBTurnDN_W1=false;      // Флаг разворота вверх на W1
            case 43200: TrBBTurnUP_MN =true;  TrBBTurnDN_MN=false;      // Флаг разворота вверх на MN
         }
      }
   if (BB_1<BB_2 && BB_2>=BB_3 && BB_1>0)                               // Найден разворот BB вниз
      {
      switch (tf)
         {
            case 1:     TrBBTurnUP_M1 =false;  TrBBTurnDN_M1=true;      // Флаг разворота вниз на М1
            case 5:     TrBBTurnUP_M5 =false;  TrBBTurnDN_M5=true;      // Флаг разворота вниз на М5
            case 15:    TrBBTurnUP_M15=false;  TrBBTurnDN_M15=true;     // Флаг разворота вниз на М15 
            case 30:    TrBBTurnUP_M30=false;  TrBBTurnDN_M30=true;     // Флаг разворота вниз на М30 
            case 60:    TrBBTurnUP_H1 =false;  TrBBTurnDN_H1=true;      // Флаг разворота вниз на H1
            case 240:   TrBBTurnUP_H4 =false;  TrBBTurnDN_H4=true;      // Флаг разворота вниз на H4
            case 1440:  TrBBTurnUP_D1 =false;  TrBBTurnDN_D1=true;      // Флаг разворота вниз на D1
            case 10080: TrBBTurnUP_W1 =false;  TrBBTurnDN_W1=true;      // Флаг разворота вниз на W1
            case 43200: TrBBTurnUP_MN =false;  TrBBTurnDN_MN=true;      // Флаг разворота вниз на MN
         }
      }
//---------------------- Проверка на разворот Momentum -----------------------------------------------
   
   if (Mom_1>Mom_2 && Mom_2<=Mom_3 && Mom_1<100.0)
      {
      switch (tf)
         {
            case 1:     TrMomTurnUP_M1 =true;  TrMomTurnDN_M1=false;      // Флаг разворота вверх на М1
            case 5:     TrMomTurnUP_M5 =true;  TrMomTurnDN_M5=false;      // Флаг разворота вверх на М5
            case 15:    TrMomTurnUP_M15=true;  TrMomTurnDN_M15=false;     // Флаг разворота вверх на М15 
            case 30:    TrMomTurnUP_M30=true;  TrMomTurnDN_M30=false;     // Флаг разворота вверх на М30 
            case 60:    TrMomTurnUP_H1 =true;  TrMomTurnDN_H1=false;      // Флаг разворота вверх на H1
            case 240:   TrMomTurnUP_H4 =true;  TrMomTurnDN_H4=false;      // Флаг разворота вверх на H4
            case 1440:  TrMomTurnUP_D1 =true;  TrMomTurnDN_D1=false;      // Флаг разворота вверх на D1
            case 10080: TrMomTurnUP_W1 =true;  TrMomTurnDN_W1=false;      // Флаг разворота вверх на W1
            case 43200: TrMomTurnUP_MN =true;  TrMomTurnDN_MN=false;      // Флаг разворота вверх на MN
         }
      }
      
   if (Mom_1<Mom_2 && Mom_2>=Mom_3 && Mom_1>100.0)
      {
      switch (tf)
         {
            case 1:     TrMomTurnUP_M1 =false;  TrMomTurnDN_M1=true;      // Флаг разворота вверх на М1
            case 5:     TrMomTurnUP_M5 =false;  TrMomTurnDN_M5=true;      // Флаг разворота вверх на М5
            case 15:    TrMomTurnUP_M15=false;  TrMomTurnDN_M15=true;     // Флаг разворота вверх на М15 
            case 30:    TrMomTurnUP_M30=false;  TrMomTurnDN_M30=true;     // Флаг разворота вверх на М30 
            case 60:    TrMomTurnUP_H1 =false;  TrMomTurnDN_H1=true;      // Флаг разворота вверх на H1
            case 240:   TrMomTurnUP_H4 =false;  TrMomTurnDN_H4=true;      // Флаг разворота вверх на H4
            case 1440:  TrMomTurnUP_D1 =false;  TrMomTurnDN_D1=true;      // Флаг разворота вверх на D1
            case 10080: TrMomTurnUP_W1 =false;  TrMomTurnDN_W1=true;      // Флаг разворота вверх на W1
            case 43200: TrMomTurnUP_MN =false;  TrMomTurnDN_MN=true;      // Флаг разворота вверх на MN
         }
      }
//---------------------- Проверка DeMarker на перепроданность/перекупленность ---------
You see - there's absolutely identical code going on, but it's already checking trading criteria of other indictors... I just want to cram all checks of all indices used in the EA into one analytical block, so it would calculate their values once per a tick, put them into variables and use values of the variables for trading decisions. I don't know how to arrange it using an array of predefined values...
 
artmedia70:

Thanks, but could you be more specific? Because the predefined values here are timeframes, but the code following the cases for different indicators will be different... Probably, it's easier to lay out a little more code... :) I'm not thinking straight today - I couldn't sleep last night and am still in limbo...

You see - there is absolutely identical code there but it already checks trade criteria of other indirectors... I just want to cram all checks of all indices used in the EA into one analytical block and then it will calculate their values once per a tick, put them into variables and use the values of the variables for trading decisions. I don't know how to arrange it using an array of predefined values...




Maybe you just need to select a calculation priority, i.e. it looks like you have

If (BB_1<0 ) is the first mandatory condition after which there is no need to calculate other BB_, well, make a compound if and make necessary BB_ calculations in second if, provided that first if was done, and if ... else is rather effective, while you have only if

I agree, the code may become larger and less readable, but performance will go up

 
IgorM:


maybe you just need to pick up the computation priority, i.e. like you have

If (BB_1<0 ) is the first mandatory condition, after which there is no need to calculate other BB_, so make a compound if and make the necessary BB_ calculations in the second if, provided the first if was fulfilled, and if . else is rather effective, while you have only if

I agree that your code may become larger and less readable, but performance will go up.

Thanks, Igor, I'll see what happens. That's not what I had in mind... I remember back in the early days of computerization, in 1991-94, I don't remember exactly... I was doing assembly language programming for ZX Spectrum... which was terribly slow and limited to 64Kb of memory... So there was a command to the processor to work with the screen memory area to quickly output 16386Kb to that area. The documented CPU command was the fastest of all the commands dealing with a large data set. There's not much we can do about it, but... they found a way to quadruple the output speed. There were commands for working with the stack and they were executed much faster. This is how they did it: moved the stack to an unused area of memory that goes right after the screen, filled that area with graphical data and then, having moved the stack to the screen, they quickly jumped the screen prepared in memory to the screen area with a command that filled the stack... Just a miracle for those times, but for Spectrum it was magic...

Here too, I'm interested in unconventional ways of working... You know, like see what commands are executed in how many clock cycles and build something similar... What could replace the logical comparison commands, maybe subtraction or something else in the same vein....

 
artmedia70:

And here I'm interested in non-standard ways of working... Like looking up which commands are executed in how many clock cycles and constructing something similar... What could replace the logical comparison commands, maybe subtraction or something like that....


i think you won't find it in mql - the principles of mql are very similar to java with C syntax, try to see which is faster to execute case or if, i remember when i saw in turbopascal that if is faster
 
artmedia70:
Welcome here.
 
Oper:
Do you know if you can send a command to disable the EA from the script?

You can. I, for example, control my EA with scripts that set global variables to a certain state. The states of these variables

they are analyzed in the Expert Advisor and the necessary commands are executed.

 
Good afternoon.
 
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,241); 
Can you tell me how to set the size of the arrow correctly, and why does it increase in size when you reset the colour settings but decrease when you recompile?