[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 340

 
dyxaa:

people, how do you close a pending order in n, number of pips if it has not triggered?

It cannot be closed, but it can be deleted.

 

I draw an indicator for training purposes (i.e. I'm learning) and get this result when I change the data:


The red and blue lines don't flow smoothly into each other.

Why does this happen and how do I get around it?

  for(i = limit; i >= 0; i--) 
    {
     cciTrendNow      = iCCI(NULL, 0, CCIPeriod, PRICE_TYPICAL, i);
     cciTrendPrevious = iCCI(NULL, 0, CCIPeriod, PRICE_TYPICAL, i+1);

     if (cciTrendNow > st && cciTrendPrevious < st)
      {
       TrendUp[i+1] = TrendDown[i+1];
       ArrayInitialize( TrendDown[i+1], 0 ); // Попытался обнулить, чтобы обойти некрасивую отрисовку.
      }

     if (cciTrendNow < st && cciTrendPrevious > st) 
      {
       TrendDown[i+1] = TrendUp[i+1];
       ArrayInitialize( TrendUp[i+1], 0 );   // Попытался обнулить, чтобы обойти некрасивую отрисовку.
      }
    }

The problem appears on this part of the code. But how to overcome it - could not figure out or think of something myself. Please advise.

 
dyxaa:

people, how do you close a pending order in n, number of pips if it has not triggered?

Click on the cross!
 
artmedia70:

I wasn't talking about external variables. I was talking about this.

Let's imagine a situation. A decision has to be made according to the last open position.


For the tester:

We create variables, in which we will store the necessary data of the last opened position.

As soon as a new position is opened, we will immediately add the required data into these variables.

When a signal to open a next position comes (for example, after 20 tester minutes), we need to check some criteria, by which we decide on the data of the position to be opened. These criteria, by convention, depend on the previous position opened. We read them from variables (we saved them at the previous opening) and use them as additional data for a new position.

When we open a position, we store the new data about the newly opened position in the variables.


For real:

Let's imagine the same situation, but ... Imagine that after the last position was opened and its data stored in variables, 10 minutes have passed (another 10 minutes have to pass before the next position is opened (we have just assumed this in a 'tester')). And in this interval of time, the Expert Advisor was restarted for some reason.

What happens after the restart of the EA with data of the last opened position, which was stored in variables? They will not exist.

So where do we need to get them? Right - search. This is why we need the function of searching for the necessary data. It is therefore better to find everything at once, when we need it, and not store it in variables, which is really much easier and faster.


Sorry for the late clarification - just got out into the world ... :))



Thank you Artyom. It all makes sense, of course. That is why I am learning to write with functions. But sometimes the logic is not so good. That's why I stumble. The last time I solved this problem by expanding all loop data from one function to another, I took a break from programming in general for a couple of days, to get my bearings. Now I'll keep on going!
 
solnce600:

Gentlemen, please advise how to encode the following algorithm using a loop.

if (iLow (Symbol (),0,1) > iLow (Symbol (),0,10))// if the MINIMUM of the first candle > MINIMUM of the tenth candle

OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-2950*Point,Bid+150*Point, "jfh",123 ); // open the order.

I HAVE TO

If Low 1 and simultaneously Low 2 and simultaneously Low 3...... . ...and simultaneously Low 9 candle> Low 10 candle ( i.e.Low candle from 1 to 9)

/ /open an order.

Thank you.

Still, if I heard your question correctly, the code would be

bool have = true;

for (int i=0; i<10; i++)
  {
   if (Low[i] > Low[10])        // Как вариант:  if ( iLow(Symbol(),0,i) > iLow(Symbol(),0,10) )
    {
     have = false;
     break;
    }
  }

if(have) OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-2950*Point,Bid+150*Point,"jfh",123 );    //открыть ордер.

But that's with the hint of the FAQ. Couldn't have done it without it.

 

I have an idea, but how to do it in real life and how it will work reliably in real life, I don't really know.

The essence is as follows. We should enter the market after placing the owl on the chart immediately after the bar is closed, i.e. at the opening of a new bar. This is the first order. Further, when the order is closed by a TP or a Stop price, we should open an order at the opening of a new bar immediately. How to do it more reasonably?

I understand we should create a variable. Place the open price of the current bar in it. And compare this value with the opening price of the current bar. If the value of the variable is not equal to the opening price of the current bar with the index zero, we will open an order.

Is this the best option?

 
Chiripaha:

I draw an indicator for training purposes (i.e. I'm learning) and get this result when I change the data:


The red and blue lines do not go smoothly into each other.

Why does this happen and how do I get around it?

The problem appears on this part of the code. But how to overcome it - could not find out or think of something myself. Can you tell me please.


Phew!... I've got it figured out... : )))

Now if I could only sort out the rest of the problem it would be so much better. Thanks to all who wanted to help! : ))

I open 2 more exactly the same buffers - they don't draw... What is this wizardry... - Okay, we'll study and search. It's a pity to waste time on the "bike", though. When in this case, when to invent a new one?

 
hoz:

I have an idea, but how to do it in real life and how it will work reliably in real life, I don't really know.

The essence is as follows. We should enter the market after placing the owl on the chart immediately after the bar is closed, i.e. at the opening of a new bar. This is the first order. Further, when the order is closed by a TP or a Stop price, we should open an order at the opening of a new bar immediately. How to do it more reasonably?

I understand we should create a variable. Place the open price of the current bar in it. And compare this value with the opening price of the current bar. If the value of the variable is not equal to the opening price of the current bar with the index zero, we will open an order.

Is it the best option?


If implemented, it will work as reliably in real trading as it does on the demo. But not the fact that it will be profitable.

You have to open an order and that's it . But you haven't formulated in which direction the order should be opened and under what conditions this side is determined.

You don't have to compare anything - simply open an order when a new bar appears (based on your input).

newBars = iBarShift(Symbol(), PERIOD_H1, lastH1BarTime);    // Это было найдено через поиск на форуме

If you have no idea:

"And experience is the son of hard mistakes.
And genius is a friend of paradoxes" (Alexander Sergeyevich for your help).

You need to make (write) an owl and check it experimentally. - I don't think anyone will write the owl for you (for free). To give you a hint is one thing. But to implement ideas (thoughts) is not help, but work.

 
borilunad:
Click on the cross!

Exactly. Brilliantly simple))))

I'm asking for your help) here's putting an order pending let'sbuy stop for example I need it to delete if the price passed 100 points down it can do that?

 
borilunad:
Click on the cross!

Exactly. Brilliantly simple))))

I'm asking for your help) here's putting an order pending let'sbuy stop for example I need it to delete if the price passed 100 points down it can do that?

Reason: