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

 
Rewerpool:
That's a nice touch. Removed from the code.

Stop is now twitching at every tick )))))

Add it.

          double    OOP = OrderOpenPrice(),
                    OSL = OrderStopLoss(),
                    OTP = OrderTakeProfit();
          if ((OSL!=0&&stoploss==0) && (OTP!=0&&takeprofit==0)) continue;
 

Good evening again. Full gist of the question.

I am putting an EA (working) in the Market. MT4 platform. I can display a single file. A file of the Expert Advisor. It should pass the validity, but it cannot because it is an EA without indicators. They are in separate files. The Expert Advisor works with four indicators. They have to be somehow attached to the Expert Advisor. You have to specify the path, i.e., write them in the Expert Advisor. What? and Where? Please advise which form and how to do this.

From what I understand, we have to use the "Resources" . I do not know how to register it correctly in the Expert Advisor. Maybe you know some other solutions.

Thank you .

Here's what it says when validity fails

 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2]01 00:00:00 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\HA_Smooth.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\HA_Smooth.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\TrendLord.ex4' [2] 2016.04.01 00:00:00 cannot open file 'MQL4\indicators\TrendLord.ex4' [2] 2016.04.01 00:00:05 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2] 2016.04.01 00:00:05 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2] 2016.04.01 00:00:0504.01 00:00:05 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2] 2016.04.01 00:00:05 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2] 2016.04.0101 00:00:05 cannot open file 'MQL4\indicators\HA_Smooth.ex4' [2] 2016.04.01 00:00:05 cannot open file 'MQL4\indicators\HA_Smooth.ex4' [2] 2016.04.01 00:00:05 cannot open file 'MQL4\indicators\TrendLord.ex4' [2] 2016.04.0101 00:00:05 cannot open file 'MQL4\indicators\TrendLord.ex4' [2] 2016.04.01 00:00:10 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2] 2016.04.01 00:00:10 cannot open file 'MQL4\indicators\Heiken_Ashi_Smoothed1lime.ex4' [2] 2016.04.01 00:00:10 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2] 2016.04.01 00:00:10 cannot open file 'MQL4\indicators\MA in Color_wAppliedPrice.ex4' [2]

 
Evening, how do you make a slip? I've searched all over the internet, can't find anything....
 
Oleksandr Kulibaba:

Good evening again. Full gist of the question.

I am putting an EA (working) in the Market. MT4 platform. I can display a single file. A file of the Expert Advisor. It should pass the validity, but it cannot because it is an EA without indicators. They are in separate files. The Expert Advisor works with four indicators. They have to be somehow attached to the Expert Advisor. You have to specify the path, i.e., write them in the Expert Advisor. What? and Where? Please advise which form and how to do this.

From what I understand, we have to use the "Resources" . I do not know how to register it correctly in the Expert Advisor. Maybe you know some other solutions.

Thank you .

Here is what it says if validity is not passed

I think it's sad that you have written an EA and cannot add indicators to it.

 
Vladislav Andruschenko:

It's sad that you wrote an EA and can't add indicators to it to make it work.

 
Oleksandr Kulibaba:
I'm working it out. I hope it works out. Your answer didn't help me at all. And I'm not sad at all, on the contrary I'm excited. And I'll do it.
 
//+------------------------------------------------------------------+
//|                                                        temp1.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int    Slippage=29;

int Slippage1;

int OnInit()
  {
//---
   Slippage1=Slippage;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  if(Slippage1!=Slippage){Slippage1=Slippage; Print("Параметры изменены");}
//---
   Comment(Slippage1);
  }
//+------------------------------------------------------------------+

Greetings.

A new tick should assign the value of input parameterSlippage to the variableSlippage1,outputthe value ofSlippage1 in a comment and show"Parameters changed"in the log.

What it does not work with: WhenSlippage1!=Slippage, the"Parameters changed" option is not printed in the log.

Question: What am I doing wrong?

 
Andrey Sokolov:

Greetings.

A new tick should assign the value of input parameterSlippage to the variableSlippage1,outputthe value ofSlippage1 in a comment and show"Parameters changed"in the log.

What it does not work with: WhenSlippage1!=Slippage, the"Parameters changed" option is not printed in the log.

Question: What am I doing wrong?

If an input parameter is changed, then the Slippage1 variable is assigned the value of Slippag in OnInit.Accordingly, they cannot be unequal.

extern int    Slippage=29;

int Slippage1 = 0;

int OnInit()
  {
//---
   //Slippage1=Slippage;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  if(Slippage1!=Slippage){Slippage1=Slippage; Print("Параметры изменены");}
//---
   Comment(Slippage1);
  }

 
Alexey Viktorov:

If the input parameter is changed, the Slippage1 variable is set to Slippag in OnInit.Accordingly, they cannot be unequal.

Yes, thank you. I just got it.

 

Hello, please help me with the error that occurs in the tester when I try to modify an order (transfer to Breakeven): I put the OrderOpenPrice() function instead of SL, but the tester shows error1 (according to the documentation it means that there is an attempt to passunchanged values as parameters to the function). I attach the code! Thank you in advance!

void DeleteOrderFunction2() //function that deletes the second pending order and saves the second order to Breakeven on a certain evening

{

bool flag = false;

if (FlagDeleteSecondOrder2 == true)

{

if(DayOfWeek() == DAYOFWEEK && //if a weekday is selected

Hour() == 22 //if evening

)

{

if(BuyCount() == 1 && if(there is an open Buy order

SellStopCount() == 1 //and there is a sell pending order

)

{

for( int i = 0; i < OrdersTotal(); i++) //create orders

{

OrderSelectX(i, SELECT_BY_POS, MODE_TRADES;)

switch(OrderType())

{

case OP_BUY: if(OrderProfit() > 0 &&

Bid > OrderOpenPrice()

)

{

OrderModifyX(OrderTicket(),OrderOpenPrice(),OrderTakeProfit(),0,Arrow_Color);

flag =true;

}

break;

case OP_SELLSTOP: if(flag==true)

{

OrderDeleteX(OrderTicket(), Arrow_Color);

}

break;

}

}

}

if(SellCount() == 1 && // if there is an open Sell order

BuyStopCount() == 1 //and there is a Buy pending order

)

{ Print("IS!!!!");

for( int i = 0; i < OrdersTotal(); i++) //create orders

{

OrderSelectX(i, SELECT_BY_POS, MODE_TRADES;)

switch(OrderType())

{

case OP_SELL: if (OrderProfit() > 0 &&

Ask < OrderOpenPrice()

)

{

OrderModifyX(OrderTicket(), OrderOpenPrice(),OrderTakeProfit(),0, Arrow_Color);

flag = true;Print("flag =", flag);

}

break;

case OP_BUYSTOP: if(flag == true)

{

Print("flag =", flag);

OrderDeleteX(OrderTicket(), Arrow_Color);

}

break;

}

}

}


}


}

}

Reason: