[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 129

 

Greetings all, I downloaded Owl, in the tester everything is normal and sells and buys, I put it on the demo in Alpari, only buys.....

Maybe something is missing there? I don't know how it would work....

/* decompiled deleted */

 

I want my Expert Advisor to buy when the price is close to the price of the mask + indenti_thresholdFromMa. I wrote it this way for a long position:

bool OpenBuy(double fastMa)
{
   int ticket = -1;
   
   //if (Bid > fastMa)
   if (High[0] == fastMa || Low[0] == fastMa)
       ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(fastMa + i_thresholdFromMa * pt), 3, 0, 0, NULL, i_magic, 0);
   
      if (ticket > 0 && OrderSelect(ticket, SELECT_BY_TICKET == true))
 
   return (true);
}

The value offastMa is passed through the function parameters. Then I compare values of the current high and low with the value of thefastMa fast stroke.

If the value of high or low is equal to the value of thefastMa fast valve, then logically an order should be opened at the price (value of thefastMa fast valve + offset from iti_thresholdFromMa).

The function doesn't work. What is the reason? The Expert Advisor does not send any errors to the journal.

 
hoz:

I want my Expert Advisor to buy when the price is close to the price of the mask + indenti_thresholdFromMa. I wrote it this way for a long position:

The value offastMa is passed through the function parameters. Then I compare values of the current high and low with the value of thefastMa fast stroke.

If the value of high or low is equal to the value of thefastMa fast valve, then logically an order should be opened at the price (value of thefastMa fast valve + offset from iti_thresholdFromMa).

The function doesn't work. What is the reason? The Expert Advisor does not send any errors to the journal.

Good evening, you are in the middle of the night!

Equals between fractions will never be fixed! The ticks will slip and there will be no signal. That's why it's better this way:

   if (High[0] >= fastMa && Low[0] <= fastMa)
 

I agree with Boris, but I would also add that any price comparison is better done as follows

not Bid>fastMA but Bid-fastMA>Zero

Not High[0]>=fastMA , but High[0]-fastMA>-Zero , and so on:)

In the global section:

#define Zero 0.00000001 , or something similar.

 
tara:

I agree with Boris, but I would add that any price comparison is better done as follows

not Bid>fastMA but Bid-fastMA>Zero

Not High[0]>=fastMA , but High[0]-fastMA>-Zero , and so on:)

In the global section:

#define Zero 0.00000001 , or something similar.

And I agree with Alexei, but I didn't go into detail, just corrected the obvious incorrectness! The rest will all be found by checking, tasting to one's own taste.
 

Alexey and Boris thank you for your valuable comment.

#define Zero 0.00000001 , I think it would be very small :) I suppose you can safely put half a point here or a spread point...

 
hoz:

Alexey and Boris thank you for your valuable comment.

#define Zero 0.00000001 , I think it would be very small :) I suppose you can safely put half a point here or a spread point...

Try putting a variable instead of Zero and that's how you determine the necessary spacing! And most likely you will have to leave it, because its value will change depending on the state of the market.
 
borilunad:
Try putting a variable instead of Zero and that's how you define the necessary clearance! And most likely you should leave it, because its value will change depending on the state of the market.


Yes, if there is a variable, we should test it and observe the market results. In the meantime, I am writing it to run it in the tester and identify strengths and weaknesses of my TS.

This is my logic:

bool OpenBuy(double fastMa, double slowMa)
{
   int ticket = -1;
   
   //if (Bid > fastMa)
   //if (High[0] == fastMa || Low[0] == fastMa)
   if ( (MathAbs(High[0] - fastMa) <= 1 * pt ) || ( MathAbs(Low[0] - fastMa) <= 0.1 * pt) )
       ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(fastMa + i_thresholdFromMa * pt), 3, 0, 0, NULL, i_magic, 0);
   
      if (ticket > 0 && OrderSelect(ticket, SELECT_BY_TICKET == true))
 
   return (true);
}

I've put 1 in place of the variable clearance for now for the test, and then I'll put it in the external one.

As I understand it will be the most correct variant. If the price touches the bar or not, it will be important to get a signal. The candlestick has two ends (high and low). It means we check by its 2 extremums. That is why I wrote the gap to be shorter than 1.

But I wonder if it opens at the distance ofi_thresholdFromMa(indent), i.e. not from the wrist, but from the candle's extremum.

I will ask you not to pay attention to the condition for entering in the function of opening, of course I will include it in the signal function.

Here is a screenshot, for example,

Screenshot of the moment

The red ball is fastMA.i_thresholdFromMa(indent from the waving) is 5 in external variables. All other conditions are buy. Here we see 2 blue stop orders below the red fastMa. I do not see any logic here. The order is sent precisely at the priceND(fastMa + i_thresholdFromMa * pt) and I can see it in the given function...

 
hoz:


Yes, if variable, it should be tested and observed in the market, what kind of results it shows. In the meantime, I am writing this to run it in the tester and identify strengths and weaknesses of the TS.

This is my logic:

I've put 1 in place of the variable clearance for now for the test, and then I'll put it in the external one.

As I understand it will be the most correct variant. If the price touches the bar or not, it will be important to get a signal. The candlestick has two ends (high and low). It means we check by its 2 extremums. That is why I wrote the gap to be shorter than 1.

But I wonder if it opens at the distance ofi_thresholdFromMa(indent), i.e. not from the wrist, but from the candle's extremum.

I will ask you not to pay attention to the condition for entering in the function of opening, of course I will include it in the signal function.

Here is a screenshot, for example,

The red check mark is fastMA.i_thresholdFromMa(indent from the waving) is 5 in external variables. By all conditions the rest are buy. Here we see 2 blue stop orders below the red fastMa. I do not see any logic here. The order is sent exactly at the priceND(fastMa + i_thresholdFromMa * pt) and I can see it in the given function...

If you want the position to open earlier, in the middle of a bar, you have to specify Low bar for the Bai and High bar for the Sall.

   if ( MathAbs(fastMa - Low[0]) <= 1 * pt )//для бая

   if ( MathAbs(High[0] - fastMa) <= 1 * pt )// для сэлла
   
 
borilunad:

If you want the position to open earlier, in the middle of a bar, you must specify Low bar for the Bai and High bar for the Sall.

if ( MathAbs(fastMa - Low[0]) <= 1 * pt )//для бая

   if ( MathAbs(High[0] - fastMa) <= 1 * pt )// для сэлла


Well, you don't have to do it earlier. I do not know from which side the candle approaches the mask. Top or bottom. That's the question. That's why it's inappropriate. Isn't it?

Anyway, the open price in my function OrderSend() is different and anyway it is higher than the mask:

Here I print the values in the function:

//+-------------------------------------------------------------------------------------+
//| Открытие длинной позиции                                                            |
//+-------------------------------------------------------------------------------------+
bool OpenBuy(double fastMa, double slowMa)
{
   int ticket = -1;
   
   if ( (MathAbs(High[0] - fastMa) <= 1 * pt ) || ( MathAbs(Low[0] - fastMa) <= 0.1 * pt) )
   {
       if ((fastMa + i_thresholdFromMa * pt) > Ask)            // Проверка что цена открытия выше Ask, т.к. у нас вход отложенником
      Print("fastMa = ", DoubleToStr(fastMa,Digits));
      Print("i_thresholdFromMa = ", DoubleToStr(i_thresholdFromMa * pt,Digits));
       ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(fastMa + i_thresholdFromMa * pt), 3, 0, 0, NULL, i_magic, 0);
      Print("OrderOpenPrice() = ", DoubleToStr(OrderOpenPrice(),Digits));
   }
      if (ticket > 0 && OrderSelect(ticket, SELECT_BY_TICKET == true))
 
   return (true);
}

This is what the log shows:

2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: delete #110 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: modify #110 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: OrderOpenPrice() = 1.29820
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: open #110 buy stop 0.10 EURUSD at 1.29820 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: i_thresholdFromMa = 0.00050
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: fastMa = 1.29770
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: delete #109 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: modify #109 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: OrderOpenPrice() = 1.29820
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: open #109 buy stop 0.10 EURUSD at 1.29820 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: i_thresholdFromMa = 0.00050
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: fastMa = 1.29770
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: delete #108 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: modify #108 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: OrderOpenPrice() = 1.29820
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: open #108 buy stop 0.10 EURUSD at 1.29820 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: i_thresholdFromMa = 0.00050
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: fastMa = 1.29770
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: delete #107 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: modify #107 buy stop 0.10 EURUSD at 1.29820 sl: 1.29520 tp: 1.30520 ok
2013.02.01 15:37:18     2011.01.12 14:02  D_Aleks_first_pattern EURUSD,H1: OrderOpenPrice() = 1.29820
2013.02.01 15:37:14     D_Aleks_first_pattern EURUSD,H1: loaded successfully

It is obvious, that the opening price should be set by me. You are being calculated. A gap is added to the machine value. And you can see it in the print...