[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 424

 
sergeev >>:

приведите здесь вашу функцию открытия ордеров.

int NewOrder(int Cmd,double Lot)

{double TP=0, TP2=0;

double SL=0, SL2=0;

double PR=0;

datetime endtime;


while(!IsTradeAllowed()) Sleep(100);

endtime = TimeCurrent()+4*60*60;


if(Cmd == OP_BUYSTOP)

{

PR=TOP+10*Point;

PR=NormalizeDouble(PR,2);

if(TakeProfit>0)

{

TP=PR+25*Point;

}

if(StopLoss>0)

{

SL=PR-30*Point;

SL=NormalizeDouble(SL,2);

}

}

if(Cmd==OP_SELLSTOP)

{

PR=BOT-7*Point;

PR=NormalizeDouble(PR,2);

if(TakeProfit>0)

{

TP=PR-25*Point;

}

if(StopLoss>0)

{

SL=PR+30*Point;

SL=NormalizeDouble(SL,2);

}

}

if ((TOP-BOT)<115*Point)

int tic=OrderSend(Symbol(),Cmd,Lot,PR,3,SL,TP,"",0,endtime,CLR_NONE);

else

Print("Big difference between TOR and BOT: ",(TOP-BOT));

if(tic<0) Print("Order opening error: ",GetLastError();


return(tic);

[Deleted]  
sanyooooook >>:

а ордер как закрывается? по стоп лосту или функцией OrderClose()

at stop loss or take profit.

 

Hi all...I have a question...where can I see a transaction report...total for the whole period of work...?

[Deleted]  
sergeev >>:
В принципе можно искать ордера в истории и отсортировать их, затем узнать два последних закрытия. Но это вам надо пройтись по всем ордерам истории два раза.

используйте OrderHistoryTotal(), MODE_HISTORY, OrderCloseTime()>0, OrderProfit()

Другим вариантом - чтоб не сканировать два раза историю - это запоминание тикетов открывшихся ордеров и потом определения их профита.

How exactly do you memorise tickets? And how do you understand: to access a ticket, you need to select an order, and to select it, you need to know the ticket...

 
just-me >>:

А как именно запоминать тикеты? И как понимать: чтоб обратиться к тикету - нужно выбрать ордер, а чтоб его выбрать - нужно знать тикет...

you do not need to know the ticket to select an order

[Deleted]  

I'm confused with the marketinfo function and can't calculate the correct spread value for an instrument in the currency of deposit with a given lot size. Can you suggest a correct formula? I need it for both spot and CFD...

[Deleted]  

I have a question for experts - is it possible to make a constant, the first price value received when I start the Expert Advisor?

I want to save this price as a constant, so that all the time the EA is running, I can refer to it. The only question is, how to do it? Because Ask is constantly changing, and I can't find the copying function.

 

make a global variable or just a variable

and insert this not in the start function, but in the init function

int init()
  {
//----
   GlobalVariableSet("Price_Start",Ask);
//----
   return(0);
  }
 
Kesha_k85 >>:

У меня такой вопрос к спецам - есть ли возможность сделать константой, первое полученное значение цены при запуске советника?

Т.е если я запустил советник и в это время цена Ask=1.4444 Я хочу эту цену сохранить как константу, чтобы всё время работы советника можно было к ней орбащаться. Только вот вопрос, как это сделать??? Ведь Ask постоянно меняеться, а функции копирования я нигде не нашёл.


A variation on the theme.


double Price_Start;

int init()
 {
   Price_Start=Ask;
   return(0);
 }


double Price_Start=0;

int start()
 {
   if ( Price_Start<0.001) Price_Start=Ask;
   //....
 }
 
just-me писал(а) >>

How exactly do you memorise tickets? And how do you understand: to refer to a ticket, you need to select an order, and to select it, you need to know the ticket...

https://docs.mql4.com/ru/trading/OrderSelect - see SELECT_BY_POS