Need help concerning simple coding - page 3

 

deVries,

Thank you for your help.

You were right. My broker has 5 digits, that is why I had a problem with SL and TP. Well When I tried to change it, here is what I get !

Well, I have two main problems

1 / We can see that only one pending order SELLSTOP appeared on the graph. So where is the BUYSTOP pending order?

2/ the most weird problem is that this SELLSTOP order appeared every seconds and not only once as I thought. Do I have to use a special function ?

 
waldganger:

deVries,

Thank you for your help.

You were right. My broker has 5 digits, that is why I had a problem with SL and TP. Well When I tried to change it, here is what I get !

Well, I have two main problems

1 / We can see that only one pending order SELLSTOP appeared on the graph. So where is the BUYSTOP pending order?

2/ the most weird problem is that this SELLSTOP order appeared every seconds and not only once as I thought. Do I have to use a special function ?



Like a wrote before maybe at time of placing buystop the price that moment was to close to the highest point of the 3 previous bars or maybe it was already higher that moment.... Also you see your coding is placing every tick a new trade How many do you want ????
 

Just one...if possible. one which will be updated and adjusted to the highest/lowest price in the last candlestick...

If possible, I would like to keep the same pending order if there is no new highest/lowest price in the last 3 candlesticks (bar?)

Well...maybe the best will be to update the pending order when a new candlestick appear. (all new tick,a new pending order is too much...)

do you think it is possible ?

 
waldganger:


Just one...if possible. one which will be updated and adjusted to the highest/lowest price in the last candlestick...

If possible, I would like to keep the same pending order if there is no new highest/lowest price in the last 3 candlesticks (bar?)

Well...maybe the best will be to update the pending order when a new candlestick appear. (all new tick,a new pending order is too much...)

do you think it is possible ?


ofcours count your open trades

if counted buystop (and buys maybe) is equal to zero you can place new buystop at first ticks newbar

don't forget counting down

select on symbol

select on magicnumber

select on ordertype

 
int count_buys =0;
int count_sells =0;
int count_buystop =0;
int count_sellstop =0; 
for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--)     
   if (OrderSelect(iPos, SELECT_BY_POS)                         // Only my orders w/
        &&  OrderMagicNumber()  == Magic.Number                 // my magic number
        &&  OrderSymbol()       == chart.symbol)                // and my pair.   
    {
     if(OrderType() == OP_BUY){buys++;}     
     if(OrderType() == OP_SELL){sells++;}     
     ........                                     // buystop     
     ........                                     // sellstop   
    } 
example counting not finished that is something you can ...
Reason: