Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 506

 
I use the Flive signal, but sometimes I want to close an order myself. But as soon as I close it, it opens again. Is there any way to solve this?
 
Artur116:
I use the Flive signal, but sometimes I want to close an order myself. But as soon as I close it, it opens again. Is there any way to solve this?

Uncheck "Synchronise positions..."
 
Nesradamus:
I assumed that there are only two monthly extrema - min and max... Well, never mind, at first I had a long code, that's why I asked for help... But it dawned on me, I managed to fit it into four lines.

This is if on a monthly candlestick. Of course there will be iHigh(Symbol(), PERIOD_MN1, BarOfMonth); and iLow(Symbol(), PERIOD_MN1, BarOfMonth);

And if we need to find extrema of the price on a daily chart within a month, there will definitely be more than one on at least 28 bars ;)

 
Zver4991:

another question about the function

how to make the rectangle draw forward instead of backward, for example five bars forward at a specified price ...... and not to redraw it

The name "object_name" should contain the time when it was drawn. For example, "Object_name "+TimeToString(Time[0]); Then each rectangle will have its own name.

To specify the shift to the right of the zero bar, add the required number of bars to Time[0], for example Time[0]+Period()*5*60 (add five bars)

datetime t1=Time[10], t2=Time[0]+Period()*60*5;
SetRectangle(clrBlue,"Прямоугольник"+TimeToString(Time[0]),t1,Low[10],t2,High[0]);
 
#property strict
#include <Indicators\Trend.mqh>
bool ind;
CiMA MA;
extern int pos=1;
extern int sl=40;
extern int tp=70;
datetime time;
datetime time2;
bool trade=false;
bool trade2=false;
int a,b;
int OnInit()
  {
//---
   MA.Create(Symbol(),PERIOD_CURRENT,10,6,MODE_EMA,PRICE_CLOSE);//создал машку
//---
   return(INIT_SUCCEEDED);
   
  }
void OnTick()
  {
//---
  if(IsNewBar()==true)//если новый бар включаемся
     {
     if(buy(pos)==true)//если цена выше МА продолжаем
     {
      if(!ExistPositions(Symbol(),-1,-1,0))//если нету открых ордеров продолжаем
        {

         if(GetTypeLastClosePos(Symbol(),-1)!=OP_BUY)//если тип последней закрытой позиции был не на покупку то тогда только покупаем таким образом я пред остерегаюсь от повторных входов в покупку если цена 
//все ещо выше МА...но почему то не работает открываются и дальше сделки на покупку если ордер закрылся выше МА....ХОТЯ НЕ ДОЛЖО ТАК КАК Я ОГРАНИЧИЛ ПО ТИПУ ПОЗИЦИИ ПОСЛЕДНЮЮ СДЕЛКУ И ОНИ ДОЛЖНЫ ТОЛЬКО 
//       ЧЕРЕДОВАТСЯ И УЖ НИ КАК НЕ ПОВТОРЯТСЯ ПО НЕСКОЛЬКО РАЗ ПОДРЯД
           {
            trade=true;
           }
  if(trade==true)
        {
         OpenPosition(Symbol(),OP_BUY,0.1,Ask-sl*Point,Ask+tp*Point);
         trade=false;
        }
}
        }
    
     
if(sell(pos)==true)
{
   if(!ExistPositions(Symbol(),-1,-1,0))
     {

      if(GetTypeLastClosePos(Symbol(),-1)!=OP_SELL)
        {
         trade2=true;
        }

      if(trade2==true)
        {
         OpenPosition(Symbol(),OP_SELL,0.1,Bid+sl*Point,Bid-tp*Point);
         trade=false;
      }
  }}
 }
  }

//возвращает истину если закрытие бара  с указаной позицией выше МА

bool buy(int pos)
  {
   if(iClose(Symbol(),0,pos)>MA.Main(1))
      return true;
   else
      return false;
  }
//+------------------------------------------------------------------+
//| возвращает истину если закрытие бара  с указаной позицией ниже МА
//+------------------------------------------------------------------+
bool sell(int pos)
  {
   if(iClose(Symbol(),0,pos)<MA.Main(1))
      return true;
   else return false;
  }
ALL FUNCTIONS except two BUY and SELL conditions were taken from Kim's branch...... please tell me where I made a mistake...I need one trade to open on one intersection
 

Is there any way in mql4 to hide some code from view, collapse code area so that it is placed under plus (+)?

like in sharp #region #endregion, code placed between these directives will be possible to collapse.

 
I can't figure out what's wrong? In the tester everything works, but on the real and demo, when I try to open an order, I get "Error 0". GetLastError() returns "0" which means no error. What does it mean?
 
Leo59:
I can't figure out what's wrong? In the tester everything works, but on the real and demo, when I try to open an order, I get "Error 0". GetLastError() returns "0" which means no error. What does it mean?

It means this is how it is written in the code, if it bothers you, please correct it.
 
evillive:

It's written in the code, so if it bothers you, fix it.

What should I fix if the order doesn't open?
 
Leo59:

What to fix if the order does not open?
Fix the code, you can't see it from here, so it can't be helped.
Reason: