Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 209

 
Atlis:

Good evening Dear artmedia70.

I'm coming back to you with the same problem: I still can't figure out how to get the data I need.

You wrote about the concept of searching for a new bar. As I understand it (concept) consists in comparing the time of bars and if the time is different - here's a new bar. Besides, this function displays the data about times of all following bars.

I tried to apply this approach to my task. The first value I get is exactly what I want but then I get data of each next bar.

I don't understand how I can get data from only one (first) bar. Can you tell me please.

Without your code and without understanding what you want to do, it is difficult to tell you anything.
 
artmedia70:
Without your code and without understanding what you want to do, it's hard to tell you what to do.

I don't have a code as such yet: I only have enough intelligence to identify the highs and lows on the required interval.

But I will try to explain what I want to do.

Here is actually an example of what I am trying to achieve:

the purple lines are the highs and lows of the range.

The green is the "reference point" (defined by time).

I need to know the time when the opening price of a candle will go out of the range. The arrow on the picture shows a bar whose open time I need to know and assign its value to a variable.

 
Atlis:

I don't have a code as such yet: I only have enough intelligence to identify the highs and lows on the required interval.

But I will try to explain what I want to do.

Here is actually an example of what I am trying to achieve:

the purple lines are the highs and lows of the range.

The green is the "reference point" (defined by time).

I need to know the time when the opening price of a candle will go out of the range. The arrow on the picture shows a bar whose open time I need to know and assign its value to a variable.

1. For Expert Advisor or indicator?

2. First candle or zero?

 
artmedia70:

1. For an EA or indicator?

2. First candle or zero?



For an EA.

The candlestick is zero.

 
Atlis:


For the EA.

A candlestick is zero.

If the opening price of the current candle is higher/lower than the upper/lower limit of the range, and the opening price of the first candle is lower/lower than/equal to the upper/lower limit of the range, then store the opening time of this candle in a variable with datetime type

Something like this:

//+----------------------------------------------------------------------------+
if (Open[1]<=UpLevel && Open[0]>UpLevel) {
   // Пересекли вверх верхнюю границу диапазона (UpLevel)
   }
if (Open[1]>=DnLevel && Open[0]<DnLevel) {
   // Пересекли вниз нижнюю границу диапазона (DnLevel)
   }
//+----------------------------------------------------------------------------+
 
artmedia70:

If the opening price of the current candle is higher/lower than the upper/lower limit of the range and the opening price of the first candle is lower/lower than or equal to the upper/lower limit of the range, then store the opening time of this candle in a variable with datetime type

Something like this:


Thank you very much.
 

Made an indicator. The indicator value ExtMapBuffer1[i] is obtained from one of three current conditions.

Question, how to get indicator value with shift (the day before yesterday (2) and yesterday (1) )?

 
Forexman77:

Made an indicator. The indicator value ExtMapBuffer1[i] is obtained from one of three current conditions.

Question, how to get indicator value with shift (the day before yesterday (2) and yesterday (1) )?


Well, it's hard to say. Usually iCustom() helps
 
Vinin:

Well, it's hard to say. Usually iCustom() helps.
Thanks, I'll try to figure it out.
 

Good afternoon.

My strategy takes into account the spread, the spread is defined by a function:

double Spread_(){
   double spread = 0.0;
     RefreshRates();
     spread = MathRound((Ask - Bid) / Point);
   return(spread);
}   

But because the spread is constant in the strategy tester, I need a random spread emulator. I want to emulate the changes of spread in the tester in the range of 2 to 3 points (4 digits) in 80% of cases and more than 3 points in 20% of cases. Any ideas how to implement this, or links where such an idea has been solved.

Reason: