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

 
It would probably be easier to run the indicator in the tester...
 
nlp2311:

Thanks for understanding!):

So... Make two scripts - hang them on the keys you need - and in them add a Global Variable of the terminal - which your Expert Advisor will periodically read - and change the Barshift... :-)

If you can - you can do the same via graphical objects ... for example during the initialization of the EA, two text marks are displayed - and if one of them gets lost (you have selected one of them with the mouse during the work of the EA - pressed the Del key) - then the counter of your Barsheift will be incriminated one way or another :-) - restoring the deleted mark on the screen....

 
Aleksander:

So... Make two scripts - hang them on the keys you need - and in them add a Global Variable of the terminal - which your Expert Advisor will periodically read - and change the Barshift... :-)

If you can - you can do the same via graphical objects ... for example during the initialization of the EA, two text marks are displayed - and if one of them gets lost (you have selected one of them with the mouse during the work of the EA - pressed the Del key) - then the counter of your Barsheift will be incriminated one way or another :-) - restoring the deleted mark on the screen....


Bullshit, then already chase the vertical over the chart, and relative to it.
 
alsu:

Why doesn't MT want hooks, by the way?

Protection. Subclassing works.
 
Zhunko:
Protection. Subclassing works.
then substitute WindowProc))
 

Hi all. Please help me find a bug in the code, I'm exhausted - I can't do anything.

Most likely in the last part.

#define MagicNum  700283
//-----
ObjectSetText
extern double  Percent        = 0.8;
extern double  TakeProfit     = 55;
extern bool    UseMM          = true;
extern int     PercentMM      = 1;
extern double  Lots           = 0.1;
//+------------------------------------------------------------------+
double GetLots()
 { 
   if (UseMM)
    {
      double a;
      a = NormalizeDouble((PercentMM * AccountFreeMargin() / 100000), 2);      
      if(a > 49.99) return(49.99);
      else if(a < 0.01)
       {
         return(0);
       }
      else return(a);
    }    
   else return(Lots);
 }
//+------------------------------------------------------------------+ 
int CalculateCurrentOrders()
 {
   int orderT = OrdersTotal(), buys = 0, sells = 0;
   //----
   for(int i = 0; i < orderT; i++)
    {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
       {
         if(OrderType() == OP_BUY)  buys++;
         if(OrderType() == OP_SELL) sells++;
       }
    }
   if(buys > 0) return(buys);
   else if(sells > 0) return(-sells);
   else return(0);
 }
//+------------------------------------------------------------------+  
int start()
 {
        //==============
   int  ticket;
   //-----
   if(CalculateCurrentOrders() == 0) 
    {
      if(AccountFreeMargin() < (1000 * GetLots())) 
         {
            return(0);  
         }
      if(High[1]<High[2] && Low[1]>Low[2] && (High[1]-Low[1])/(High[2]-Low[2])<Percent)
       {
         ticket=OrderSend(Symbol(), OP_BUYSTOP, GetLots(), High[1], 3, Low[2], High[1] + TakeProfit * Point, "iB", MagicNum, 0, Green);
         ticket=OrderSend(Symbol(), OP_SELLSTOP, GetLots(), Low[1], 3, High[2], Low[1] - TakeProfit * Point, "iB", MagicNum, 0, Red);
       }
    }
 }
 
SkinnerDE:

Hi all. Please help me find a bug in the code, I'm exhausted - I can't do anything.

Most likely in the last part.


What's the problem, doesn't it compile or something?
 
By the way, you forgot to multiply the lots by the leverage. Therefore, a variable in your GetLots() function will most likely be 0 (unless you have a million in your account).
 

{' - left parenthesis expected C:\DOCUME~1\9226~1\0016~1\Forex\MACD_N~1.MQ4 (11, 2)

'{' - semicolon expected C:\DOCUME~1\9226~1\0016~1\Forex\MACD_N~1.MQ4 (11, 2)

here's

 
//+------------------------------------------------------------------+
double GetLots()
 { 
   if (UseMM) {
      double a;
      a = NormalizeDouble((PercentMM * AccountFreeMargin() / 100000), 2);      
      if(a > 49.99) return(49.99);
      if(a < 0.01)  return(0);
      return(a);
    }    
 return(Lots);
 }
Stuffed with brackets and yelsev for some reason :-)