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.
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 ""externstring A1 = "Объем сделки. Если i_lots = 0, то считается в процентах";
externdouble i_lots = 0.1;
externstring A2 = "Управление рисками";
externdouble i_sl = 15,
i_tp = 10;
externint slippage,
price_b,
price_a;
externstring Z1 = "=== Прочие настройки ===";
externstring i_openOrderSound = "ok.wav";
externint 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 parameterspriceForBuy 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().
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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!
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!
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.
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!
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?)
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:
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:
Where is the error coming from? I have already defined these parameters in functionGetPriceToInput().
and what is the pretzel & after double for (I honestly don't know)?
It's an obsession with wanting to pass parameters by reference. :-)