stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Best Bob
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3566
Page 5 of 8
Author:  phil_trade [ Mon May 05, 2014 11:15 am ]
Post subject:  Best Bob

Steve

"Most people go ootb and the magics are different by default" -> Between Trade and CT trade but are equal for each SYMBOL !

More, the last bug I found in BOB EA in Close Procedure was a bad Ticket Number / Symbol association that was corrected by adding an OrderSelect().
Author:  phil_trade [ Thu May 08, 2014 8:53 am ]
Post subject:  Best Bob

Hi Steve

In LookForTradeClosure routine the test if (CloseEnough(DailyStochMain, 0)) in the same for SELL and BUY trades ?

is this abug as for sell it should be if (CloseEnough(DailyStochMain, 100)) ?

Code: Select all

   if (OrderType() == OP_SELL)
   {
   
      if (UseDailyStochForExit==true)
      {
          
         //Reset FirstFlipTime if the yellow is the corrrect value
         if (!CloseEnough(DailyStochMain, 0))
            FirstFlipTime = 0;
            
         //Take the time the line flips
         if (CloseEnough(DailyStochMain, 0))
            if (FirstFlipTime == 0)
               FirstFlipTime = TimeCurrent();
   
         //Is it time to close the trade?
         if (CloseEnough(DailyStochMain, 0))
            if (FirstFlipTime > 0)
               if (TimeCurrent() - FirstFlipTime >= (MinutesToConfirmYellowFlip) )
               {
                  CloseThisTrade = true;
                  reason = StringConcatenate(Symbol() + " Yellow flip. Closing ticket no " + OrderTicket() + " Blue = " + DoubleToStr(dStochMain[0], 2) + " Yellow = " 
                           + DoubleToStr(DailyStochMain, 0) + " Red = " + DoubleToStr(WeeklyStochMain, 0));
               }//if (TimeCurrent() - FirstFlipTime >= (MinutesToConfirmYellowFlip ) )
            

        
          /*if (NewBar(PERIOD_M5))
Author:  phil_trade [ Thu May 08, 2014 9:47 am ]
Post subject:  Best Bob

With BreakEven allowed I have bug alert : Invalid Stop Loss cause GBPJPY wants to Move SL of EUCAD trade ....

just stop this with :

but it seems there's a mess in Symbol and/or Trade management :

Code: Select all

void BreakEvenStopLoss() // Move stop loss to breakeven
{

if (OrderSymbol() != Symbol()) return;
Author:  SteveHopwood [ Thu May 08, 2014 10:44 am ]
Post subject:  Best Bob

phil_trade » Thu May 08, 2014 8:53 am wrote:Hi Steve

In LookForTradeClosure routine the test if (CloseEnough(DailyStochMain, 0)) in the same for SELL and BUY trades ?

is this abug as for sell it should be if (CloseEnough(DailyStochMain, 100)) ?

Code: Select all

   if (OrderType() == OP_SELL)
   {
   
      if (UseDailyStochForExit==true)
      {
          
         //Reset FirstFlipTime if the yellow is the corrrect value
         if (!CloseEnough(DailyStochMain, 0))
            FirstFlipTime = 0;
            
         //Take the time the line flips
         if (CloseEnough(DailyStochMain, 0))
            if (FirstFlipTime == 0)
               FirstFlipTime = TimeCurrent();
   
         //Is it time to close the trade?
         if (CloseEnough(DailyStochMain, 0))
            if (FirstFlipTime > 0)
               if (TimeCurrent() - FirstFlipTime >= (MinutesToConfirmYellowFlip) )
               {
                  CloseThisTrade = true;
                  reason = StringConcatenate(Symbol() + " Yellow flip. Closing ticket no " + OrderTicket() + " Blue = " + DoubleToStr(dStochMain[0], 2) + " Yellow = " 
                           + DoubleToStr(DailyStochMain, 0) + " Red = " + DoubleToStr(WeeklyStochMain, 0));
               }//if (TimeCurrent() - FirstFlipTime >= (MinutesToConfirmYellowFlip ) )
            

        
          /*if (NewBar(PERIOD_M5))
You are dead right here :clap: and it explains both why rapple's picture was showing the wrong yellow line values and why I could not find the fault. The code in post 1 here is not the code I was reading, which does have the correct value of 100.

Not even a hint of a clue how that happened folks, but somehow I managed to upload a faulty version. V 1b is in post 1 with the fix. CT trading turned back on by default, so let's see if the trades open and close properly now.

:xm:
Author:  phil_trade [ Thu May 08, 2014 11:54 am ]
Post subject:  Best Bob

phil_trade » Today, 11:47 wrote:With BreakEven allowed I have bug alert : Invalid Stop Loss cause GBPJPY wants to Move SL of EUCAD trade ....

just stop this with :

but it seems there's a mess in Symbol and/or Trade management :

Code: Select all

void BreakEvenStopLoss() // Move stop loss to breakeven
{

if (OrderSymbol() != Symbol()) return;
Steve

I think I have found the problem with this example above. The problem occur when a new GBPJPY trade was generated. the Chart GBPJPY try to modify an EURCAD trade and calculate a wrong SL value.
I guess that the problem come that BOB EA is a single Symbol EA and we run it on multiple charts. When one chart is in CountOpenTrades() module, and another chart add or close a trade, then the loop

Code: Select all

for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
is disturbed
and this problem could occur for all loops like this one !
Author:  SpiderX [ Thu May 08, 2014 2:54 pm ]
Post subject:  Best Bob

phil_trade » Thu May 08, 2014 7:54 pm wrote:
Steve

I think I have found the problem with this example above. The problem occur when a new GBPJPY trade was generated. the Chart GBPJPY try to modify an EURCAD trade and calculate a wrong SL value.
I guess that the problem come that BOB EA is a single Symbol EA and we run it on multiple charts. When one chart is in CountOpenTrades() module, and another chart add or close a trade, then the loop

Code: Select all

for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
is disturbed
and this problem could occur for all loops like this one !
Hi phil,

Wow...cant believe you caught this.
Wonder what are the chances for this to happen.

Cheers
Author:  phil_trade [ Thu May 08, 2014 3:07 pm ]
Post subject:  Best Bob

SpiderX » 8 minutes ago wrote:
phil_trade » Thu May 08, 2014 7:54 pm wrote:
Steve

I think I have found the problem with this example above. The problem occur when a new GBPJPY trade was generated. the Chart GBPJPY try to modify an EURCAD trade and calculate a wrong SL value.
I guess that the problem come that BOB EA is a single Symbol EA and we run it on multiple charts. When one chart is in CountOpenTrades() module, and another chart add or close a trade, then the loop

Code: Select all

for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
is disturbed
and this problem could occur for all loops like this one !
Hi phil,

Wow...cant believe you caught this.
Wonder what are the chances for this to happen.

Cheers
it's happen to me this afternoon... error message just fire after the second a new trade on GBPJPY... there are 25 charts running... so a lot of possibilities to crunch.

Need to code to filter better Symbol().

I have to add this

Code: Select all

if (OrderSymbol() != Symbol()) return;
at the beginning of a lot of module to stop bugs
Author:  SpiderX [ Thu May 08, 2014 3:18 pm ]
Post subject:  Best Bob

The below can be a possible fix, though i can already imagine how it might fail...if you got multiple orders opening and closing at the same time.
Not perfect, but guess....it could work ?

Cheers

Code: Select all

int InitialOrdersTotal = OrdersTotal();
for (int cc = InitialOrdersTotal - 1; cc >= 0; cc--)
{
     if(OrdersTotal()!= InitialOrdersTotal)
     {
         InitialOrdersTotal = OrdersTotal();
         cc= InitialOrdersTotal -1;
         continue;
     }

     ..............
}
Author:  phil_trade [ Thu May 08, 2014 3:20 pm ]
Post subject:  Best Bob

SpiderX » 1 minute ago wrote:The below can be a possible fix, though i can already imagine how it might fail...if you got multiple orders opening and closing at the same time.
Not perfect, but guess....it could work ?

Cheers

Code: Select all

int InitialOrdersTotal = OrdersTotal();
for (int cc = InitialOrdersTotal - 1; cc >= 0; cc--)
{
     if(OrdersTotal()!= InitialOrdersTotal)
     {
         InitialOrdersTotal = OrdersTotal();
         cc= InitialOrdersTotal -1;
         continue;
     }

     ..............
}
I will test that. for now I have to add this

Code: Select all

if (OrderSymbol() != Symbol()) return;
at the beginning of a lot of module to stop bugs
Author:  phil_trade [ Thu May 08, 2014 3:37 pm ]
Post subject:  Best Bob

phil_trade » 15 minutes ago wrote:
SpiderX » 1 minute ago wrote:The below can be a possible fix, though i can already imagine how it might fail...if you got multiple orders opening and closing at the same time.
Not perfect, but guess....it could work ?

Cheers

Code: Select all

int InitialOrdersTotal = OrdersTotal();
for (int cc = InitialOrdersTotal - 1; cc >= 0; cc--)
{
     if(OrdersTotal()!= InitialOrdersTotal)
     {
         InitialOrdersTotal = OrdersTotal();
         cc= InitialOrdersTotal -1;
         continue;
     }

     ..............
}
May be it will be safer to EXIT the loop if if(OrdersTotal()!= InitialOrdersTotal) and wait next tick ? this should avoid all add/close trade interference ?
All times are UTC Page 5 of 8