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

 
dkfl.zrjdktdbx:

Good evening!!! I have decided to write how to calculate the distance from the price to the nearest order above, and the nearest below. I count up to each order, going through the loop forwards and out of all this I choose the minimum number. Well, this turns out to be such a load of crap! Well, okay, the distance turns out sometimes great, 1162 points or more, I'm almost 100 percent sure well no way, well, okay! But if you divide 1162 by 40, that's four...

And it does come out, look at the log screenshot, there are exactly M equals 4, there in the line after the X+++ ...... I don't get it. Either I'm a moron or I don't understand the normalize double function... I don't get it! Or what? ...... Please tell me, I'm totally confused and am amazed !!!!

Have a look at Kim's function, you might find the solution to your problem here.
 
Thank you!!!!
 

Can you please help me write code to execute the program only when a new bar arrives and ignore the inter-bar ticks? I don't know what's going on.

 
kolaider:

Can you please help me write code to execute the program only when a new bar arrives and ignore the inter-bar ticks? Thank you.


Declare an integer variable before the initialization block. For example, int MyBars;

Then in the initialisation block, assign this variable a value = zero. In the start function write:

if(MyBars<Bars){
  MyBars=Bars;
// пришёл новый бар - выполняем какой-то код.
}
Now tell me, what happens on the next tick? What will end up in the MyBars variable?
 

Vladimir, I daresay nothing will happen. The MyBars variable will still contain Bars :(

 
kolaider:

Please help, how can I write code to execute the program only when a new bar arrives and ignore the inter-bar ticks? Thank you.


or so -

Declare an integer variable before the initialisation block. For example, int g_time.

In the start function write:

//------- : ждём следующий бар
   if (g_time == Time[0]) return (0); // возврат на начало кода, если условие не выпоняется программа работает дальше
       g_time =  Time[0]; 
 
elmucon:


or so -

Declare an integer variable before the initialisation block. For example, int g_time

In the start function write:


You shouldn't be writing here. I would have deleted your post.
 
tara:

You shouldn't be writing here. I would have deleted your post.

I don't understand. Why not?
 
DhP:

Try to use the SRC (there's a button at the top of the text box) to insert your codes. It will be easier to read your posts.

I've noticed your search for shadows (top_ten=High-Close;). Why do you subtract Close and not Open? Think about it.

A white candlestick closes on a close, so the upper shadow will be counted as close, and if it is open, then it will be the upper shadow + the candlestick body
 
frixer:
A white candlestick is closed by close, therefore the upper shadow will be considered as such; if it is open then it will be the upper shadow + the candlestick body


Upper shadow (High-MathMax(Open. Close))

Low shadow (MathMin(Open, Close)-Low)