Thread: Martingale EA
View Single Post
  #416 (permalink)  
Old 02-13-2008, 03:04 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 820
wolfe is on a distinguished road
Quote:
Originally Posted by ajk View Post
wolfe, did you ever get that ts programmed. Otherwise, it will be difficult to make this a profitable adventure.
Yes I did. I'm still testing it. Seems to be working.

It looks something like this-(this part keeps track of your highest profit in the cycle)
PHP Code:
Total_Profit=OPBM(Magic_Long)+OPBM(Magic_Short);

if (
Trailing_Stop==true)  
{
 
Open_Profit=Total_Profit;
 
Highest_Profit=GlobalVariableGet(TFX_Highest_Profit);
 if (
Open_Profit Highest_Profit)
  {
   
Highest_Profit=GlobalVariableSet(TFX_Highest_Profit,Total_Profit);
   
Highest_Profit=GlobalVariableGet(TFX_Highest_Profit);
   
Loss_Percent=TSLoss_Percent*0.01;
   Print(
"                                                                                                 Loss percent = ",Loss_Percent);
   
Allowed_Loss=GlobalVariableGet(TFX_Highest_Profit)*Loss_Percent;
   
Allowed_Loss=GlobalVariableSet(TFX_Allowed_Loss,Allowed_Loss);
   
Allowed_Loss=GlobalVariableGet(TFX_Allowed_Loss);
   Print(
"                                                                                      Highest Profit = ",Highest_Profit);
   Print(
"                                                                                        Allowed Loss = ",Allowed_Loss);
  }

And this part handles the closing of a cycle-
PHP Code:
if ((Trailing_Stop==true) && (Trail_Engaged==true)) 
{
 if (
OPBM(Magic_Long)+OPBM(Magic_Short) <= (GlobalVariableGet(TFX_Highest_Profit)-GlobalVariableGet(TFX_Allowed_Loss)))
  {
   while(
OTBM(Magic_Long)+OTBM(Magic_Short)>0)
   {
   
CBM(Magic_Long);CBM(Magic_Short);
   }
     if (
OTBM(Magic_Long)>0)
      {
       
Sleep(1000);CBM(Magic_Long);
      }
     if (
OTBM(Magic_Short)>0)
      {
       
Sleep(1000);CBM(Magic_Short);
      }
     if (
OTBM(Magic_Long)+OTBM(Magic_Short)==0)
      {
       
GlobalVariableSet(TFX_LastTicketL,0);
       
GlobalVariableSet(TFX_LastOpenL,0);
       
GlobalVariableSet(TFX_LastLotsL,0);
       
GlobalVariableSet(TFX_LastTicketS,0);
       
GlobalVariableSet(TFX_LastOpenS,0);
       
GlobalVariableSet(TFX_LastLotsS,0);
       
GlobalVariableSet(TFX_Highest_Profit,0);
       
GlobalVariableSet(TFX_Allowed_Loss,0);
      }
     
Highest_Profit=GlobalVariableGet(TFX_Highest_Profit);
     
Allowed_Loss=GlobalVariableGet(TFX_Allowed_Loss);
     
Trail_Engaged=false;
    }
  } 
I don't want to post until further testing is satisfied. Plus I have some more ideas for it.
Reply With Quote