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

 
Make a global or static boolean variable like flag. When the condition has occurred and flag=true open the order and make flag=false. Now if the order closes, a new order will not open. When the condition has gone, set flag=True again.
 
Roger:
Make a global or static boolean variable of type flag. When the condition is reached and flag=true, open an order and make flag=false. Now, if the order is closed, a new order will not be opened. When the condition has gone, set flag=True again.

How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has closed.

That is, I need to know that the order has been executed, but it has closed n candles ago because the N condition has triggered. And if the condition N has disappeared, and no more than n candles have passed since the close of the order, we should open the order again.

 
Xaoss1990:

How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has been concluded.

That is to say I need to know that the order has been concluded but it has closed n candles ago because of the N condition. And if the condition N has disappeared and no more than n candles have passed since the close of the order, we should open the order again.


Be more active using Alert(), Print() with Logic!
 
Xaoss1990:

Please advise us, gentlemen!

Imagine the situation: a stop is triggered, because of the triggering of the N-th condition. But after a couple of candlesticks, the N-th condition has fallen away. With the help of which function you can open the deal again after the N-th condition falls out. That is, you need to determine that triggered a stop some number of bars ago, and because the N-th condition fell off, re-open the trade!


if programmatically - when opening an order - there is a magik and a comment - you can encrypt the information about which condition the order is opened, in the magik or comment

in general, the stop is not triggered by a condition, but when the price reaches a price level - this order can be closed by a condition

 
Xaoss1990:

How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order is closed.

That is, I need to know that the order has been placed, but has closed n candles ago due to triggering of condition N. And if condition N has disappeared and no more than n candles have passed since the order was closed, I need to open the order again.

You do not want to complicate things too much? After all, the order could have been closed if condition X had been present, although condition N may also have been present.

The solution depends a lot on your position management logic, for example to find orders which have been closed no later than n candlesticks and to check the event N at the moment the order is closed and at the current moment.

 
 int CountH,NewCountH,CountL,NewCountL;
 double ResistH,ResistL;
 
 //========================
 
 int start(){

 //--------------------------
   double bid = Bid;
   double UPPprice = bid+3000.0*Point;
   double LOWprice = bid-3000.0*Point;
   NewCountH=0;
   ResistH=0;
   NewCountL=0;
   ResistL=0;
  
   while(LOWprice<UPPprice)
    {
      CountH=0;
      CountL=0;
      for(int i=1; i<=6000; i++){  
          if(LOWprice> bid)if(iHigh(NULL,60,i)>LOWprice && LOWprice>iLow(NULL,60,i))CountH++;  
          if(LOWprice<=bid)if(iHigh(NULL,60,i)>LOWprice && LOWprice>iLow(NULL,60,i))CountL++;
       } 
      if(CountH>NewCountH){NewCountH=CountH;ResistH=LOWprice;} 
      if(CountL>NewCountL){NewCountL=CountL;ResistL=LOWprice;}   
      LOWprice=LOWprice+5*Point;
    }
 //----------------------------
 
 return(0);
 }
How do I make this cycle "easier"? It takes a very long time to count.
 
DhP:

How do I make this cycle "easier"? It takes a very long time to count.


maybe something I don't understand, but here:

          if(LOWprice> bid)if(iHigh(NULL,60,i)>LOWprice && LOWprice>iLow(NULL,60,i)) CountH++;  
          if(LOWprice<=bid)if(iHigh(NULL,60,i)>LOWprice && LOWprice>iLow(NULL,60,i)) CountL++;
the same condition
 
abolk:


maybe I didn't get it right, but here:

the same condition - at all times CountH equals CountL

No, if the price is higher than Bid, then CountH counts, if it is lower, then CountL counts
 
DhP:
No, If the price is higher than Bid, then CountH? If lower, then CountL


it is possible to speed up the calculation:

reduce i<=6000

 
abolk:


It is possible to speed up the calculation:

a) Reduce i<=6000
b) Calculate only at the beginning of the bar

a) Reduce the number of i can be done, but is not desirable. This is how it takes bars for the year.

b) At the beginning of a bar... This is probably an option. Works on M15.

However, in any case, it counts almost 2 seconds.