[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 105

 

That's it. I'm all messed up and my head's not working anymore.

here is the code

       double Low1=Low[iLowest(NULL,0,MODE_LOW,3,0)],
              Low2=Low[iLowest(NULL,0,MODE_LOW,20,0)];
         
         if(Low1<Low2 && Open[2]>Close[2])    
          {
            if(Open[1]<=Close[2] && Open[2]<Close[1])
             {
                 double sl=Low[iLowest(NULL,0,MODE_LOW,3,0)],
                        tp=Ask+(Open[2]-Low[2]);
                 OrderSend(Symbol(),OP_BUY,0.1,Ask,3,sl,tp);
                 return;
             }
          }

I want to draw the following. i need to find the minimum point for the last 3 candlesticks. compare it with the minimum price of the last 20 candlesticks. if the last 3 candlesticks are lower and the candle is black ( Open[2]>Close[2] ) then look further.

I need to find a bearish takeover ( Open[1]<=Close[2] && Open[2]<Close[1] ).

And open a buy position.

It seems to be correct, but i feel something is wrong.

I will be very grateful if you can help me.

 
Hello,

I have moved the channel drawing indicator to the EA.

Unbalanced parentheses is a constant error, although I have double-checked all brackets.

But my question is different - I need to use these very channels to open trades in the condition, but I don't know how to mark them. I tried just to write the name of an object but I haven't managed to check the correctness of this solution yet.

Please advise how to solve this problem
 
kilnart:

and open a buy position.

everything seems right, but there is something wrong.

And where does the code reach? What does Comment or Print tell you?
 

only as far as here.

if(Low1<Low2 && Open[2]>Close[2])  

Nothing further.

 
kilnart:

only as far as here.

Nothing further.


So, what condition is not fulfilled next? What does Comment or Print tell you?
 
What do you need to write?
 
kilnart: what do you need to write?

check if your conditions are fulfilled on the historical data using Print(), like this:

double Low1=Low[iLowest(NULL,0,MODE_LOW,3,0)],
              Low2=Low[iLowest(NULL,0,MODE_LOW,20,0)];
//Print("Low1 = ",Low1 ,"Low2 = ",Low2);
         
         if(Low1<Low2 && Open[2]>Close[2])    
          {
            Print("сработал первый if...");
            if(Open[1]<=Close[2] && Open[2]<Close[1])
             {
                 Print("сработал второй if...");
                 double sl=Low[iLowest(NULL,0,MODE_LOW,3,0)],
                        tp=Ask+(Open[2]-Low[2]);
                 OrderSend(Symbol(),OP_BUY,0.1,Ask,3,sl,tp);
                 return;
             }
          }
 

just did what you asked. nothing is happening.

The problem is in this expression

if( Low1<Low2 && Open[2]>Close[2])  

if I removeLow1<Low2 then Open[2]>Close[2] is executed, if I remove Open[2]>Close[2], Low1<Low2 is not executed

 
kilnart:

Low1<Low2 is not met

and what do the Low1 and Low2 you found equal, are the Lowest indexes found correct?
 
I checked with the scripts, the numbers add up. I guess they're right. I don't know. It doesn't work.