Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 114

 
MarkTrade:

I beg your pardon, explain what the mistake is here. I can't figure it out.


for (i=0;i>5<==ошибка;i++)
 
MarkTrade:

I beg your pardon, explain what the mistake is here. I can't figure it out.

Let's break down the string.

for (i=0;i<5;i++)

Let i vary from zero to five. After each iteration the counter will increase by one. Iterations will be calculated until i is less than five. I.e. the loop will work and it will run through five iterations: 0, 1, 2, 3, 4 - these are values of the i loop counter. When i equals five, the loop will terminate

Let's see what you have:

for (i=0;i>5;i++)

You have the i counter initialised to zero, but the iterations of the loop must take place as long as i is greater than five. And it is not initially greater than five. Therefore, the loop does not start.

 
artmedia70:

Let's break down the string

Let i be varied from zero to five. After each iteration the counter will increase by one. Iterations will be calculated until i is less than five. I.e. the loop will work and it will run through five iterations: 0, 1, 2, 3, 4 - these are values of the i loop counter. When i equals five, the loop will terminate

Let's see what you have:

You have the i counter initialised to zero, but the iterations of the loop must take place as long as i is greater than five. And it is not initially greater than five. Therefore, the loop does not start.



Oh, yeah! Thank you! I must have had a black eye.
 
K-o-t:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Gentlemen programmers, please advise how to combine an EA with an indicator?

For example, I took a simple bot mo_bidir.mq4 which trades using its own algorithm and I want it to open trades using its own algorithm but after 3 MA signals

For example on signal - Three Moving Averages:

FastEMA>MediumEMA>SlowEMA (trending up) - bot buys

FastEMA<MediumEMA<SlowEMA (trend down) - bot sells

Inp_Signal_ThreeEMA_FastPeriod = 8;

Inp_Signal_ThreeEMA_MediumPeriod = 38;

Inp_Signal_ThreeEMA_SlowPeriod= 48;

I want my Expert Advisor to trade on 5-minute timeframe and the indicator to give signals from daily or 4hour timeframe, and I want to be able to change timeframes in the settings of bot.

\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I apologize for the repetition, but at least tell me in which forum thread to apply, or should I create a new thread?

I do not know what to do.


What you want to do is called filtering. So do a search on the word "filter", look at a couple of EAs with filtering, and see if you can do what you need.
 
artmedia70:

I'm getting a little confused... :) A problem:

1. There is an open position of 0.1 lot

2. Its TakeProfit value is 50 pips.

3. I calculate its potential profit according to the formula PotentialProfit = Lots*TakeProfit*MarketInfo(Symbol(), MODE_TICKVALUE);

4. from the calculation I get the potential profit of $5.00 (0.1*50*1.0).

The position goes in the red and at some point one more averaging Buy opens, but with 0.2 lot

1. I calculate Breakeven for these two positions. The function has been used for a long time, as required, and I do not have any complaints so far:

2. Perfect. You have calculated the breakeven level, but... if you put the tokens of those two positions on it, they will close at zero. Okay, I think. Now I need to add to this level of the BU as many points as I need to obtain a total profit, equal to the previously calculated - $5.

3. And here is where I get a blockage in my brain. What I do: I take $ 5, divide by the total lot of these two positions (0.1 + 0.2 = 0.3), multiplied by TICK_VALUE

I have 5/(0.3*1.0) = 16.6666 Then I multiply it by Point (0.00016) and add to Breakeven price.

4. Perfect. Takes are transferred there, but it seems to me that the total profit of two Baisers closing at this level is not equal to $5 - it seems to me less. This can be seen from the testing chart. It clearly shows that when one position closes, the balance increase is much greater than when multiple positions are closed at the calculated total take level (you can see these places on the chart by the appearance of the equity line on them). Graph:


Where am I wrong?

I understand that you can print the total profit, but... I want to understand where I could be wrong in my calculations, not the value of the variables. I have printed them already.

( 0.3 * 16 = 4.8 ) < ( 0.3 * 16.66666 = 5 )
I do not know if this is the difference you had in mind, but due to the rounding of 16.6666, the profit will naturally be less than the $5 you planned to get.
 
artmedia70:

I'm getting a bit full of myself... :) The problem:

1. There is an open position of 0.1 lot

2. Its TakeProfit value is 50 pips.

3. I calculate its potential profit according to the formula PotentialProfit = Lots*TakeProfit*MarketInfo(Symbol(), MODE_TICKVALUE);

4. from the calculation I get the potential profit of $5.00 (0.1*50*1.0).

The position goes in the red and at some point one more averaging Buy opens, but with 0.2 lot

1. I calculate Breakeven for these two positions. The function has been used for a long time, as required, and I do not have any complaints so far:

2. Perfect. You have calculated the breakeven level, but... if you put the tokens of those two positions on it, they will close at zero. OK, I think. Now I need to add to this level of the BU as many points as I need to obtain a total profit, equal to the previously calculated - $5.

3. And here is where I get a blockage in my brain. What I do: I take $ 5, divide by the total lot of these two positions (0.1 + 0.2 = 0.3), multiplied by TICK_VALUE

I have 5/(0.3*1.0) = 16.6666 Then I multiply it by Point (0.00016) and add to Breakeven price.

4. Perfect. Takes are transferred there, but it seems to me that the total profit of two Baisers closing at this level is not equal to $5 - it seems to me less. This can be seen from the testing chart. It clearly shows that when one position closes, the balance increase is much greater than when multiple positions are closed at the calculated total take level (you can see these places on the chart by the appearance of the equity line on them). The chart:


Where am I wrong?

I understand that you can print the total profit, but... I want to understand where I could be wrong in my calculations, not the value of the variables. I have printed them already.

I don't understand why it has to be so complicated.
Wouldn't that make it easier?

  double sumprofit=0;
  for (int i=0; i<OrdersTotal(); i++) 
      {
       if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
          {
           if ((OrderSymbol()==Symbol()) 
              {
               if (OrderType()==OP_BUY || OrderType()==OP_SELL) 
                  {
                    sumprofit+=OrderProfit()+OrderCommission()+OrderSwap();
                  }
             }
         }
      }
  if(sumprofit > 5) AllPosClose();//5 ----> суммарный профит позиций
 

or like this

double sumprofit;
  for (int i=0; i<OrdersTotal(); i++) 
      {
       if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
          {
           if ((OrderSymbol()==Symbol()) 
              {
               if (OrderType()==OP_BUY || OrderType()==OP_SELL) 
                  {
                    sumprofit+=OrderProfit()+OrderCommission()+OrderSwap();
                  }
             }
         }
      }
  if(sumprofit > 5) AllPosClose();//5 ----> суммарный профит позиций
  if(sumprofit < -5) Dolivka();//  определенным лотом Sell или Buy
 
Please advise me, I am not a programmer - where in the terminal are the downloaded indicators (how to see and run them). ??? I downloaded and installed them, but I can't find them in the terminal itself?
 
fox6900:
Please advise me, I am not a programmer - where in the terminal are the downloaded indicators (how to see and run them). ??? I downloaded and installed them, but I can't find them in the terminal itself?

how did you install them? Tell us how... maybe we'll have a clue...
 
Can AccountNumber() be read from the dll and how? At least give me a hint where to dig. I mean without passing the function value to the dll, i.e. from the dynamic library itself.
Reason: