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

Nanningbob 10.2 auto-trading EA
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=552
Page 22 of 54
Author:  spotdespot [ Thu May 24, 2012 8:23 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

Thanks for your help with this Philippe. I am still getting the partial close issue - the same as highlighted above. I tried restoring the 2 lines you mentioned (each in 2 places?) but that didn't seem to do the trick. I have tried looking through the code but I am going round in circles.... :(

The last fix for WeeklyDirection worked - thanks.
Author:  phil_trade [ Thu May 24, 2012 8:26 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

spotdespot wrote:Thanks for your help with this Philippe. I am still getting the partial close issue - the same as highlighted above. I tried restoring the 2 lines you mentioned (each in 2 places?) but that didn't seem to do the trick. I have tried looking through the code but I am going round in circles.... :(

The last fix for WeeklyDirection worked - thanks.
Below my JumpingStopLoss routine

Code: Select all

void JumpingStopLoss() 
{
   // Jump sl by pips and at intervals chosen by user .
   //if (OrderProfit() < 0) return;//Nothing to do.
   
   //Use the sl line if this is drawn on the chart.
   string LineName = SlPrefix + DoubleToStr(OrderTicket(), 0);
   double sl = OrderStopLoss();
   if (ObjectFind(LineName) > -1)
   {
      sl = ObjectGet(LineName, OBJPROP_PRICE1);
   }//if (ObjectFind(LineName) > -1)
   
   //if (sl == 0) return;//No line, so nothing to do
   double NewStop;
   bool modify=false;
   bool result;
   
   
    if (OrderType()==OP_BUY)
    {
       if (sl < OrderOpenPrice() ) return;//Not at breakeven yet
       // Increment sl by sl + JumpingStopPips.
       // This will happen when market price >= (sl + JumpingStopPips)
       //if (Bid>= sl + ((JumpingStopPips*2)*Point) )
       if (sl == 0) sl = MathMax(sl, OrderOpenPrice());//No hidden stop loss line
       if (Bid >=  sl + ((JumpingStopPips * 2) * Point) )//George{
       {
          NewStop = NormalizeDouble(sl + (JumpingStopPips * Point), Digits);
          if (AddBEP) NewStop = NormalizeDouble(NewStop + (BreakEvenProfit*Point), Digits);
          ObjectMove(LineName, 0, Time[0], NewStop);
          if (NewStop - OrderStopLoss() >= Point) modify = true;//George again. What a guy
       }// if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())     
    }//if (OrderType()==OP_BUY)
       
       if (OrderType()==OP_SELL)
       {
          if (sl > OrderOpenPrice() ) return;//Not at breakeven yet
          // Decrement sl by sl - JumpingStopPips.
          // This will happen when market price <= (sl - JumpingStopPips)
          //if (Bid<= sl - ((JumpingStopPips*2)*Point)) Original code
          if (sl == 0) sl = MathMax(sl, OrderOpenPrice());//No hidden stop loss line
          if (Bid <= sl - ((JumpingStopPips * 2) * Point) )//George
          {
             NewStop = NormalizeDouble(sl - (JumpingStopPips * Point), Digits);
             if (AddBEP) NewStop = NormalizeDouble(NewStop - (BreakEvenProfit*Point), Digits);
             ObjectMove(LineName, 0, Time[0], NewStop);
             if (OrderStopLoss() - NewStop >= Point || OrderStopLoss() == 0) modify = true;//George again. What a guy   
          }// close if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())         
       }//if (OrderType()==OP_SELL)


             
   //Move 'hard' stop loss whether hidden or not. Don't want to risk losing a breakeven through disconnect.
   if (modify)
   {
      while (IsTradeContextBusy() ) Sleep(100);
      result = OrderModify(OrderTicket(), OrderOpenPrice(), NewStop, OrderTakeProfit(), OrderExpiration(), CLR_NONE);      
      if (!result) ReportError();      
      Print(Symbol()+" Jumping SL");
      if (PartCloseEnabled && OrderLots() > Preserve_Lots)// Only try to do this if the jump stop worked
      {
         bool PartCloseSuccess = PartCloseTradeFunction();
         //if (!PartCloseSuccess) SetAGlobalTicketVariable();
      }//if (PartCloseEnabled && OrderLots() > Preserve_Lots)
   }//if (modify)

} //End of JumpingStopLoss sub
Author:  mackaozy [ Thu May 24, 2012 8:28 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

[/quote]

Hmmm...It's up to steve to do that ! It's his home here :D

but you can Cut and paste the code and compile it ![/quote]

Yep I guess so :D Whereabouts does the code need to be pasted? Sorry I am dumb lol :oops:
Author:  phil_trade [ Thu May 24, 2012 8:33 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

mackaozy wrote:
Hmmm...It's up to steve to do that ! It's his home here :D

but you can Cut and paste the code and compile it ![/quote]

Yep I guess so :D Whereabouts does the code need to be pasted? Sorry I am dumb lol :oops:[/quote]


just replace the JumpingStopLoss() routine
Author:  mackaozy [ Thu May 24, 2012 8:37 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

phil_trade wrote:
mackaozy wrote:
Hmmm...It's up to steve to do that ! It's his home here :D

but you can Cut and paste the code and compile it !
Yep I guess so :D Whereabouts does the code need to be pasted? Sorry I am dumb lol :oops:[/quote]


just replace the JumpingStopLoss() routine[/quote]

Cheers :)
Author:  spotdespot [ Thu May 24, 2012 9:13 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

phil_trade wrote:
Below my JumpingStopLoss routine
Thanks again Philippe - all looking good now.
Author:  jjasper7 [ Thu May 24, 2012 6:16 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

thank you, phil
re:trend trades ....
changing to ...Direction != up) return(false);
instead of
WeeklyDirection <= up)
is subtle - i do not see the difference! is '<=' not valid in Empty4 or something?
Author:  phil_trade [ Fri May 25, 2012 5:52 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

jjasper7 wrote:thank you, phil
re:trend trades ....
changing to ...Direction != up) return(false);
instead of
WeeklyDirection <= up)
is subtle - i do not see the difference! is '<=' not valid in Empty4 or something?
for sure <= is valid in Empty4 but we are in routine "LookForLongTrend(int tf)" to see if Trend is Long so
if you test "if (WeeklyDirection <= up) return(false);"
then when WeeklyDirection is UP you return false.... it's not correct !
Author:  spotdespot [ Fri May 25, 2012 8:33 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

jjasper7 wrote:thank you, phil
re:trend trades ....
changing to ...Direction != up) return(false);
instead of
WeeklyDirection <= up)
is subtle - i do not see the difference! is '<=' not valid in Empty4 or something?
WeeklyDirection is a string (text) <= doesn't work so well with text. != (not equal to) does.
Author:  alex_forex [ Sat May 26, 2012 9:17 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

Hi all :)

Some bugs on Friday with V1N (I'll update the EA on my VPS over the Week End)

Broker Alpari UK
Capture1.JPG
Capture2.JPG

Regards
Alex
All times are UTC Page 22 of 54