some problems about TS

 

I am an newbie for MQ4,recently have tried to write TS() for my code as follows:

void TS(double ts=550)
{
  bool res = false;
  int total = OrdersTotal();

  for(int i = 0;i<total;i++)
  {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ==false) continue;
     if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)  
      {
        if( OrderType()==OP_BUY)  
           {
           if(Bid>OrderOpenPrice()&& Bid-OrderOpenPrice()>Point*ts)

          OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*ts,OrderTakeProfit(),0,Blue);
            }
        if( OrderType()==OP_SELL) 
        {
         if(Ask<OrderOpenPrice()&& OrderStopLoss()<Ask-Point*ts) 
          OrderModify(OrderTicket(),OrderOpenPrice(),Ask-Point*ts,OrderTakeProfit(),0,Yellow);
         }
      }
   } 

  }

but I found there are some prblems when back test:

1,the sell TS seems don't takes effect;

2,TS() only takes effect after close one order under(CalculateCurrentOrders(Symbol())<2),my intention it should take effect if meet condition as list above.

Gurus who could help me ? appreciating!

 
  1. Always count down in the presence of multiple orders/multiple charts
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
    

  2. ,Bid-Point*ts,
    //Ask-Point*ts
    .Ask+Point*ts,

  3. Adjust for 5 digit brokers (tp, sl, and slippage)
    //++++ These are adjusted for 5 digit brokers.
    double  pips2points,    // slippage  3 pips    3=points    30=points
            pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

 
univetsity:

I am an newbie for MQ4,recently have tried to write TS() for my code as follows:

but I found there are some prblems when back test:

1,the sell TS seems don't takes effect;

2,TS() only takes effect after close one order under(CalculateCurrentOrders(Symbol())<2),my intention it should take effect if meet condition as list above.

Gurus who could help me ? appreciating!


add another problem :3,how to make TS() would not retrace when price reversed move.TKS!
 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

 
sty671:

can someone help me edit sar ohlc to use heiken ashi ohlc

https://www.mql5.com/en/forum/132964
 
WHRoeder:
  1. Always count down in the presence of multiple orders/multiple charts

  2. Adjust for 5 digit brokers (tp, sl, and slippage)

could you help me solve the 2nd problem? TKS!
Reason: