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

 

r772ra

thanks for the tip

 

Good evening! I'm sorry, I think I've already asked you a question somewhere. One with a takeprofit, and a trailing stop should work for the other.

As soon as one takes a takeprofit, a trailing stop starts working for the other. Well, it starts to work immediately when both orders are placed!

//***************************************   
 
  nahodka=false;
 
 
 if (OrderSelect(tocket, SELECT_BY_TICKET , MODE_HISTORY)) { 
 if (OrderTakeProfit( )-3*Point<profitsell&&OrderTakeProfit( )+3*Point>profitsell) nahodka=true;}
     // Находим ордер, сработавший именно по тейкпрофиту 
 
 
  
 if(nahodka){if (OrderSelect(tecket,SELECT_BY_TICKET)){
 if(OrderStopLoss( )>Bid+treylingstop*Point ){ Print ("четвёртаямодифи    " );
 OrderModify(  tecket, OrderOpenPrice(), Bid+treylingstop*Point, OrderTakeProfit(), 0, CLR_NONE);}}}
  // Модифицируем оставшийся ордер

How and what does OrderSelect choose, if the order with the ticket is not yet on the history?

 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 
               
               //SELL
               
               //EMA – период 10 пересекает с верху в низ EMA – период 200 , CCI пересекает уровень
 0,100 или-100 с вверху в низ; Свеча закрывается или находится ниже LMA – период 100
 
 bool CCInapravlenie=false;
 if(( CCI_50S>100&&CCI_50<100) ||(CCI_50S>0&&CCI_50<0)||( CCI_50S>-100&&CCI_50<-100 ) )CCInapravlenie=true;
 if(EMA_10S>EMA_20S&&EMA_10<EMA_20&&CCInapravlenie&&LMA_100<Ask&&!sellistavili){
 
 RefreshRates();   
           tocket=OrderSend (Symbol( ), OP_SELL,   lot , NormalizeDouble (Bid, Digits), 5 ,
 NormalizeDouble( Bid+ (stoploss*Point),Digits),   NormalizeDouble( Bid-( teykprofit*Point),Digits),   NULL, 450, 0, CLR_NONE);
           Error=GetLastError();if (Error==0){  
           Sleep(2000); RefreshRates();  
           tecket=OrderSend (Symbol( ), OP_SELL,  lot ,NormalizeDouble(Bid, Digits), 5,
 NormalizeDouble( Bid+ (stoploss*Point),Digits),   0, NULL, 450, 0, CLR_NONE); 
           if (Error==0){ profitsell = NormalizeDouble( Bid-( teykprofit*Point),Digits); tsenasell=Bid;  
           sellistavili= true; perenossell= false;  }}}
           
           if (Error!=0){  errorcomment = "Ошибка открытия  ордера OP_SELL"  + " " + Symbol() +  " " + ErrorDescript(Error); 
           Print (errorcomment);}
 
 
 if(tsenasell-30*Point>Bid&&!perenossell){Print ("третямодифи    " );
 OrderSelect( tocket, SELECT_BY_TICKET ); 
Positioning
 
Dimka-novitsek:

Good evening! I'm sorry, I think I've already asked you a question somewhere. One with a takeprofit, and a trailing stop should work for the other.

As soon as one takes a takeprofit, a trailing stop starts working for the other. Well, it starts to work immediately when both orders are placed!

How and what does OrderSelect select , if the order with the ticket is not yet on the history?

In the loop, go through the historyOrderSelect(index, SELECT_BY_POS , MODE_HISTORY), comparing the value of tocket with the ticket of the order being selected.

The OrderSelect(tocket, SELECT_BY_TICKET , MODE_HISTORY) will return true if the order with this ticket is even present in the terminal.

Pool - data source for the selection. It is used when the select parameter is equal to SELECT_BY_POS. It can be one of the following values:

MODE_TRADES (default) - order is selected among open and pending orders,

MODE_HISTORY - the order is selected among closed and deleted orders.

And just in case, putNormalizeDouble(Bid+treylingstop*Point, Digits)

 
Thank you!!! I'm going to mess around with my code!
 
Which Expert Advisor is the best to use to visualise trading. Again, it is desirable to be able to use different TFs at the same time. Thank you!
 

finished the councillor! it does what it wants...but...

The first thought that came to my mind: how does the tester work with trade history? For example, if there is the condition "if 2 last bars were loss - do not buy" . Not only that, but my Expert Advisor ignores this condition (maybe a mistake - I'll think again). But what will happen when the Tester opens his own deals (which are already absent in the terminal history)? What tickers will he apply to and in what history? the tester does not seem to assign tickers to trades! does the tester form its own history of trades at all?

 
lottamer:

finished the councillor! it does what it wants...but...

The first thought that came to my mind: how does the tester work with trade history? For example, if there is the condition "if 2 last bars were loss - do not buy" . Not only that, but my Expert Advisor ignores this condition (maybe a mistake - I'll think again). But what will happen when the Tester opens his own deals (which are already absent in the terminal history)? What tickers will he apply to and in what history? the tester does not seem to assign tickers to trades! does the tester form its own history of trades at all?


everything is assigned - look at the "results" tab. but the tester doesn't do miracles - you need to know how to use it
 
YOUNGA:

everything is assigned - look at the "results" tab. but the tester does not perform miracles - you need to know how to use it.

there is no multi-digit ticker like in real life. There is a serial number of the deal. Did you mean it?
 
lottamer:

There is no multivalued ticker as in real trading. There is a consecutive number of a deal. Did you mean it?


If there were as many orders in the tester as are accounted for by the server, the data would also be multi-digit.

The tester, just like the server, assigns each new order a unique ticker number, but the server has been doing this since the brokerage company was founded, for all of its clients and for all instruments.

Reason: