Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 970

 
Aleksandr Klapatyuk:

object name move over iFractals

So it's visually obvious as it is
 
Vladimir Baskakov:
This is visually obvious

and on behalf of the object - my Expert Advisor can open in any direction as well as close

it's an indicator. and my EA works in semi-automatic mode on objects with the name

101010

Files:
IgorM.mq5  17 kb
 
Aleksandr Klapatyuk:

and on behalf of the object - my Expert Advisor can open in any direction as well as close

it's an indicator. and my EA works in semi-automatic mode on objects with the name


You couldn't have come up with a worse algorithm.

 
Alexey Viktorov:

I could not think of a worse algorithm.

I mostly trade with my hands - this is just for fun. maybe someone will come up with something else.

Thealgorithm is not so bad. For instance, you open a position, put an object on the chart and go smoke.

As the object is crossed, the position will close or vice versa - as you set in the EA.

This indicator turns out as a trawl byiFractals

(The name of the object is not attached to the indicator - and when the Expert Advisor works, it will delete the object and everything has to be repeated manually).

Совершение сделок - Торговые операции - MetaTrader 5
Совершение сделок - Торговые операции - MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
Yevhenii Levchenko:
double value = 0;
Initialise value, it's a UB in general.
 
int TP;
int SL;

CTrade trader;
bool Invertor;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {

   TP = TakeProfit;
   SL = Stoploss;

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   double points;

   if(!PositionSelect(_Symbol))
     {
      if(Invertor)
         trader.Buy(Lot);
      else trader.Sell(Lot);
     }
   else
     {
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
        {
         points=(SymbolInfoDouble(_Symbol,SYMBOL_BID)-PositionGetDouble(POSITION_PRICE_OPEN))/_Point;
         if(points>=TP)
           {
            trader.PositionClose(_Symbol);
            Invertor=true;
           }

         if(points<=-SL)
           {
            trader.PositionClose(_Symbol);
            Invertor=false;
           }
        }
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
        {
         points=(PositionGetDouble(POSITION_PRICE_OPEN)-SymbolInfoDouble(_Symbol,SYMBOL_ASK))/_Point;
         if(points>=TP)
           {
            trader.PositionClose(_Symbol);
            Invertor=false;
           }
         if(points<=-SL)
           {
            trader.PositionClose(_Symbol);
            Invertor=true;
       }

Good afternoon, please help me to write a code that would add a lot or a certain number of lots each time I make a U-turn. And at TP it would return 1 lot.

 
Vict:
Initialise value, it's a UB in general.
At the same time I learned what UB is. Thanks :)
 
In mt5 hedge account type, how can the open trades be searched if the Positive Select only has an instrument name?
bool PositionSelect(
        string symbol // имя инструмента
);
 
Yevhenii Levchenko:
I have seen the answer to your question exactly in his codes.

Look at KB, the moderator there is like a copy of three codes a day - I've definitely seen the answer to your question in his codes

Reason: