[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 511

 

Good evening! I'm stumped. I have two orders open in the tester, one with takeprofit, the other without it at all.

They both take takeprofit at once!!!!

I've passed this place eight times in the tester. I can't understand it!

 
Dimka-novitsek:

Good evening! I'm stumped. I have two orders open in the tester, one with takeprofit, the other without it at all.

They both take takeprofit at once!!!!

I've passed this place eight times in the tester. I can't understand it!


Looks like a clone double! Try it on Demo! Tell us about it later!

So look, where the SL triggered, the loss, and where the TP, the profit. That's right!

Check what the log says? So, step by step trace all the actions!

Only in the tester pass doubles! On the demo, moreover, on the Real will be 1, and the second will not pass, there will be a lot of mistakes!

 
hoz:
The question is this. If I want to place a Limit Pending Order which will trigger exactly at the opening of the Day Bar, i.e. the bar on TF D1. How should I implement it? I do not really understand the logic. After all, I do not need to put a simple Limiter, but a Limiter that will work exactly at a certain time, i.e. at the opening of a new bar of the day.
First of all, decide with terminology - "Limit that will trigger exactly at a certain time" - what does "Limit trigger" mean? And the more you explain this magic process - the easier it will be to implement it in real life. Just in case, read about pending orders.
 
Dimka-novitsek:

Good evening! I'm stumped. I have two orders open in the tester, one with takeprofit, the other without it at all.

They both take takeprofit at once!!!!

I've passed this place eight times in the tester. I can't understand it!

Maybe you can share a secret - "Why create a clone of an open order??? Can't you open ONE order with a larger lot??? ;)
 
It's a strategy. I might take a screenshot of it now. Oh, my older brother's here. I can't make it in time. It's a weird situation, though.
 
is it correct to compare datetime formats like this?
datetime t=OrderCloseTime();
             datetime t1=Time[1];
             datetime t0=Time[0];
             if(t1>=t&&t<t0){
               p++;
             }
 
Dimka-novitsek:
This is a strategy. I might take a screenshot of it now. Oh, my older brother's here. I can't make it in time. It's a weird situation.

When Diman, will you be able to use a PERSONAL CAMPAIGN?)

Have you made any money in a year on the real world? It's like the START amounts allocated to you, isn't it?)

 
TarasBY:
First of all, define the terminology - "the limit which will be triggered exactly at a certain time" - what does it mean "the limit will be triggered"? And the more details you give about this magic process - the easier it will be to implement it in real life.


Yes, I misspoke. I mean, basically. If it's clear here, the pendulum is only put on price.

Here's the code:

//+------------------------------------------------------------------+
//|                                                       2 Days.mq4 |
//|                                                              hoz |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "hoz"
#property link      ""

extern string    A1 = "Объем сделки. Если i_lots = 0, то считается в процентах";
extern double    i_lots = 0.1;
extern string    A2 = "Управление рисками";
extern double    i_sl = 15,
                 i_tp = 10;
extern int  slippage,
            price_b,
            price_a;

extern string    Z1 = "=== Прочие настройки ===";
extern string    i_openOrderSound = "ok.wav";
extern int       i_magicNumber = 400021;

double firstBarClosed,
       secondBarClosed;
 
// Идентификаторы типов сигналов
#define SIGNAL_BUY              1                     // Сигнал на покупку
#define SIGNAL_SELL            -1                     // Сигнал на продажу
#define SIGNAL_NO               0                     // Нет сигнала

#include <stderror.mqh>

int init()
{
   
   return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//+-------------------------------------------------------------------------------------+
//| Получение рыночных данных                                                           |
//+-------------------------------------------------------------------------------------+
//FindOrders()
//+-------------------------------------------------------------------------------------+
//| Получение рыночных данных                                                           |
//+-------------------------------------------------------------------------------------+
void GetMarketInfo()
{
  price_b = MarketInfo(Symbol(),MODE_BID);
  price_a = MarketInfo(Symbol(),MODE_ASK);
}
//+-------------------------------------------------------------------------------------+
//| Открытие позиций                                                                    |
//+-------------------------------------------------------------------------------------+
bool Trade(int signal, double& priceForBuy, double& priceForSell)
{
 // FindOrders();
  priceForBuy = NormalizeDouble(priceForBuy,Digits);
  priceForSell = NormalizeDouble(priceForSell,Digits);
  
  if(!IsTesting())
     GetMarketInfo();
     
  if (signal == SIGNAL_BUY)
     if (!OrderSend(Symbol(),OP_BUYLIMIT, i_lots,priceForBuy,slippage,i_sl,i_tp,"",i_magicNumber,3))
     return(false);
     
  if (signal == SIGNAL_SELL)
     if (!OrderSend(Symbol(),OP_SELLLIMIT,i_lots,priceForSell,slippage,i_sl,i_tp,"",i_magicNumber,3))
     return(false);
     
  return(true);
}
//+-------------------------------------------------------------------------------------+
//| Получение цены входа в покупку или в продажу                                        |
//+-------------------------------------------------------------------------------------+
double GetPriceToInput()
{
  firstBarClosed = iClose(Symbol(),1440,2);
  secondBarClosed = iClose(Symbol(),1440,1);
    
  {
    double deltaForSell = (firstBarClosed - secondBarClosed)/2;
    double priceForSell = secondBarClosed - deltaForSell;
    
    return(priceForSell);
  }  

  {
    double deltaForBuy = (secondBarClosed - firstBarClosed)/2;
    double priceForBuy = secondBarClosed + deltaForBuy;  
    return(priceForBuy);
  }
}
//+-------------------------------------------------------------------------------------+
//| Генерация сигнала закрытия, покупки или продажи                                     |
//+-------------------------------------------------------------------------------------+
int GetSignal()
{
  if(firstBarClosed > secondBarClosed)
  return(SIGNAL_BUY);

  if(firstBarClosed < secondBarClosed)
  return(SIGNAL_NO);
}
//+-------------------------------------------------------------------------------------+
//| Функция Start                                                                       |
//+-------------------------------------------------------------------------------------+
int start()
{
  int signal = GetSignal();
    
    if (signal != SIGNAL_NO)
      if(!Trade(signal, priceForBuy, priceForSell))
      return(0);

  return(0);
}


The question, in fact, is not very complicated. I have passedformal parameters priceForBuy and priceForSell into the Trade(int signal, double& priceForBuy, double& priceForSell) function. The parameters are passed by the links. Isn't it done this way? The functions are local, not global.

An error has occurred during the compilation:

'priceForBuy' - variable not defined    E:\Insall'd soft's\Forex\Admiral Markets\experts\2 Days.mq4 (117, 25)
'priceForSell' - variable not defined   E:\Insall'd soft's\Forex\Admiral Markets\experts\2 Days.mq4 (117, 38)

Where is the error coming from? I have already defined these parameters in functionGetPriceToInput().

 
What is the pretzel & after double for (I honestly don't know)?
 
YOUNGA:
and what is the pretzel & after double for (I honestly don't know)?

It's an obsession with wanting to pass parameters by reference. :-)