[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 161

 
The following situation has occurred: The Strategy Tester does not close TakeProfit positions. Trading is done on TF Day, I looked at smaller TF on loss-making trades - price goes down/climbs at more than the required level for TakeProfit triggering, but the trade is not closed, and when the price reaches StopLoss, then the loss is fixed. I have even tried visualization - the price just passes TakeProfit and that's it. And sometimes everything works, and sometimes things like that appear. Just yesterday everything was fine, but today I ran the tester and got a total lack of performance. I tried to reinstall the terminal - it didn't help. I am not sure if I rented a different brokerage company.
 
beginner666999:
The following situation occurred: Strategy Tester does not close positions by TakeProfit. Trading is done on TF Day, I looked at smaller TF on loss-making trades - the price goes down/up more than the required level for TakeProfit triggering, but the trade is not closed and when the price reaches StopLoss, the loss is fixed. I have even tried visualization - the price just passes TakeProfit and that's it. And sometimes everything works, and sometimes things like that appear. Just yesterday everything was fine, but today I ran the tester and got a total loss of performance. I tried to reinstall the terminal - it didn't help. I am not sure if I am going to use another brokerage company.

It's all about the spread, it's increased for the weekend.

It's like this.

 
r772ra:

It's all about the spread, it's increased for the weekend.

It goes something like this.


Thank you! I'll wait for weekdays to check it out.
 
r772ra:

It's all about the spread, it's increased for the weekend.

It's like this.


You have to be such a moron - I looked at the spread for my instrument on broker's website and was amazed - 11 pips! Thanks again!
 
Then another question, slightly off-topic. Why do they increase the spread at the weekend? After all, there is no trading going on anyway.
 
Konstebl:

Please, advise how to specify the condition correctly. If there is an open BUY order, if it is at breakeven, then we set BUYSTOP:

static bool flag ;

if(NewBar())

flag = true;

for(i=0;i<total;i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==123)

{

if(OrderType()==OP_BUY)

{

if(OrderStopLoss()>OrderOpenPrice())

{

if(Ask>m && frUP>0 && flag)

{

price = NormalizeDouble(frUP+(Ask-Bid)+30*Point,Digits);

takeprofit = NormalizeDouble(price+tp*Point,Digits);

ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,price,5,Bid-sl*Point,takeprofit, "Fractal",123,TimeCurrent()+72000,Blue);

if(ticket>0)

flag = false;

else

Print("Error ",GetLastError());

}

}

}

}

}

does not work!!!


Have you tried to put braces according to logic? Because so far there isn't any.

What is written implies that at least one position is open. Otherwise it won't open any new ones.

 
Vinin:


Have you tried to put braces according to logic? Because so far there is none.

What is written implies that at least one position is open. Otherwise no new ones will be opened


And how do you arrange them? I've written a little bit more code:

 if(NewBar())

     flag = true;    

          for(i=0;i<total;i++)

             {

             OrderSelect(i,SELECT_BY_POS,MODE_TRADES); 

             if(OrderSymbol()==Symbol() && OrderMagicNumber()==123)

                {

                if(OrderType()==OP_BUY || OrderType()<=OP_BUYSTOP)

                   {

                   if(OrderStopLoss()>OrderOpenPrice())

                      {

                      if(Ask>m && frUP>0 && flag)

                         {                

                        price = NormalizeDouble(frUP+(Ask-Bid)+30*Point,Digits);

                        takeprofit = NormalizeDouble(price+tp*Point,Digits);

                        ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,price,5,Bid-sl*Point,takeprofit,"Fractal",123,TimeCurrent()+72000,Blue);

                       if(ticket>0)

                        flag = false;

                       else

                        Print("Ошибка ",GetLastError());

                      }

                   }

                }

             }

          }
По идее должно работать,но не хочет.
 
beginner666999:
Then another question, a little off the subject. Why do they increase the spread on weekends? They do not trade anyway.

No, not over the weekend, I didn't write it correctly, the Spread stays in the terminal at the last quote that came in

So you close the terminal during the day, Friday. And you test it on weekend.

 
r772ra:

No, not over the weekend, I didn't write it correctly, the Spread stays in the terminal at the last quote that came in

So you close the terminal during the day, Friday. And you test it over the weekend.


Got it, thanks! It makes much more sense that way.
 
Konstebl:


And how do I arrange them? I've added a little bit of code:


OK, a little bit of logic

if(NewBar())
    flag = true;    
for(i=0;i<total;i++) {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES); 
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==123) {
    if(OrderType()==OP_BUY || OrderType()<=OP_BUYSTOP) {
        if(OrderStopLoss()>OrderOpenPrice()) {
            if(Ask>m && frUP>0 && flag) {                
                price = NormalizeDouble(frUP+(Ask-Bid)+30*Point,Digits);
                takeprofit = NormalizeDouble(price+tp*Point,Digits);
                ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,price,5,Bid-sl*Point,takeprofit,"Fractal",123,TimeCurrent()+72000,Blue);
                if(ticket>0)
                    flag = false;
                else
                    Print("Ошибка ",GetLastError());
            }
        }
    }
}

          }

The loop is executed regardless of the condition if(NewBar())