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

 

Hello, the robot has calculation of breakeven for buy and sell orders separately. what should I add to display the total breakeven price for both buy and sell at the same time?



double Average_Price(int type,bool hand_orders,bool use_correct)

{
double pr=0,swap=0,dist_swap=0;
int cnt=0;
double lots=0,correct_sum=0;

for(cnt=OrdersTotal()-1; cnt>=0; cnt--)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()==Symbol() &&
(OrderMagicNumber()==Magic_Number ||(OrderMagicNumber()==0 && hand_orders==true)))
{
if(Get_Ordr_Tip()=="S")
{
continue;
}

if(OrderType()==type)
{
pr=pr+OrderOpenPrice()*PointPrice(OrderLots());
swap=swap+OrderSwap()+OrderCommission();
lots=lots+PointPrice(OrderLots());
}
}
}

if(lots>0)
{
if(use_correct==true)
{
if(type==OP_BUY)
{
correct_sum=Correct_Sum_Buy;
}
else
{
correct_sum=Correct_Sum_Sell;
}
}

if(type==OP_BUY)
{
pr=NormalizeDouble((pr-(swap-correct_sum)*Point)/lots,Digits);
}
else
{
pr=NormalizeDouble((pr+(swap-correct_sum)*Point)/lots,Digits);
}
}

return(pr);
}
 
Anybody here alive? :)
 
Tigerfreerun:
Anybody here alive? :)

Learn how to insert code and someone will come alive.

 

how to convert int to date?

how to find the number of bars between dates taken from the current period? I did this and of course it does not work

int barsBetweenDates(int firstDate, int secondDate){
   if(secondDate < firstDate){
      int temp;
      temp = secondDate;
      secondDate = firstDate;
      firstDate = temp;
   }
   
   return (secondDate - firstDate) / PeriodSeconds(PERIOD_CURRENT); 
}
 

1. oh no

: О

the graph jumps if I move it first (fix scale) and then shrink the price axis

https://ru.files.fm/u/8t68kgss

: (


2. when i reopen the terminal it forgets my screen settings - i have to scroll the price to the left again to be able to move the chart up and down further (fixscale).


i want to direct this to sd.


p.s. muzhichenko, come here, f*ck me!

2018-08-30_8t68kgss
2018-08-30_8t68kgss
  • ru.files.fm
If you want to remove ads for yourself and your file viewers or just want to support us subscribe to a PRO account. This will help us to continue develop services and new features. Thank you!
 

Dear experts, could you please advise me?

When the price reaches a certain level, the order modification function is executed. Sometimes the function is not executed (OFF Quotes) and the price has already bounced. How to make the function continue trying to execute until it wins or make a certain number of attempts even if the condition to execute the function is no longer met.

 
mmaxx:

Dear experts, could you please advise me?

When the price reaches a certain level, the order modification function is executed. Sometimes the function is not executed (OFF Quotes) and the price has already bounced. How to make the function continue trying to execute until it wins or make a certain number of attempts even if the condition to execute the function is no longer met.

So don't reset the condition after it is triggered, you can think of a hundred ways to do it, for example from the modification function itself to make it work until it wins or the condition triggered - raise a flag and run a primitive timer with an assigned trigger time, it all depends on your imagination
 
mmaxx:

Dear experts, could you please advise me?

When the price reaches a certain level, the order modification function is executed. Sometimes the function is not executed (OFF Quotes) and the price has already rebounded. How do I make the function keep trying to be executed until it wins? Or make a certain number of attempts.

Look atKimIVhttps://www.mql5.com/ru/forum/107476/page27
Полезные функции от KimIV
Полезные функции от KimIV
  • 2008.06.16
  • www.mql5.com
В этой теме я буду выкладывать коды своих функций на языке программирования MQL4, приводить примеры их использования и отвечать на вопросы, связанн...
 
@Aleksey Semenov. I'm a beginner, so I couldn't come up with it myself. How to make function work until win ? Maybe there are some code examples?
 
mmaxx:
@Aleksey Semenov. I'm a beginner, so I couldn't come up with it myself. How to make function work until win ? Maybe there are some code examples?
I left you a link. There are both examples and discussion at the start of the thread. Of the ones I know "to win" you can do while.
Reason: