Nanningbob 10.2 auto-trading EA

Share your 10.x automated traders here.
Locked
spotdespot
Trader
Posts: 768
Joined: Sun Jan 22, 2012 11:38 pm

Re: 10.2; the auto-trading EA is born.

Post by spotdespot »

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.
phil_trade

Re: 10.2; the auto-trading EA is born.

Post by phil_trade »

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
mackaozy
Trader
Posts: 190
Joined: Sat Mar 17, 2012 1:22 pm

Re: 10.2; the auto-trading EA is born.

Post by mackaozy »

[/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:
phil_trade

Re: 10.2; the auto-trading EA is born.

Post by phil_trade »

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
mackaozy
Trader
Posts: 190
Joined: Sat Mar 17, 2012 1:22 pm

Re: 10.2; the auto-trading EA is born.

Post by mackaozy »

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 :)
spotdespot
Trader
Posts: 768
Joined: Sun Jan 22, 2012 11:38 pm

Re: 10.2; the auto-trading EA is born.

Post by spotdespot »

phil_trade wrote:
Below my JumpingStopLoss routine
Thanks again Philippe - all looking good now.
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: 10.2; the auto-trading EA is born.

Post by jjasper7 »

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?
phil_trade

Re: 10.2; the auto-trading EA is born.

Post by phil_trade »

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 !
spotdespot
Trader
Posts: 768
Joined: Sun Jan 22, 2012 11:38 pm

Re: 10.2; the auto-trading EA is born.

Post by spotdespot »

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.
User avatar
alex_forex
Trader
Posts: 438
Joined: Tue Nov 15, 2011 5:46 pm
Location: F R A N C E

Re: 10.2; the auto-trading EA is born.

Post by alex_forex »

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
You do not have the required permissions to view the files attached to this post.
Locked

Return to “10.x EA forum”