Questions from Beginners MQL4 MT4 MetaTrader 4 - page 204

 

Hello all.

I have one question. I wrote an EA on Martin. When I modify orders and set TakeProfit, it flies to the sky. And this only happens on real account. In the Strategy Tester all is OK, and everything is OK on the demo. I do not understand what is the trick.

//+------------------------------------------------------------------+

double BuyAverange=0, SellAverange=0, SellPrice=0, BuyPrice=0, BuyLot=0,SellLot=0;

for(int i = OrdersTotal()-1; i>=0; i--)

if(OrderSelect(i,SELECT_BY_POS))

if(OrderSymbol()==Symbol())

if(OrderMagicNumber()==Magic)

{

if(OrderType()==OP_BUY)

{

BuyPrice+=OrderOpenPrice()*OrderLots();

BuyLot+=OrderLots();

}

if (OrderType()==OP_SELL)

{

SellPrice+=OrderOpenPrice()*OrderLots();

SellLot+=OrderLots();

}

}

if(b>1&&BuyLot>0)

BuyAverange=NormalizeDouble(BuyPrice/BuyLot+Profit*Point(),Digits());

if(s>1&&SellLot>0)

SellAverange=NormalizeDouble(SellPrice/SellLot-Profit*Point(),Digits());

//+-----------------------------------------------------------

for(int i = OrdersTotal()-1; i>=0; i--)

if(OrderSelect(i,SELECT_BY_POS))

if(OrderSymbol()==Symbol())

if(OrderMagicNumber()==Magic)

{

if(OrderType()==OP_BUY)

{

if(b==1)

{ if(OrderTakeProfit()==0)

if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()+TakeProfit*Point(),Digits(),0,clrGreen)==false)

Print("Errow N",GetLastError());

if (b>1)

if(OrderTakeProfit()!=BuyAverange)

if(Ask<BuyAverange)

if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(BuyAverange,Digits(),0,clrGreen)==false)

Print("Errow N",GetLastError());

}

if (OrderType()==OP_SELL)

{

if(s==1)

if(OrderTakeProfit()==0)

if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(OrderOpenPrice()-TakeProfit*Point(),Digits(),0,clrGreen)==false)

Print("Errow N",GetLastError());

if (s>1)

if(OrderTakeProfit()!=SellAverange)

if(Bid>SellAverange)

if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(SellAverange,Digits(),0,clrGreen)==false)

Print("Errow N",GetLastError());

}

}

 

Colleagues - decided to write here because I don't know where else to go. Please correct - in MT 4 - when saving one default profile - default - when running multiple robots on multiple tabs - in general this theme from below eurobucks, poundbucks, etc. - When you restart the terminal - it is mixed up and when loading the default profile - it is also mixed up - this is VERY inconvenient, I have to manually sort out the sequence - what came after what, etc.


CAN it be fixed?

 
#property strict
#property copyright "Alex Kolodin"
#property link "www."
#property version "1.00"
#property  show_inputs

input color buy =clrGreen;
input color sell =clrCoral;
input int _width=3;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   int i,k=OrdersHistoryTotal(), r=-1;
   string sy=Symbol();
   for(i=0; i<k; i++)
   {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
      {
       if(OrderType()==OP_BUY)
        {
         if(OrderSymbol()==sy)
         {
          TrendCreate(0,"Trendline"+(string)OrderTicket(),0,
                        OrderOpenTime(),
                        OrderOpenPrice(),
                        OrderCloseTime(),
                        OrderClosePrice(),
                        buy,
                        STYLE_SOLID,
                        _width
                        );
        }    
         if(OrderType()==OP_SELL)
              {
               TrendCreate(0,"TrendLine"+(string)OrderTicket(),0,
                        OrderOpenPrice(),
                        OrderOpenTime(),
                        OrderCloseTime(),
                        OrderClosePrice(),
                        sell,            
                        STYLE_SOLID,
                        _width
                        );
              }
          }
         } 
 
 
      }
    }
    
//+------------------------------------------------------------------+
bool TrendCreate(const long chart_ID=0,
const string namename="trendLine",
const int sub_window=0,
datetime time1=0,
double price1=0,
datetime time2=0,

double price2=0,
const color clr=clrRed,
const ENUM_LINE_STYLE style=STYLE_SOLID,
const int width=1,
const bool back=false,
const bool selection=false, 
const bool ray_right=false,
const bool hidden=true,
const long z_order=0)
{

ResetLastError();
 if(!ObjectCreate(chart_ID,namename,OBJ_ARROW,sub_window,time1,price1,time2,price2))
     {
      Print(__FUNCTION__,
            ": не удалось создать линию тренда! Код ошибки = ",GetLastError());
      return(false);
     }
     ObjectSetInteger(chart_ID,namename,OBJPROP_COLOR,clr);
     ObjectSetInteger(chart_ID,namename,OBJPROP_STYLE,style);
     ObjectSetInteger(chart_ID,namename,OBJPROP_WIDTH,width);
     ObjectSetInteger(chart_ID,namename,OBJPROP_BACK,back);
     ObjectSetInteger(chart_ID,namename,OBJPROP_SELECTABLE,selection);
      ObjectSetInteger(chart_ID,namename,OBJPROP_SELECTED,selection);
   ObjectSetInteger(chart_ID,namename,OBJPROP_RAY_RIGHT,ray_right);
   ObjectSetInteger(chart_ID,namename,OBJPROP_HIDDEN,hidden);
   ObjectSetInteger(chart_ID,namename,OBJPROP_ZORDER,z_order);
   return(true);

//
     }Здраствуй, читающий уважаемый(АЯ), вот такой код по идее выдаст трендовую линию по двум точкам. Компилируется, а результата нет. Помогите, спасибо.
 

Good day!

Why is the chart in mt4 different from the chart in mt5? And if possible, how do i transfer the mt5 chart to mt4? (Just my broker uses price data as in mt5, but all my favourite indicators are in mt4)

 

Can you tell me why the postal service is not working?


 
Vitaly Muzichenko:

Can you tell me why sending to the post office is not working?


Maybe from whom and to whom should it be different?

 
Сергей Таболин:

Maybe from whom and to whom should it be different?

I've already tried it, nothing works.

 
Vitaly Muzichenko:

I've already tried it, it doesn't work.

All mailers now require a separate password to be generated for the third party application. Read your mailer's help - most likely you need to generate a separate password.


Plus you need to specify the exact port of the SMTP server, like this:

smtp.ukr.net:465
 
Vladimir Karputov:

All mailers now require you to generate a separate password for a third-party application. Read your email provider's help - you'll probably need to generate a separate password.

Plus you need to specify the exact port of the SMTP server, like this:

Tak-zhe tried - did not go.

The port was prescribed: smtp.ukr.net:465


 
Does it even work with any of the mailers?
Reason: