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

 
midorum:
iLow
cp
 
silhouette:

I'm a bit stuck on the implementation of the order placing algorithm.

The essence is that there is a ticket, I switch on the enumeration with a condition to find the ticket:

If any of the orders corresponds to a magik, we modify it.

We have another task: if none of the orders corresponds to a Magic, we should set a new pending order. if(OrderMagicNumber()!=magic) will not work here.

How can we implement this condition without resorting to third-party custom functions?

It is very simple. Create some boolean variable. Before processing orders, set it to false. As soon as the order is processed, change it to true. After you have checked all of the orders, check the value of the variable - if it remains false, it means that there has been no order with the needed magic. You open a new order.

 
midorum:

It's very simple. Create a boolean variable. Set it to false before processing orders. As soon as the order is processed, change it to true. After you have checked all of the orders, check the value of the variable - if it remains false, it means that there has been no order with the needed magic. You open a new order.

Thank you!
 
Roman.:
Try to play around with (edit to your needs) Kim's isCloseLastPosByStop - Returns flag to close last position by stop

and NumberOfPositions - Returns the number of positions, and maybe others will suit your question...


THANKS BUDDY, I'LL KEEP DIGGING :D
 

I decided to understand how the ATR indicator works , and at the same time to study its code. I got the gist of it, but it's written strangely.

Here is its start function:

int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=AtrPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=AtrPeriod;i++) AtrBuffer[Bars-i]=0.0;
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      if(i==Bars-1) TempBuffer[i]=high-low;
      else
        {
         double prevclose=Close[i+1];
         TempBuffer[i]=MathMax(high,prevclose)-MathMin(low,prevclose);
        }
      i--;
     }
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
      AtrBuffer[i]=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);
//----
   return(0);
  }
//+----------------

Here is the first block of confusion:

//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=AtrPeriod;i++) AtrBuffer[Bars-i]=0.0;
//----

What is the sense of doing something if the counted_bars value <1. In my opinion, it means that the indicator hasn't counted any bar and I should just exit the function as there are no values yet... What is the catch?

Why AtrBuffer has the index[Bars-i]? I understood that the idea is to set the buffer to 0.0 if there are no values. But it turns out that the value 0.0 is defined only for bars from (Bars) to (AtrPeriod), while fromAtrPeriod to the 0-th bar nothing is written to the buffer. Why?

I do not understand the logic of this code fragment

In the next block:

//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      if(i==Bars-1) TempBuffer[i]=high-low;
      else
        {
         double prevclose=Close[i+1];
         TempBuffer[i]=MathMax(high,prevclose)-MathMin(low,prevclose);
        }
      i--;
     }
//----

In the line:

if(i==Bars-1) TempBuffer[i]=high-low;

Condition if i==Bars-1. It appears that the value of the 1st bar from the beginning of the chart on the left is taken into account... But this is very far away, what good is this value?

 

I need some help!

How can I make an EA close all open and pending orders at a given drawdown level, for example 30%, and then restart it and start all over again?

Files:
 
OrderSend
(  string symbol, int cmd, double volume, double price, int slippage,
double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

Could you please tell me what should be in the datetime expiration parameter in the order placing function, so that the pending order would delete itself after 5 minutes if it has not worked? Is it TimeCurrent()+300 or not?

 
BeerGod:

Could you please tell me what should be in the datetime expiration parameter in the order placing function, so that the pending order would delete itself after 5 minutes if it has not worked? Is it TimeCurrent()+300 or not?

it indicates seconds, if I am not mistaken. so you are right 5 min will be 300. Try to use time of opening without stop and profit and time of closing, print it and there you can compare.
 
Hi all. Love to help out, bet 0.10 stop 200pip what amount do I need to have to sustain 200pip?
 
laveosa:
Hi all. Love to help out, bet 0.10 stop 200pip how much do I need to have to sustain 200pip?
I don't know, it depends on what kind of account you are using, e.g. normal or cent. Sometimes 1 pip for 0.01 lots = 1 cent (x10x200 = 20 USD), and sometimes 1 pip for 0.01 lots = 10 cents (x10x200 = 200 USD).
Reason: