Need internal Trailing Stop function to bypass broken limitation... - page 3

 
excalibur7:

You delivered the job and won 50$! Give me your Paypal email address and I'll send you this amount as first part of the job.

If you are able to help me get the same result as I got with my first version of my EA, a big surprise will come in your Paypal!

My first version was working perfectly with 50point Physical trailing stop in test mode but was impossible in real due to broker limitation!

Check what it give with data from september 2012 to september 2013, AUDUSD, 1H range, Long positions only!

http://youtu.be/kA35UHhI9Bs


Payment done, thanks to my friend Thirteen!

Next step, get the right output!!!

Thanks!

GAB

 
excalibur7: Everywhere it says that it's better to start from -1...
Show me a link. ANY LINK.
 

You know what?

I found the main error in my EA...

StopLoss value is now Static...

The main problem was that the stop loss value disapear everytime the EA restart so, the if/else was not working!

With the StopLoss value set static, everything is working

BUT

The output is not right, we have to find what's the problem!!!

Here's my version of the trailing stop with basic problem solved :

//Dynamic Stop-----------------------------------
int DynamicStop()
 {double TrailLevel;
  static double StopLoss;
  for (int I=-1; I<OrdersTotal(); I++) 
  {OrderSelect(I, SELECT_BY_POS, MODE_TRADES);
   TrailLevel = NormalizeDouble(Bid-(Point*(50+Spread)),Digits);
   if (TrailLevel > StopLoss)
    StopLoss = TrailLevel;
   else if (Bid <= StopLoss)
    {OrderClose(OrderTicket(), OrderLots(), Bid, 0, White);
     StopLoss=0;}}
return(0);}
//-----------------------------------------------

It give the exact same result that with what I've got from my friend Thirteen :

//Dynamic Stop-----------------------------------
int DynamicStop()
 {GetLastError();
  double TrailLevel=0, cSpread=0; 
  static double vStoploss[][2];
  bool TicketFound = false;
  int ARange = 0;
  for (int I=OrdersTotal()-1; I>=0; I--)
   if (OrderSelect(I, SELECT_BY_POS) && OrderSymbol() == Symbol())
    {for (int i=0; i < ArrayRange(vStoploss, 0); i++)
      if (OrderTicket() == NormalizeDouble(vStoploss[i][0], 0))
       {TicketFound = true; break;}
         if (!TicketFound)
          {ArrayResize(vStoploss, ArrayRange(vStoploss, 0)+1);
           i=ArrayRange(vStoploss, 0)-1;
           vStoploss[i][0] = OrderTicket();
           vStoploss[i][1] = 0;}   
// 
  cSpread = MarketInfo(OrderSymbol(),MODE_SPREAD);
  TrailLevel = NormalizeDouble(Ask-((50+cSpread)*Point), Digits);
  if (TrailLevel > vStoploss[i][1] || vStoploss[i][1] == 0)
   vStoploss[i][1] = TrailLevel;
  if (Bid <= vStoploss[i][1])
   {if (!OrderClose(OrderTicket(), OrderLots(), Bid, 0, White))
     Print ("Order ", OrderTicket(), " failed to close.  Error: ", GetLastError());
    else
     {ARange = ArrayRange(vStoploss, 0);
      if (ARange-1>i)
       {ArrayCopy(vStoploss, vStoploss, i*2, (i+1)*2, ((ARange-(i+1))*2));
        ArrayResize(vStoploss, ARange-1);}
      else if (ARange-1 == i)
       ArrayResize(vStoploss, ARange-1);}}}
return (0);}
//-----------------------------------------------

Thanks!

GAB

 
excalibur7:

You know what?

I found the main error in my EA...

StopLoss value is now Static...

The main problem was that the stop loss value disapear everytime the EA restart so, the if/else was not working!

With the StopLoss value set static, everything is working

. . .

When I posted my solution, I believe I was fairly explicit that the variables would reset if the EA was re-initialized and even suggested that could possibly be avoided by saving the information to a file. See my post/code.

excalibur7:

Next step, get the right output!!!

excalibur7:

The output is not right, we have to find what's the problem!!!

I don't understand. Your original DynamicStop() function didn't print anything to the log/journal, didn't write any information to a file, and didn't create any objects. What output are you referring to?
Reason: