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

 
belck:

after the first function no longer works


What condition does it fail before?
 
sergeev:

What condition doesn't work at all?

the first condition stops closing orders.

And the second one doesn't work either.

i.e. if the conditions are fulfilled, the trades continue to be open.

 
Somewhere here on this site I saw an article about such a miracle of engineering as "a program for code design ", and it seemed to me that this is a program for visual representation of all conditions, but I never finished the article, and I forgot the name, maybe someone will prompt whether this miracle exists at all?
 
The following code draws a line below the graph in a separate window, which is coloured green or red depending on the conditions.
- Is there any way to get rid of one buffer and still maintain the same functionality?
Thank you!

int init(){
   IndicatorBuffers(8);
   IndicatorShortName("");
   IndicatorDigits(0);


   SetIndexLabel(    0,"TREND BUY");
   SetIndexArrow(    0,110);
   SetIndexDrawBegin(0, 0);
   SetIndexStyle(    0, DRAW_ARROW, EMPTY, Buffer_Lines_Width, Green);
   SetIndexBuffer(   0, Buf_1_Buy);

   SetIndexLabel(    1,"TREND SELL");
   SetIndexArrow(    1,110);
   SetIndexDrawBegin(1, 0);
   SetIndexStyle(    1, DRAW_ARROW, EMPTY, Buffer_Lines_Width, Red);
   SetIndexBuffer(   1, Buf_1_Sell);
. . . 

}
 
     int endbar = 12;
     int startbar = 5;
     int barstotal;
     
     for(;startbar < endbar;startbar++)
       {
       if(StopLoss > Low[startbar])
         {
         StopLoss = Low[startbar];
         
         }
       }

A little more advice. There is a loop that should search for the lowest price value for the period, but the loop ends and the StopLoss variable is 0 even though it should be equal to at least one price

The StopLoss variable is equal to 0 at the beginning

The loop does not assign the minimum value to the StopLoss variable, as far as I understood it.

 
chief2000:
The following code draws a line below the graph in a separate window, which is coloured green or red depending on the conditions.
- Is there any way to do without a single buffer and still retain the same functionality?
One buffer - one colour. That is, you can change colour at arbitrary moment of time, but whole line will change colour along its length. All two-color lines in the indicators are drawn with two buffers.
Of course, it is possible to apply objects, but it is another song.
 
DOCTORS:

So, I did my own thing with fractals - I wrote my own indicator... Well, it's easier for me. Here's the question-- I got a problem.

how do I move the arrows back 3 bars? :(

A little piece of code...

SetIndexStyle(0, DRAW_ARROW,0,1);
SetIndexArrow(0,217);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexEmptyValue(0, 0.0);
SetIndexStyle(1, DRAW_ARROW,0,1);
SetIndexArrow(1, 218);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexEmptyValue(1, 0.0);

IndicatorShortName("My_iFractals");
SetIndexLabel(0, "iFractalsUp");
SetIndexLabel(1, "iFractalsDn");

UPD

Вопрос снят, сорри опять за кривость свою, но может кому будет интересно ответ- SetIndexShift(0,-3);


I've seen different ways, but this one. Use SetIndexShift - upward curve
 
granit77:
One buffer - one colour. It means that you can change colour at any moment, but the whole line will change colour along its length. All two-color lines in indicators are drawn with two buffers.
Of course, it is possible to apply objects, but it is another song.

This is exactly what I observed - the entire line changes colour. I've tried to use objects too (before buffers), but they have their own subtleties and buffers are much more preferable in the end. At least now I know I used all the possibilities.
Thank you!
 
I can't figure out how to sum up (Close[1]-Open[1])+(Close[2]-Open[2]) etc. for N periods (applicable to the indicator).
 
001:
I can't figure out how to sum up (Close[1]-Open[1])+(Close[2]-Open[2]) etc. for N periods (applicable to the indicator).
How did you try?