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

 
KarpovNikolay:

Hello everyone. I am new to trading, I am sitting on demo with Expert Advisors, but I want to start real with $45. I am testing EAs for now, so I want to use signals. I use MT4. I have selected a list from which I would like you to help me choose the best signal. Here is the list:

https://www.mql5.com/ru/signals/10276

https://www.mql5.com/ru/signals/11021

https://www.mql5.com/ru/signals/6283

https://www.mql5.com/ru/signals/10964

https://www.mql5.com/ru/signals/9649

It's beginner's luck! But it is better not to waste time, study trading, the language! Maybe you will be lucky!
 
Good afternoon. help me please help me if the variable sig=1 needs the pol variable to remember the balance and not to change its value no matter how long it will continue to show and if sig=1 again to remember the current one please give me the code
 
sannin:
Good afternoon. help me please help me if the variable sig=1 will remember the balance and not to change its value, no matter how much it will display next, and if sig=1 again to remember the current one please give me the code
    if (сиг == 1) pol = AccountBalance();
 
TarasBY:


if the balance changes, the sex will be equal to the new balance

this is immediately visible if you do the following

int pol;
Comment("\n balance: ", pol);

pol=AccountBalance();

 

I made up an Expert Advisor for testing trade, but I cannot figure out one thing...

Bay/sell is opened using maximal and minimal MAs

// Condition for opening BUY position
if(MA_L1<MA_L0&&Ask<=MA_L0&MA_0>MA_1&&HA_up>HA_dw)

// Condition for opening a SELL position
if(MA_H1>MA_H0&&Bid>=MA_H0&MA_0<MA_1&HA_up<HA_dw)

#include <b-Lots.mqh>
extern double TrailingStop = 30;
extern double Sploss = 15;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start() {
   double HA_up,HA_dw;
   double MA_H0,MA_H1,MA_L0,MA_L1,MA_0,MA_1;
   int i, cnt, ticket, total;
   bool flag=true;

   if(Bars<100) {
      Print("bars less than 100");
      return(0); 
   }
// Проверяем стоит ли открываться
   
   cnt=OrdersHistoryTotal()-1;
   for(i=cnt;i>=0;i--) {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY )) continue;
      if(OrderOpenTime()>=Time[0]) { // Time[0] - если позиция открывается на нулевом баре текущего символа
         flag=false;
         break;
      }
   }
   cnt=OrdersTotal()-1;
   for(i=cnt;i>=0;i--) {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderOpenTime()>=Time[0]) { // Time[0] - если позиция открывается на нулевом баре текущего символа
         flag=false;
         break;
      }
   }
   if(!flag) return(0); 
//-----------------------------------------------
   MA_H0=iMA(0,0,3,0,MODE_SMA,PRICE_HIGH,0);
   MA_H1=iMA(0,0,3,0,MODE_SMA,PRICE_HIGH,1);
   MA_0=iMA(0,0,3,0,MODE_EMA,PRICE_MEDIAN,0);
   MA_1=iMA(0,0,3,0,MODE_EMA,PRICE_MEDIAN,1);
   MA_L0=iMA(0,0,3,0,MODE_SMA,PRICE_LOW,0);
   MA_L1=iMA(0,0,3,0,MODE_SMA,PRICE_LOW,1);
   HA_up=iCustom(0,0,"Heiken Ashi",3,0);
   HA_dw=iCustom(0,0,"Heiken Ashi",2,0);

//задали все данные 

   total=OrdersTotal();
   if(total<1) 
     {
      // Проверка свободной маржи
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // Условие открытие позиции BUY
      if(MA_L1<MA_L0&&Ask<=MA_L0&&MA_0>MA_1&&HA_up>HA_dw)
        {
         Lots=GetSizeLot();
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-Sploss*Point,0,"",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }
      // Условие открытие позиции SELL
      if(MA_H1>MA_H0&&Bid>=MA_H0&&MA_0<MA_1&&HA_up<HA_dw)
        {
         Lots=GetSizeLot();
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+Sploss*Point,0,"",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        }
      return(0);
     }
    
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   
         OrderSymbol()==Symbol())  
        {
         if(OrderType()==OP_BUY)   // длинная позиция открыта
           {
           if(NormalizeDouble (MathAbs(MA_H0-Bid),Digits)<Point)
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                 return(0); 
                }
            // трейлинг-стоп для длинной позиции
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else 
           {
           if(NormalizeDouble (MathAbs(MA_L0-Ask),Digits)<Point)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
               return(0); 
              }
            // трейлинг-стоп для короткой позиции
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
  }

Question: If the position on the current candle is not closed (the conditions have not come), how to close it on the next candle, when it matches MA_0= iMA ( 0, 0, 3, 0, MODE_EMA, PRICE_MEDIAN, 0 );

We have a close condition: crossing the high or low of the current candle, but we need the position to close on the next candle after it is opened.

We can write if ( NormalizeDouble ( MathAbs (MA_0-Ask), Digits )< Point ), but how to fulfill the condition of the second open candle.


If you can answer with code, the example is clearer.

 
sannin:


if the balance changes, pol will be equal to the new balance

This is immediately visible if you do the following

int pol;
Comment("\n balance: ", pol);

pol=AccountBalance();

You can't check anything with this code. And the pol variable must be declared globally, as well as the sig variable.
 
TarasBY:
This code does not check anything. And the pol variable must be declared globally, as well as the sig variable.


well... how to do it... the soment shows the current value of the pol variable

at first, half of the order shows the initial balance

i open an order and my balance is equal to the initial one but if i close in profit or vice versa the balance changes

I need sex to become a new balance under certain conditions and until these conditions are fulfilled, it is equal to the initial balance.

 
borilunad:
For MQL4 code, use SRC and everyone can figure it out and help you!

Thank you I will know.
 
sannin:


well... how to do it... the comment shows the current value of the sex variable

at first, half of the order shows the initial balance

i open an order and my balance is equal to the initial one but if i close in profit or vice versa the balance changes

i need the floor to become a new balance under certain conditions and until the conditions are met the floor is equal to the initial balance

There is a category of people who do not know how to listen, it is almost impossible to help them.
 
TarasBY:
There is a category of people who don't know how to listen, it's almost impossible to help them.


Hello, help me please help me if i need the pol variable to store the balance when the variable sig=1 without changing its value, no matter how long it keeps on displaying, and if sig=1 again i need to store the current one , please tell me the code

agree

Everybody's a smart-ass.

I'm sorry... the thing is, I've been dreading the task for two days...

I wouldn't ask for help.