Multicurrency advisor question - page 10

 
rid >> :
However, I need - at the same time - trailing stop function to be implemented for all ticks.

A tangible benefit of a potting trawl can only be seen on a short section at the expense of fitting.

As a rule, coarse trawl is just as good (if the trawl is not pipsing and scalping).

But the benefits of "opening price" optimisation when using a trawl are lost, which is very significant.

Lately I've given up trailing stops on almost all TCs.

Partial/full position closing (possibly by reversal) by reverse signal works better.

 

And I use a threshold trawl. And if you adjust the start threshold, there's a reason...

extern string   ____________= "Параметры Трейлинг стопа";
extern bool UseTrailing = false;
extern int lMinProfit = 150;
extern int sMinProfit = 160;
extern int lTrailingStop = 50;
extern int sTrailingStop = 60;
extern int lTrailingStep = 5;
extern int sTrailingStep = 5;
//--------------------------------------------------------
int start()
  {
  if(Time[0] == prevtime)   return(0);
   prevtime = Time[0];//если появился новый бар , включаемся
//-------------------------------------------------------------------   
if ( UseTrailing) TrailPositions(); //трейлинг стоп

//--------------------------------------------------------------
... ... ... ... ... ... ... ... ... ... ... ... 
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
void TrailPositions() //пороговый трейлинг стоп
{  int Orders = OrdersTotal();
  for (int i=0; i< Orders; i++) {
    if (!(OrderSelect( i, SELECT_BY_POS, MODE_TRADES))) continue;
    if (OrderSymbol() != Symbol() && OrderMagicNumber()== Magic) continue; 
    if (OrderType() == OP_BUY) {
      if (Bid-OrderOpenPrice() > lMinProfit*Point) {
        if (OrderStopLoss() < Bid-( lTrailingStop+ lTrailingStep-1)*Point) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Bid- lTrailingStop*Point,
                                                    OrderTakeProfit(), 0, Blue);
        }}}
    if (OrderType() == OP_SELL) {
      if (OrderOpenPrice()-Ask > sMinProfit*Point) {
        if (OrderStopLoss() > Ask+( sTrailingStop+ sTrailingStep-1)*Point || 
                                                      OrderStopLoss() == 0) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Ask+ sTrailingStop*Point,
                                                     OrderTakeProfit(), 0, Blue);
        }}}}}
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
 

In general, I don't understand what is the point of using a Potikko threshold trawl?

 

Good afternoon, everyone. Problem again.

With the indicator.

Can't write the iCustom.

I wrote it like this:

double ActivatorBLUE=iCustom(NULL,0,"HL Next Activator", ActivatorPeriod, useFullPeriods,0,1);
//синие уровни на 1 баре
double ActivatorRED=iCustom(NULL,0,"HL Next Activator", ActivatorPeriod, useFullPeriods, 1,1);
//красные уровни на 1 баре
Comment( ActivatorBLUE,"-", ActivatorRED);

But in both cases only blue level values are returned. I don't understand why! After all, I have provided buffer numbers of 1 and 0 respectively!

Even in the comment the same values are displayed - blue level

This is how the buffers are defined in the indicator init :

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexBuffer(0, SellActivator);//синий
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(1, BuyActivator);//красный
   SetIndexEmptyValue(1,0.0);
   if ( useFullPeriods!=0) useFullPeriods=1;
//----
   return(0);
  }

Pozh. suggestion? Indicator in the upload (Author of the indicator is Rosh).

Files:
 
rid писал(а) >>

Good afternoon, everyone. Problem again.

With the indicator.

Can't write iCustom.

Checked it, it looks like this:

2008.10.29 15:13:49 2008.10.28 12:51 testhl EURUSD,H1: 1.2395-0
2008.10.29 15:13:49 2008.10.28 12:51 testhl EURUSD,H1: 1.2395-0
2008.10.29 15:13:49 2008.10.28 12:51 testhl EURUSD,H1: 1.2395-0
2008.10.29 15:13:48 2008.10.28 05:52 testhl EURUSD,H1: 0-1.2547
....
2008.10.29 15:13:48 2008.10.28 05:51 testhl EURUSD,H1: 0-1.2547
2008.10.29 15:13:48 2008.10.28 05:51 testhl EURUSD,H1: 0-1.2547
2008.10.29 15:13:47 2008.10.27 18:49 testhl EURUSD,H1: 1.2414-1.2542
.....
2008.10.29 15:13:47 2008.10.27 18:49 testhl EURUSD,H1: 1.2414-1.2542
2008.10.29 15:13:46 2008.10.27 14:54 testhl EURUSD,H1: 0-1.2612

I haven't got into it, but it seems to be right, I took indicator with default parameters, value call with string

Print(iCustom(NULL,0,"HLdNextmActivator",0,1),"-",iCustom(NULL,0,"HLdNextmActivator", 1,1));
 

Thank you.

That's weird. Suddenly it's working for me, too. Didn't fix it, didn't do anything.

But it didn't work this morning! It took me two hours. "I bet..."

It's not the first time I've noticed that. I'll do something simple on a simple turkey. All of a sudden it doesn't work from the start!

For no apparent reason! Although the construction is the simplest. All right, I guess. I'll try again later...

And then I turn it on and look, it's working just as it should!

It's like a miracle...

I did it once with a parabolic. I set conditions for opening of a position at changing of the "sign" of the parabolic.

It was the most primitive condition. It did not work in the tester! For two days, I swore foul and tried to find out what was wrong. I failed to understand it. I couldn't figure it out. I thought I'd figure it out later. A day later I turned it on and... - ...it was working like clockwork...

 
rid >> :

.............. then ... Then a day later I turned it on and... - I look, it's running like clockwork...

The man comes to the watchmaker.

- This one has broken.

The mechanic opens the clock and a dead cockroach falls out.

- It will not work, though.

- Why not?

- The mechanic is dead, though.

 

Good afternoon, everyone. I cannot solve the problem.

The Expert Advisor places pending orders, e.g. OP_BUYSTOP - four orders

OP_BUYSTOP magic 1

OP_BUYSTOP magic 2

OP_BUYSTOP magic 3

OP_BUYSTOP magic 4

Places them - at a given distance from the price and at a given step from each other.

Further. If the price has gone down, I need the orders to follow the price with the given step.

I have done it. I have not encountered any particular difficulties.

 

However!

I don't need all orders to modify and move behind the price, attracting the broker's attention with unnecessary requests to the server.

I want the furthest order from the current price to jump over all the others and become the nearest one!

And so on, so that with a further price movement downwards the furthest orders would consistently jump closer to the price!

I have been thinking for several hours and cannot come close to a solution.

I cannot even get close to the solution.

Or maybe there is a reference to something similar?

Found the function in a branch of I. Kim. But how to apply them here, is not clear yet.

//----------------------------------------------------------------------------------------------------------------------------

Function GetIndexByTicket(). This function returns the index of the order or position by the ticket

The IndexByTicket() function. This function returns the index (the index number in the general list of set orders or open positions) of the order or position within the ticket

Function GetOrderOpenPrice(). Returns the set price of the last order placed

 

Create two arrays. One by ticket number, the second by price. Then sort the array by price, moving the ticket numbers at the same time (without breaking the connection). Then at one end of the array will be the lowest price, at the other the highest price. The only thing that remains is to change one of the outermost orders.

Reason: