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

 
MakarFX:

I hope everything is clear.

//+------------------------------------------------------------------+
//|                                             AC_AO_Makar.mq4      |
//|                                               fxmvv@mail.ru      |
//+------------------------------------------------------------------+
extern double Lots       =  1;
extern double StopLoss   =  10000;
extern double TakeProfit =  10000;
//+------------------------------------------------------------------+
int init(){}
int deinit(){}
int start()
{
   int total;
   if(Bars < 10)
   {
      Print("Bars less than 10");
      return(0); 
   } 
//====================================   
   bool Buy  =  (iCustom(NULL,0,"FiboBars2",10,5,1)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,1));
//help      
   bool Sell =  (iCustom(NULL,0,"FiboBars2",10,5,0)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,0));
//=================================
//Возвращает общее количество открытых и отложенных ордеров
   total = OrdersTotal(); 
   if(total < 1) // ордеров нет
   {
      if (Buy)
       if(OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-StopLoss*Point,
           Bid+TakeProfit*Point) == 0) 
           Sleep(5000);
//help  OrderSend(Symbol(),OP_BUY,lot,price,slippage,stoploss, 
//takeprofit,      comment,magic,expiration,arrow_color);
      if(Sell)
       if(OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+StopLoss*Point,
          Ask-TakeProfit*Point) == 0) 
           Sleep(5000);
   }
//==================================== OrderClose,
   else // есть ордер
   {
     OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
      if (OrderSymbol() != Symbol()) return(0);
       
        if(OrderType() == OP_BUY && Sell) 
          OrderClose(OrderTicket(),OrderLots(),Bid,5);
        if(OrderType() == OP_SELL && Buy) 
          OrderClose(OrderTicket(),OrderLots(),Ask,5);
   }
}

Excuse me, please look at the box. The trades are not opening.

 
darirunu1:

Sorry, look at this please. no trades open.

0_о

It doesn't look like an EA for trading, make it like this and put the conditions there



Tomorrow I will give you more details.

 
MakarFX:

0_о

It doesn't look like an EA for trading, do that and put the conditions in there



More details tomorrow.

That's how it was done.

 
darirunu1:

This is how it was done.

This is what a clean template looks like

//+------------------------------------------------------------------+
//|                                                       Expert.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
What version of MetaEditor do you have?
 
MakarFX:

This is what a clean template looks like

What version of MetaEditor do you have?

I found a light on the net and just copied it there to check for errors. There were a couple of minor ones.Corrected them. So there were originally the AO and AC indicators. I put in the ones I needed.

 
darirunu1:

I found a light on the internet and just copied it in there to check for errors. There were a couple of minor ones.Corrected. So there were originally the AO and AC indicators. I put in the ones I wanted.

Why did you write it that way?

//====================================   
   bool Buy  =  (iCustom(NULL,0,"FiboBars2",10,5,1)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,1));
//help      
   bool Sell =  (iCustom(NULL,0,"FiboBars2",10,5,0)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,0));
 
MakarFX:

Why did you write it that way?

To open a trade if each has two of the same buffers, that is either two red or two green buffers.

 
darirunu1:

To open a trade, if each has two of the same buffers, that is either two red or two green.

You didn't read carefully or you didn't read...

what you wrote is not comparing the values of the two indicators

And why would you compare "FiboBars2" and "FiboBars_3" if "FiboBars_3" already does?

 
MakarFX:

You didn't read carefully or you didn't read...

What you wrote is not a comparison of values of two indicators

And why would you compare "FiboBars2" and "FiboBars_3" if "FiboBars_3" already does?

I understand everything and have read all about the description of the indicators, but I need it this way. I can share the parameters in a private message later and what I want to get as a result.

 
darirunu1:

I understand everything and have read all the descriptions of the indicators, but I need it this way. I can share the parameters and what I want to end up with in a private message.

bool Sell;
bool Buy;

if(iCustom(_Symbol,Period(),"FiboBars_3",12,24,48,2,0)==1)
  {Sell=true; Buy=false;}
if(iCustom(_Symbol,Period(),"FiboBars_3",12,24,48,2,1)==1)
  {Sell=false; Buy=true;}

This is an example on the values in the screenshot