i would like to know how i can ajust a martingale program to return to lotsize 0.01 after 2 consecutive wins.
Normaly a martingale starts over after 1 win..
I have tried this way but not sure if this is correct .
for(int x=counter-1;x>=0;x--) (I change the 0 to 1 to get consecutive loss1.
Please check this code and let me know if the code is correct
int consecutive_loss0; int consecutive_loss1; int consecutive_loss2; int consecutive_loss3; int consecutive_loss4; int consecutive_loss5; int consecutive_loss6; int consecutive_loss7; int consecutive_loss8; int consecutive_loss9; int consecutive_loss10; int consecutive_loss11; int consecutive_loss12; int consecutive_loss13; int consecutive_loss14; int consecutive_loss15; { //The variable that holds the number of consecutive losses counting from the latest //order open time (closed trades) int counter = 0; datetime opentime[]; double profit[]; for(int index=0;index<OrdersHistoryTotal();index++) { if(!OrderSelect(index,SELECT_BY_POS,MODE_HISTORY) ) continue; else if(OrderMagicNumber() == magicnumber && OrderSymbol() == Symbol() ) { counter++ ; ArrayResize( opentime, counter); ArrayResize( profit, counter); opentime[counter -1]=OrderOpenTime(); //If you change OrderOpenTime() to OrderCloseTime() it will calculate using profit[counter -1]=OrderProfit(); // close time instead of open time } } int orderarray []; ArrayResize( orderarray, counter); datetime copyopentime[]; ArrayResize( copyopentime, counter); ArrayCopy(copyopentime,opentime);
Hello
i would like to know how i can ajust a martingale program to return to lotsize 0.01 after 2 consecutive wins.
Normaly a martingale starts over after 1 win..
I have tried this way but not sure if this is correct .
for(int x=counter-1;x>=0;x--) (I change the 0 to 1 to get consecutive loss1.
Please check this code and let me know if the code is correct
int consecutive_loss1;
int consecutive_loss2;
int consecutive_loss3;
int consecutive_loss4;
int consecutive_loss5;
int consecutive_loss6;
int consecutive_loss7;
int consecutive_loss8;
int consecutive_loss9;
int consecutive_loss10;
int consecutive_loss11;
int consecutive_loss12;
int consecutive_loss13;
int consecutive_loss14;
int consecutive_loss15;
{
//The variable that holds the number of consecutive losses counting from the latest
//order open time (closed trades)
int counter = 0;
datetime opentime[];
double profit[];
for(int index=0;index<OrdersHistoryTotal();index++)
{
if(!OrderSelect(index,SELECT_BY_POS,MODE_HISTORY) )
continue;
else
if(OrderMagicNumber() == magicnumber && OrderSymbol() == Symbol() )
{
counter++ ;
ArrayResize( opentime, counter);
ArrayResize( profit, counter);
opentime[counter -1]=OrderOpenTime(); //If you change OrderOpenTime() to OrderCloseTime() it will calculate using
profit[counter -1]=OrderProfit(); // close time instead of open time
}
}
int orderarray [];
ArrayResize( orderarray, counter);
datetime copyopentime[];
ArrayResize( copyopentime, counter);
ArrayCopy(copyopentime,opentime);
for(int x=counter-1;x>=0;x--)
{
int latest = ArrayMaximum(copyopentime,WHOLE_ARRAY,0) ;
orderarray[x]=latest;
copyopentime[latest] = 0;
}
for(int x=counter-1;x>=0;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss0++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=1;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss1++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=2;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss2++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=3;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss3++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=4;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss4++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=5;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss5++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=6;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss6++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=7;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss7++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=8;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss8++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=9;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss9++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=10;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss10++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=11;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss11++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=12;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss12++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=13;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss13++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=14;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss14++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
for(int x=counter-1;x>=15;x--)
{
int pos = orderarray[x];
if(profit[pos]<0)
consecutive_loss15++;
else
break;
//Print(" Profit = ",profit[pos]) ;
}
}