Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 613

 
Hello. The basket advisor, on a condition should close all orders, but it first closes the order, then tries to close it again (the server gives an error "Invalid Ticket") and only then goes further. Here is a sample code and the EA itself.
int Answer=0;
    bool Result[14];
    for (int i = OrdersTotal()-1; i>=0; i--){
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
             if (OrderMagicNumber() == Magic){
               if (OrderType()==OP_BUY){
                  if (OrderSymbol() == "USDCAD"){
                    int cnt=0;
                    while(cnt<=5){
                      Result[0]=OrderClose(OrderTicket(),OrderLots(),MarketInfo("USDCAD",MODE_BID),slip,Blue);
                      if(!Result[0]){
                        Answer=ERRORS(GetLastError());
                        if (Answer==1)continue; cnt++;
                        if (Answer==2)break;
                      }
                      if (Result[0])break;
                    }continue;
                 }
                 if (OrderSymbol() == "USDCHF"){
                   int cnt=0;
                    while(cnt<=5){
                      Result[1]=OrderClose(OrderTicket(),OrderLots(),MarketInfo("USDCHF",MODE_BID),slip,Blue);
                      if(!Result[1]){
                        Answer=ERRORS(GetLastError());
                        if (Answer==1)continue; cnt++;
                        if (Answer==2)break;
                      }
                      if (Result[1])break;
                    }continue;
                 }   
Files:
 

Good afternoon!

Can you please tell me if there is any open source indicator/advisor that detects side channels (flats) and does it based on a candlestick configuration? If we are talking about an indicator, it is supposed to draw something similar to the attached picture:


The purpose of the question is to see already implemented algorithms for determination of these channels, because my algorithm that was used for drawing of channels in the picture does not always show what it was made for, so I want to see some alternative solutions for this issue. People have already done this and maybe there's already a sensible solution to this problem, and I'm re-inventing the wheel...

 

I have one of those. I will if I can find it.

 
FOReignEXchange:

Yes, that's right. Just remembered that in some DCs trades are only opened with zero stops with subsequent modification.

Thank you, very helpful.

I've forgotten everything, I feel like an old man.

But the thing is, a week ago everything was working and now it's not. And as far as I know, such restrictions for owls have been in place for a long time in some offices.

I'll let you know when I check your option.


These are peculiarities ofmarket execution especially often observed at ECN and STP brokers. It should be noted that the majority of reputable brokerage companies have switched to this scheme of work. Ask and Bid prices in the trade order are needed only for the tester. Roughly speaking, if you send an order, the server needs to know the pair, direction and volume of the transaction. The opening price is determined by the broker.

In normal offices the level of StopLoss and FreeLevel (levels of setting and modification of SL and TP and pending orders) = 0, so it may happen so that the order opens at the worse price and closes at TP or SL. Therefore SL and TP levels are not accepted by the server.

 
yan720:

Good afternoon!

Can you please tell me if there is any open source indicator/advisor that detects side channels (flats) and does it based on a candlestick configuration? If we are talking about an indicator, it is supposed to draw something similar to the attached picture:

The purpose of the question is to see already implemented algorithms for determination of these channels, because my algorithm that was used for drawing of channels in the picture does not always show what it was made for, so I want to see some alternative solutions for this issue. People have already done it and maybe there's already a good solution to this problem, but I'm reinventing the wheel...

I found this old code of mine. I'm trying to figure it out because it doesn't work. I remember it was working, but now it's not.

If you are interested, I will look into my code and find the error.

And the second, it is not an indicator, it is an Expert Advisor. The strategy's principle: I have a sideways channel at some certain length, open a deal on a bounce of the channel. Stop small, profit on the other side of the channel. It goes something like this.

And it will only draw the last channel it finds. When the channel breaks down, it looks for another one and deletes the old one.

If you are interested, I may make an indicator based on this algorithm.

 
yan720:

Good afternoon!

Can you please tell me if there is any open source indicator/advisor that detects side channels (flats) and does it based on a candlestick configuration? If we are talking about an indicator, it is supposed to draw something similar to the attached picture:


The purpose of the question is to see already implemented algorithms for determination of these channels, because my algorithm that was used for drawing of channels in the picture does not always show what it was made for, so I want to see some alternative solutions for this issue. I've already done it and may have a good solution, but I'm reinventing the wheel...

What can be difficult about it?

In the external parameters you set the range and number of bars. As soon as the specified number of bars has not moved out of the range (high-low < range), we draw trends for the specified number of bars. At next bar closing we check again and if this bar hasn't moved out of the range we should move the second coordinate by 1 bar. That is the logic.

 
AlexeyVik:
What's so complicated about it?

Set the range and number of bars in the external parameters. As soon as the specified number of bars does not jump out of the range (high-low < range), the trend is drawn for the specified number of bars. At next bar closing we check again and if this bar hasn't moved out of the range we should move the second coordinate by 1 bar. That is the logic.

Yes, really, it is not very complicated. I did it that way too. It's just that I have an owl, the code is cluttered. I'd rather do it all over again than take it apart.

 
AlexeyVik:
What could be difficult about that?

Set the range and number of bars in the external parameters. As soon as the specified number of bars does not jump out of the range (high-low < range), the trend is drawn for the specified number of bars. At next bar closing we check again and if this bar hasn't moved out of the range we should move the second coordinate by 1 bar. That is the entire logic.

Of course, the general idea is the same. But how do you determine the width of the channel (the range in your case)? In my case this is done using the size of an average candle plus it is all related to the length of the channel, because the presence of the channel is checked not on a fixed number of bars, but, for example, on a length of 10 to 30 bars.

It is the choice of width from length that interests me...

 
FOReignEXchange:

Yes, it's really not that complicated. That's what I was doing too. It's just that I have an owl, the code is cluttered. It's better to do it all over again than to take the code apart.

Thank you for responding. If you don't mind, please send me the EA you are talking about (or a part of it, which one is with the channel) - it would be interesting to see another implementation.
 
yan720:
Thank you for responding. If you don't mind, please send me the EA you are talking about (or a part of it, which is with the channel) - it would be interesting to see another implementation.

I can't make sense of something I made a few years ago. It's not working for some reason, although I remember it used to work and trade. Let me sort out the code first, fix it and then post it. Maybe tomorrow. I just don't want to embarrass myself if there are some childish mistakes.

Reason: