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

 
Hello again! Help with this triviality for you, because I can't figure it out....

I want to do the following!

When opened first trade at price for example 1.23455, I want that the second trade would be opened when the price will go to 1.23415

PHP code:
double positionTPask=NormalizeDouble(Ask*Point,Digits);
double lastTPask1=NormalizeDouble(Ask-40*Point,Digits);

if (
RSI0<RSIDownLevel&&RSIDownLevel<=RSI1){
TP=NormalizeDouble(Ask+takeprofit*Point,Digits);
if (
OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,TP,NULL,Magic)==-1)Print(GetLastError());

if (
positionTPask1>lastTPask1){
if (
takeprofit!=0)TPm=NormalizeDouble(Ask+takeprofit*Point,Digits);
if (
OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,TPm,NULL,Magic)==-1) Print(GetLastError());
}}

And I open 2 orders at one price at once...
Is this correct? Check it out...
 

sviter-pro:
Здраствуйте еще раз! Помогите с этой банальностью для вас, ато я разобраться не могу....

Хочу сделать следующее! 

Когда открывается первая сделка по цене к примеру 1.23455, то хочу что бы вторая сделка открывалась когда цена пойдет на 1.23415

double positionTPask = NormalizeDouble(Ask * Point, Digits);
double lastTPask1 = NormalizeDouble(Ask - 40 * Point, Digits);

if (RSI0 < RSIDownLevel && RSIDownLevel <= RSI1){
      TP  = NormalizeDouble(Ask + takeprofit * Point,Digits); 
      if (OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,0,TP,NULL,Magic)==-1) Print(GetLastError());
      
   if (positionTPask1 > lastTPask1){
      if (takeprofit!=0) TPm  = NormalizeDouble(Ask + takeprofit * Point, Digits); 
      if (OrderSend(Symbol(), OP_BUY, Lot, NormalizeDouble(Ask, Digits), slippage, 0, TPm, NULL, Magic)==-1) Print(GetLastError());
      }}  
And I have 2 orders open at once at the same price...

Is it done right? Would you look at this...

In the first line, I saw a strange thing. I did not look further.

What's this for?

double positionTPask = NormalizeDouble(Ask * Point, Digits);

On a calculator, multiply Ask by Point

I have a very good idea of how to correctly paste the code.

 
sviter-pro:
Hello again! Help with this triviality for you, because I can't figure it out....

I want to do the following!

When my first order opens at 1.23455, I want my second order to open when the price will go to 1.23415

PHP code:
double positionTPask=NormalizeDouble(Ask*Point,Digits);
double lastTPask1=NormalizeDouble(Ask-40*Point,Digits);

if (
RSI0<RSIDownLevel&&RSIDownLevel<=RSI1){
TP=NormalizeDouble(Ask+takeprofit*Point,Digits);
if (
OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,TP,NULL,Magic)==-1)Print(GetLastError());

if (
positionTPask1>lastTPask1){
if (
takeprofit!=0)TPm=NormalizeDouble(Ask+takeprofit*Point,Digits);
if (
OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,TPm,NULL,Magic)==-1) Print(GetLastError());
}}

I opened 2 orders at one price ...
Is this correct? Please check...
You should not dance from Ask-40*Point, but from the price at the opening of 1 position-40*Point.
 

I haven't worked with indicators much, so this may be a simple question, how do I disable the display of the graphical buffer inthe Data window? I want to remove buffer 3 and 4, here is the code:

#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property  indicator_color1 Black
#property  indicator_color2 Yellow
#property  indicator_color3 Black
#property  indicator_color4 Black

//---- input parameters
input int RSIPeriod=14;
input int Levl=50;
input ENUM_TIMEFRAMES TF=PERIOD_CURRENT;
//---- buffers
double RSIBuffer[];
double MABuffer[];
double PosBuffer[];
double NegBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(4);
   SetIndexBuffer(0,RSIBuffer);
   SetIndexBuffer(1,MABuffer);
   SetIndexBuffer(2,PosBuffer);
   SetIndexBuffer(3,NegBuffer);
   
//---- indicator line
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
//----
//---- name for DataWindow and indicator subwindow label
   short_name="RSI("+IntegerToString(RSIPeriod,0,' ')+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexLabel(1,"Levl"+"_"+IntegerToString(Levl,0,' ')+" Price");
   SetIndexLabel(2,"U");
   SetIndexLabel(3,"D");
   

   return(0);
  }

This is modified RSI - buffers are needed there, because calculation is based on past data and I don't want to change buffer size every time (if it is not graphical) and add new data there, so graphical buffers are convenient for my purposes.

 
Alekseu Fedotov:
You should not dance from Ask-40*Point, but from the opening price1position-40*Point.

So read the opening price and dance....

 
Aleksey Vyazmikin:

I haven't worked with indicators much, so this may be a simple question, how do I disable the display of the graphical buffer inthe Data window? I want to remove buffer 3 and 4, here is the code:

This is a modified RSI - buffers are needed there, because calculation is based on past data and I don't want to change buffer size every time (if it is not graphical) and add new data there, so graphical buffers are convenient for my purposes.


I don't know if I understood you correctly.

Try it like this:#property indicator_buffers 2

#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_color1 Black
#property  indicator_color2 Yellow
 
Alexander Voronkov:

I don't know if I've got it right.

Try it like this:#property indicator_buffers 2


It seems you are right! And out of the goodness of my heart, I thought it had to be declared if a graphical buffer was used for calculations.

Thanks!
 
Aleksey Vyazmikin: how to disable the display of the graphical buffer inthe Data Window? I want to remove buffer 3 and 4, here is the code:

to disable the display in the Data window, do the following

SetIndexLabel(2,NULL);  // Запрет в окно Данные буфера 3
SetIndexLabel(3,NULL);  // Запрет в окно Данные буфера 4
 
STARIJ:

To disable the output in the data window, do the following


Thank you. Will this move allow to see the buffers prohibited to output to the window via iCustom?

 
Aleksey Vyazmikin: Thank you. This move will allow you to see the buffers that are not allowed to be output in the data window via iCustom?

iCustom allows you to see only what is in the data window. The penultimate parameter of the function is exactly the number of the buffer visible in the data window

Просмотр и настройка графиков - Графики котировок, технический и фундаментальный анализ - Справка по MetaTrader 5
Просмотр и настройка графиков - Графики котировок, технический и фундаментальный анализ - Справка по MetaTrader 5
  • www.metatrader5.com
Графики в торговой платформе отображают изменение котировок финансовых инструментов во времени. Они необходимы для проведения технического анализа...
Reason: