[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 463

 
001:
I don't know how to sum up (Close[1]-Open[1])+(Close[2]-Open[2]) etc. for N periods (applicable to the indicator).
And what do you mean by period? N candlesticks or N chart periods?
 

Good afternoon. 2 questions with your permission:

1) OrderSelect(0,SELECT_BY_POS,MODE_HISTORY); - in this way will I select the order I just closed?
2) I wrote a pretty simple martingale based EA, it works fine in the tester, but when I run it on live charts, it only opens trades... What is the reason? Why does the EA perform well in the Strategy Tester, but works poorly on a demo account? The code is exactly the same

 
artmedia70:
and what do you mean by period? N candles or N chart periods?

In N candlesticks. The idea is that by comparing the sum of the lengths of bullish candles and the sum of the lengths of bearish candles, in 30 (let's say) candles you can understand by code what type of movement it is.
 
CLAIN:

Good afternoon. Two questions with your permission:

1) OrderSelect(0,SELECT_BY_POS,MODE_HISTORY); - so I will select the order I just closed?
2) I wrote a fairly simple martingale based EA, it works fine in the tester, but when I run it on live charts - it only opens trades... What is the reason? Why does the EA perform well in the Strategy Tester, but works poorly on a demo account? The code is exactly the same


1. Yes

2. What are opening trades? Maybe you don't have a CLOSE condition?

 
How does OrderSwap work, does this function just pass the swap value set by the broker, or does it add up all the swaps charged for each day's transaction into one amount?
 

Hello!

Please help me out. I used this article https://www.mql5.com/ru/articles/1454 The Expert Advisor sends messages to Skype, but cannot send SMS to the phone (SMS sending error). Although, the SMS from Skype to my phone (without the Expert Advisor) goes well. What can be the problem?

Regards.

 
sss2019:
How does OrderSwap work, does this function just pass the swap value set by the broker, or does it add up all the swaps charged for each day's transaction into one amount?

This value is the amount of swaps accumulated by the order during its existence in the market.
 
Hello. I have this question. When using DDE, is it possible to query the terminal from Excel to find out the account status, i.e. ask for "Balance", "Equity", etc. or is it possible to send only quotes via DDE?
 
001:
I don't know how to sum up (Close[1]-Open[1])+(Close[2]-Open[2]) etc. for N periods (applicable to the indicator).

double sum=0;
sum+=iMa(NULL, 0, N, 0, MODE_SMA, PRICE_CLOSE0);  // считаем среднюю цену закрытия
sum-=iMa(NULL, 0, N, 0, MODE_SMA, PRICE_OPEN,  0);  // вычитаем среднюю цену открытия
sum*=N;                                             // умножаем на количество свечей

Something like this

For an indicator we can do things a bit differently

extern int N=30;
int start()  {
   int i,   counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars-1;
   if (limit>1) limit=Bars-N-1;
   
   for (i=limit;i>=0;i--) {
      ExtMapBuffer1[i]=0;
      ExtMapBuffer1[i]+=iMa(NULL, 0, N, 0, MODE_SMA, PRICE_CLOSE, 1);  // считаем среднюю цену закрытия
      ExtMapBuffer1[i]-=iMa(NULL, 0, N, 0, MODE_SMA, PRICE_OPEN,  1);  // вычитаем среднюю цену открытия 
   }
   return(0);
  }
 

Can you tell me which function should close half of the order, OrderClose() or OrderCloseBy()?

And how do I calculate the percentage of volume?

Reason: