Questions from a "dummy" - page 239

 
forward666:

Thanks! If you can give me any tips, that would be great!

I'll read more about the stylizer.

Try instead:

bool first;

write:

bool first=true;
 
Dear Sirs! Please advise "dummies" how (or rather where) to download a free Expert Advisor from the Market? I know where to install standard Expert Advisors... I can't do it from Market - what application should I use?
 
Sokrat:

Dear Sirs! Please advise "dummies" how (or rather where) to download a free Expert Advisor from the Market? I know where to install an ordinary EA... I cannot do it from the Market - what application should I use?
The easiest way to do this from the terminal, the Toolbox has the Market tab
 
Sokrat:

Dear Sirs! Please advise "dummies" how (or rather where) to download a free Expert Advisor from the Market? I know where to install standard Expert Advisors... I can't do it from Market - what application should I use?



 

forward666: У меня при запуске робота сразу открывается позиция,которая явно не отражает реалии графика,соответственно она уходит в глубокий минус. Как сделать,что при запуске робота эта позиция не открывалась сразу?где в коде нужно что-то добавить?

#include <Trade/Trade.mqh>
#include <Trade/SymbolInfo.mqh>
#include <Trade/PositionInfo.mqh>

CTrade Trade;
CSymbolInfo Sym;
CPositionInfo Pos;

input int Shift=10; /*Shift*/ // Величина скачка цены для открытия позиции
input int Limit=100; /*Limit*/ // Величина убытка в пунктах для закрытия позиции
input int Prof=10;
input int MA_Period=50; // Период Moving Average 
int maHandle; // хэндл индикатора Moving Average
double maVal[3]; // статический массив для хранения значений индикатора Moving Average
bool first;
double a,b,Lots;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
  {
   maHandle=iMA(NULL,0,MA_Period,2,MODE_SMA,PRICE_CLOSE);
   if(maHandle<0)
     {
      Alert("Ошибка при создании индикаторов - номер ошибки: ",GetLastError(),"!!");
      return(-1);
     }
   first=false;
   if(!Sym.Name(_Symbol))
     {
      Alert("Ошибка инициализации CSymbolInfo, поворите попытку");
      return(-1);
     }
   Print("Инициализация эксперта выполнена");
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   IndicatorRelease(maHandle);
  }
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(CopyBuffer(maHandle,0,0,3,maVal)<0)
     {
      Alert("Ошибка копирования буферов индикаторов - номер ошибки:",GetLastError());
      return;
     }
   if(!Sym.RefreshRates()) return;
   if(first)
     {
      a=Sym.Ask();
      b=Sym.Bid();
      first=false;
      return;
     }
   Lots=AccountInfoDouble(ACCOUNT_FREEMARGIN)*0.66/1000/SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE);
   Lots=MathMin(999,MathMax(1,Lots));
   Lots=NormalizeDouble(Lots,2);
   if(Pos.Select(_Symbol))
     {
      if(Pos.Profit()>2)
        {
         Trade.PositionClose(_Symbol,Sym.Spread()*2);
        }
      else
        {
         if(Pos.PositionType()==POSITION_TYPE_BUY)
           {
            if((Pos.PriceOpen()-Sym.Ask())/Sym.Point()>Limit)// || Sym.Bid()<maVal[0]-0.0005)
              {
               Trade.PositionClose(_Symbol,Sym.Spread()*2);

              }
           }
         else if(Pos.PositionType()==POSITION_TYPE_SELL)
           {
            if((Sym.Bid()-Pos.PriceOpen())/Sym.Point()>Limit)// || Sym.Ask()>maVal[0]+0.0005)
              {
               Trade.PositionClose(_Symbol,Sym.Spread()*2);

              }
           }
        }
     }
   else
     {
      if(b-Sym.Bid()>=Shift*Sym.Point() && maVal[0]>maVal[1] && maVal[1]>maVal[2] && Sym.Bid()<maVal[0])
        {
         Trade.SetDeviationInPoints(Sym.Spread()*2);
         Trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,Lots,Sym.Bid(),0,0,""); //Sym.Bid()+0.0030
                                                                            // Trade.Sell(Lots,_Symbol,0,0,0,"");
         Print(__FUNCTION__,"():Sell");
        }
      if(Sym.Ask()-a>=Shift*Sym.Point() && maVal[0]<maVal[1] && maVal[1]<maVal[2] && Sym.Ask()>maVal[0])
        {
         Trade.SetDeviationInPoints(Sym.Spread()*2);
         Trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,Lots,Sym.Ask(),0,0,""); //Sym.Ask()-0.0030
                                                                           // Trade.Buy(Lots,_Symbol,0,0,0,"");
         Print(__FUNCTION__,"():Buy");
        }
     }
   a=Sym.Ask();
   b=Sym.Bid();
  }

You have before the first tick: first==false, and variables a and b are uninitialised. That's why on the first tick the condition

   if(first)
     {
      a=Sym.Ask();
      b=Sym.Bid();
      first=false;
      return;
     }

does not work, and variables a and b remain uninitialized.

If after fixing this problem the position will still open, print the array values for MA, ask, bid and variables a and b.

 

Hello.

I'm a real dummy, so don't kick me.)

My question is: How can I extract quote data from Metatrader 5?

I've converted quotations to excel file and took it to my place of work where I have no internet access and worked with it.

But in 5 metatrader I don't know how to convert its files to excel. Can you tell me please. It turns out, I need a step-by-step instruction or a script (I don't know the programming language, but I know how to use scripts, expert advisors or indicators), which could be started at a needed timeframe, even if it's non-standard (M3 or M7, for example). I would also like to ask you not to ask me to start studying the programming language, please.

I would just like to switch permanently to MT5 so I don't have to work with two metatrader.

Really hoping for your help, knowledgeable people, would be grateful to the grave =).

Regards, Alexey.

 
Hronoptal:

...

Partly here you will find what you need: How to prepare MetaTrader 5 quotes for other programs

If you don't want to learn, you can order whatever you want in the Jobs section. ))

 

Thank you very much, dear tol64, for the tip.

As for learning, it's still a matter of lack of time, unfortunately.

Many thanks again.

Sincerely, Alexey.

 
Is it possible for the visual indicator test to show 2 or more indicators instead of just 1?
 
paladin800:
Is it possible to make 2 or more indicators to be shown during the visual indicator test and not only 1?
Save the template with the file name tester.tpl with all required indicators and enable the test in visualisation mode.
Reason: