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

 
drknn:

...

You have a complicated way of getting at the truth. I am sure that if you formulate the problem itself to the people, he will tell you a simpler way of solving it.

P.S.

Of all solutions to a problem, the easiest one is always the hardest to find, because in order to find it you have to recycle and sift through a heap of junk. So, feel free to formulate - simple solution doesn't mean quick solution. Maybe people here will save you more than a day of your life.


Ok. I will try to give you the gist of the problem, perhaps someone will give you a hint or help me to make it easier to solve.

We work on the 1-minute chart. We take the one-minute bar (high+low/2 - average value of the bar) on the chart of 29/10/12 at 00:00 - this will be the starting point.

Then we check the deviation from this price upwards by 10 pips (each correct deviation is +1).

When we reach the 10 point deviation from the starting point - the +1 counter; and we start checking further deviations, but from the point, where we reached the 10 point deviation, and wait for the next 10 point rise in price.

For example, we get:

If (start point) + 10 pips <= price (we use all subsequent prices of bars from the starting point.) We get a counter = counter +1; and we start the starting point already from this point -(start point + 10 pips).

If (start point + 10 pips) +10 pips <= price (all subsequent prices of bars from the reference point are used) we get counter=Counter+1; and we start from this point-(start point + 10 pips) +10 pips.

If(start point + 10 p ips+10 p ips) + 10 pips <= price (we use all subsequent prices of bars from the reference point.) we get counter=Counter+1; and we start from this point -(start point + 10 pips+ 10pips) + 10 pips.

and so on...

Until we reach a counter of 10(counter == 10).

And every new formed1-minute bar (high+low/2 - average value of the bar) we check for this condition and wait until the counter reaches10 (counter == 10). Suppose two days passed, each new bar formed we checked and shifted if the conditions were correct .....

And when we reached counter =10 - we output the message that "Counter == 10". We move the starting point 2 days ahead of the initial user defined point i.e. from29/10/12 at 00:00 to 31/10/12 at 00:00 and repeat the cycle.

Repeat the cycle and so move through the schedule.

I.e. we should take the newly formed bars and draw (high+low/2 - average value of the bar). And check for the conditions and, if they are correct, shift them as described above.

I have tried to implement it through an array, it is very confusing and gives wrong values! Help me how to implement this algorithm!

 
Dimka-novitsek:
Here, I'm sorry... I re-checked the brackets eight times-- well, they're balanced! Balanced! Or are they?


In this code:

            Print(
          "strela1>strela2&&BUY==0&&SELL==0   " , GetLastError()  ,"  Ask ",Ask,
     "   NormalizeDouble( Bid- (stoplos*Point),Digits)  ", NormalizeDouble( Bid- (stoplos*Point),Digits),"  
         NormalizeDouble( Ask+( takeprofit*Point),Digits) ", NormalizeDouble( Ask+( takeprofit*Point),Digits)); }

move the inverted commas (the ones at the end of the line).

 
Yeah... Right.
 
Phew!!! Not helping. Ah. I'll compile the dog in the new EA piece by piece!
 
Dimka-novitsek:
Phew!!! Doesn't work. Ah, I'll compile the dog in a new EA piece by piece!


This is what I do in cases like this:

- I comment out all the text of the function;

- I take down the comment in parts, compile it and wait for the error to show up.

 
   if (strela1>strela2&&BUY==0&&SELL==0)    {    
            
           OrderSend( Symbol( ), OP_BUY, lot, Ask, 3, NormalizeDouble( Bid- (stoplos*Point),Digits),  
          NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE); 

 
            Print(
          "strela1>strela2&&BUY==0&&SELL==0   " , GetLastError()  ,"  Ask ",Ask,
     "   NormalizeDouble( Bid- (stoplos*Point),Digits)  ", NormalizeDouble( Bid- (stoplos*Point),Digits),  
     "    NormalizeDouble( Ask+( takeprofit*Point),Digits) ", NormalizeDouble( Ask+( takeprofit*Point),Digits)); }

so

   for( int A=0; A<100 ; A++)
   {
       double strela1 = iCustom(NULL, taymfreym, "индикатор", 2, A);
       double strela2 = iCustom(NULL, taymfreym, "индикатор", 3, A);
            
       int BUY=0,SELL=0;int ticket; 
       Print ( A,  "  strela1 " , strela1 , "    strela2  " , strela2 ); 
           
       for(int i=1; i<=OrdersTotal(); i++)
       {  
         if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
         {                                       // Анализ ордеров:
            if (OrderSymbol()!=Symbol( ) )continue;      // Не наш фин. инструм
            if (OrderMagicNumber( ) !=magicnumber)continue;
            if (OrderType()==0){ BUY++; ticket=OrderTicket( );}
            if (OrderType()==1) {SELL++;ticket=OrderTicket( );}
         }
       }
    }

like this

      if (strela1<strela2&&BUY==0&&SELL==0)
      {  

         OrderSend( Symbol( ), OP_SELL, lot, Bid, 3, NormalizeDouble( Ask- (stoplos*Point),Digits),  
         NormalizeDouble( Bid+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
         Print( "strela1<strela2&&BUY==0&&SELL==   " , GetLastError()  ,"  Bid ",Bid,
         "   NormalizeDouble( Ask- (stoplos*Point),Digits)  ", NormalizeDouble( Ask- (stoplos*Point),Digits),
         "    NormalizeDouble( Bid+( takeprofit*Point),Digits) ", NormalizeDouble( Bid+( takeprofit*Point),Digits));
      }

and so on

    Print (   "  Конец " );      

Tip 1: Structure your program with indents

Tip 2: when searching for such errors, and many others, use commenting of code parts /* */ - syntax errors are found very quickly

 
Dimka-novitsek:
Thank you!!! I'd better take a look at the code... I've also got the brackets on a piece of paper - balanced!!!

piecemeal does not mean correct - the nesting rule must be followed

 
Dimka-novitsek:
Where's the branching? Or am I stupid... I mean, we just open an order under the conditions!
The if operator is a branching operator, but the second branch (else) is missing in your code.
 

Thank you!!!

You know, it compiles without that line.

Print( "strela1<strela2&&BUY==0&&SELL==   " ,   GetLastError(),    "  Bid ",  Bid,  "   NormalizeDouble( Ask- (stoplos*Point),Digits)  ", 
 NormalizeDouble( Ask- (stoplos*Point),Digits),  "    NormalizeDouble( Bid+( takeprofit*Point),Digits) ",  NormalizeDouble( Bid+( takeprofit*Point),Digits);

And I don't see it as criminal!!! I was the one who transferred the whole EA in parts and compiled them separately until I found the root, so to speak.

 
Dimka-novitsek:

Thank you!!!

You know, it compiles without that line.

And I don't see what's wrong with it!!! It was me carrying the whole EA in parts and compiling them separately until the root was found, so to speak.

missing the closing bracket for Print

Print( "strela1<strela2&&BUY==0&&SELL==   " ,   GetLastError(),    "  Bid ",  Bid,  "   NormalizeDouble( Ask- (stoplos*Point),Digits)  ", 
 NormalizeDouble( Ask- (stoplos*Point),Digits),  "    NormalizeDouble( Bid+( takeprofit*Point),Digits) ",  NormalizeDouble( Bid+( takeprofit*Point),Digits));