yes, sure. here is the ATR code:

Code:
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);



in the first while()
it calculates the ATR of every candle into an arry, included the first incomplete
and later it smoothes the array with an MA which is the Period you choose for the ATR.

But, and this is what i mentioned above. For setting the Stop for an Order, it takes the ATR-value from the last closed candle ( candle[1], which is in Zorro candle[0] ), but the freedom has the developer of the EA to take index 0,1 or 15 to use ATR for Stop.
In an EA to get the value of an indicator it will look like this:

Code:
double = iATR(Symbol(), TF, Period, Shift)



The Shift-parameter here is from what history candle the ATR value should be taken. All indicators in MT4 has this shift parameter.
An EA-Developer should know that, if values are needed as Order-Conditions for TP, SL, BE, Trailing or Exit or whatever, that it is best to take the value at index 1 insteed 0, because of the incomplete candle. But this is also the freedom you have in MT4 and the possibilty to trade like in the example at my last post for breakouts.

And this is the difference between index-counting in MT4 and Zorro which is important to know.

I would not say wrong, they only reflect the realtime situation at the incomplete candle. But for decision-making it is better to take values from complete candles, except for breakout-trades, momentum-trading and to trade with pending orders at exactly at Support/Resistance-Levels.
So this is my call to the future of Zorro, let tick-based calculation involve.
If this will work, then Pending Orders, like Stops and Limits will work too.
Develope a global Parameter, where the user could define, if he needs this or not.
For setting Pending-Orders for entry's it is inevitable.

Another question:

How is it possible to trade a grid with the trend/countertrend (pyramiding/cost averaging) with exact x-Pips spacing between every order?

Last edited by PriNova; 11/21/12 14:51.