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

 
baykanur:

src inserted

I do not know what has been commented

there is a discrepancy in the number of profitable deals in the Strategy Tester.

In this form (without control of new bar opening) test ONLY by model: "All ticks..." in strategy tester.

Do not use the indicator values on the 0th bar, if you use not the open prices, but the close prices in them, i.e., change this part of the code - put 1 instead of 0

 
      MA2 = iMA(NULL,0,2,0,MODE_SMA,PRICE_CLOSE,1);
      MA3 = iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,1);
      Fr = iForce(NULL,0,2,MODE_SMA,PRICE_CLOSE,1);

or use open prices, i.e.

 
      MA2 = iMA(NULL,0,2,0,MODE_SMA,PRICE_OPEN,0);
      MA3 = iMA(NULL,0,5,0,MODE_SMA,PRICE_OPEN,0);
      Fr = iForce(NULL,0,2,MODE_SMA,PRICE_OPEN,0);
 
griha:
Good afternoon,
1. I want to open a position for 3-4% of my account according to my money management. Is there a calculator to calculate the required lot size for any pair (or at least the most popular pairs)? Or how do I manually calculate the lot size, for example EURUSD?
2. Terminal Help does not explain what is the "Level" calculated on the "Terminal/Trading" tab. Who can explain what it means?

Maximal lot which you can open on all deposit (see code). Generally, it is more correct to start with two parameters: stops and leverage.

double MaxmaxLots(int cmd) 
{
    double result = 0;
    double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
    double v = MarketInfo(Symbol(), MODE_MINLOT);
    double mult = 100;
    
    while (true) {
        if (AccountFreeMarginCheck(Symbol(), cmd, v + lotStep * mult) > 0) { 
            v = v + lotStep * mult;
        } else {
            mult = mult / 10;
            
            if (mult < 1) {
                if (AccountFreeMarginCheck(Symbol(), cmd, v) > 0) { 
                    result = v;
                }
                break;
            }
        }
    }
    
    return(result);
}         
 
A small suggestion to admins: to make a button - answered question (when someone answers it), and if not answered, the priority questions were at the top of the rating. Although it is probably difficult - programming in general is not easy :) I can, of course, unanswered question, duplicate 10 times, but what good - the forum will not grow from the semantic content, and unnecessary duplicates.
 

Hi !!!! Help me solve one problem. Two indicators in one window CCI and MACD, one has fixed levels the other has floating max and min. How to automate both relative to CCI zero level.

 

Can you tell me how to open only one order per period of time? For example, there is a section between bar 1 and bar 20. During this period, an order should be opened on each fractal, and one order for each fractal. How can this be done?

 
sss2019:

Can you tell me how to open only one order per period of time? For example, there is a section between bar 1 and bar 20. During this period, an order should be opened on each fractal, and one order for each fractal. How can we do that?

The order is opened on the current bar. Have you seen a fractal on the current bar?
 
artmedia70:
The order opens on the current bar. Have you seen a fractal on the current bar?

Several orders may be opened on the current bar. The pending orders are opened at the fractal prices that have been found within a period of time: the lower ones are for sale and the upper ones are for buy. We should make one order open on one fractal.
 
sss2019:

Several orders can be opened on the current bar. The pending orders are opened at the fractal prices that have been found during the period of time, the lower ones are for sale and the upper ones are for purchase. We should make one order open on one fractal.

If you are talking about placing pending orders, I do not understand you. To open an order is to open a market position as I understand it. To set an order is to place a pending order.

Make a check this way. Find a fractal, find its price and time.
Check if there is a pending order with the price equal to the fractal price and if the order is placed at the time of the bar with the fractal.
If not, set one.

 
artmedia70:

If you are talking about placing pending orders, I don't understand you. To open an order is to open a market position as I understand it. To set an order is to place a pending order.

Make a check this way. Find a fractal, find its price and time.
Check if there is a set order with the price equal to the fractal price and time of the bar with the fractal.
If not, place it.


If there are two fractals with the same price, we should open two orders, but only one order will open. And if we only check by time, then at the opening of a new candle, the repeated orders will be opened by the same fractals.
 
sss2019:

And if there are two fractals with the same price, we should open two orders and only one order will open. And if we only check by time, then at the opening of a new candle, the repeated orders will be opened by the same fractals.

That's why we need to remember the price and the time of the fractal . If the time of the fractal, for which an order has already been placed, coincides with the time of the fractal, then we do not need to place anything; the order is already in place. If the time of the fractal found does not coincide with the time of the fractal, for which an order has already been placed, then it is a new fractal and another order must be placed even if the prices of the two fractals are the same.

We use the time of a fractal to determine whether or not an order is placed on that fractal. And we use the price of the fractal to determine the opening price of the pending order