expertremove order

To add comments, please log in or register
Ghasem Mohammadi Nemat Abad
31
Ghasem Mohammadi Nemat Abad  

i write this code for expertremove() but dont meta order it.


just order else if and when AccountEquity is < target dont order it.


for eaxample:

if Equity rise to goal + 80 order done.

but when Equity rise to goal + 60 then decrease dont run and dont Expert remove.


thanks for your comment.


 if(AccountEquity() > Goal)
   {
     if(AccountEquity() < Goal - 2)ExpertRemove();
     else if(AccountEquity() > Goal + 5)
     {
       if(AccountEquity() < Goal + 3)ExpertRemove();
       else if(AccountEquity() > Goal + 10)
       {
         if(AccountEquity() < Goal + 8)ExpertRemove();
         else if(AccountEquity() > Goal + 15)
         {
           if(AccountEquity() < Goal + 13)ExpertRemove();
           else if(AccountEquity() > Goal + 20)
           {
             if(AccountEquity() < Goal + 18)ExpertRemove();
             else if(AccountEquity() > Goal + 25)
             {
               if(AccountEquity() < Goal + 23)ExpertRemove();
               else if(AccountEquity() > Goal + 30)
               {
                 if(AccountEquity() < Goal + 28)ExpertRemove();
                 else if(AccountEquity() > Goal + 35)
                 {
                   if(AccountEquity() < Goal + 33)ExpertRemove();
                   else if(AccountEquity() > Goal + 40)
                   {
                     if(AccountEquity() < Goal + 38)ExpertRemove();
                     else if(AccountEquity() > Goal + 45)
                     {
                       if(AccountEquity() < Goal + 43)ExpertRemove();
                       else if(AccountEquity() > Goal + 50)
                       {
                         if(AccountEquity() < Goal + 48)ExpertRemove();
                         else if(AccountEquity() > Goal + 55)
                         {
                           if(AccountEquity() < Goal + 53)ExpertRemove();
                           else if(AccountEquity() > Goal + 60)
                           {
                             if(AccountEquity() < Goal + 58)ExpertRemove();
                             else if(AccountEquity() > Goal + 65)
                             {
                               if(AccountEquity() < Goal + 63)ExpertRemove();
                               else if(AccountEquity() > Goal + 70)
                               {
                                 if(AccountEquity() < Goal + 68)ExpertRemove();
                                 else if(AccountEquity() > Goal + 75)
                                 {
                                   if(AccountEquity() < Goal + 73)ExpertRemove();
                                   else if(AccountEquity() > Goal + 80)ExpertRemove();
                                 }
                               }
                             }
                           }
                         }
                       }
                     }
                   }
                 }
               }
             }
           }
         }
       }
     }
   }
 }
William Roeder
20228
William Roeder  
 if(AccountEquity() > Goal)
   {
     if(AccountEquity() < Goal - 2)ExpertRemove();
The first tick above goal removes the Expert. No further code will ever execute.
Ghasem Mohammadi Nemat Abad
31
Ghasem Mohammadi Nemat Abad  
whroeder1:
The first tick above goal removes the Expert. No further code will ever execute.
Thanks
Alain Verleyen
38701
Alain Verleyen  
whroeder1:
The first tick above goal removes the Expert. No further code will ever execute.

Really ? Check again. And please read the documentation.

ExpertRemove() statement will never execute, whatever the equity and goal value. The inner if can never be true.

 ...
 else if(AccountEquity() > Goal + 30)
     {
       if(AccountEquity() < Goal + 28)ExpertRemove();   // ALWAYS false
       ...

Even if it was executed all the code would run.

The Expert Advisor is not stopped immediately as you call ExpertRemove(); just a flag to stop the EA operation is set. That is, any next event won't be processed, OnDeinit() will be called and the Expert Advisor will be unloaded and removed from the chart.

Alain Verleyen
38701
Alain Verleyen  
Ghasem Mohammadi Nemat Abad:

i write this code for expertremove() but dont meta order it.


just order else if and when AccountEquity is < target dont order it.


for eaxample:

if Equity rise to goal + 80 order done.

but when Equity rise to goal + 60 then decrease dont run and dont Expert remove.


thanks for your comment.


What you really want is not clear. A trailing equity stop : Remove EA is Equity above "Goal" and loss more than 2 from the maximum  ?

Also you don't just need to remove the EA. You certainly want to close open orders too.

Ghasem Mohammadi Nemat Abad
31
Ghasem Mohammadi Nemat Abad  
Alain Verleyen:

What you really want is not clear. A trailing equity stop : Remove EA is Equity above "Goal" and loss more than 2 from the maximum  ?

Also you don't just need to remove the EA. You certainly want to close open orders too.

thanks for your commet.
yes your right.
just if aquity rise to 80 done .

for this i chenge my alquritm.

thanks for help my friend

To add comments, please log in or register