# Martingail Expert

30

I would put, linear Martingale 1, 2, 3, 4.

could help me in this code I determine a price, and this price is as start and stop it have to do to stop the manual or TP or TrailingStop order.

Can anyone help me how to do this?

```//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
extern double TakeProfit=10000;
extern double timeframe=0; //0=atual / 1=1M / 60=1H / 240=4H / 1440=1D / 10080=1Semana / 43200=1MES
extern double Lots=0.01;
extern double TrailingStop=0;
extern double Stop_loss_sell=0;
extern double Price_sell1=0;

//---
string lastSignalUsed="No signal";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
{

double Price1,Price2;
int cnt,ticket,total;

Price1=iMA(NULL,timeframe,1,0,MODE_SMA,0,1);         //PREÇO atual
Price2=iMA(NULL,timeframe,1,0,MODE_SMA,0,2);         //PREÇO anterior

total=OrdersTotal();
if(total<1)
{

if(AccountFreeMargin()<(1*Lots))
{
Print("Account Free Margin = ",AccountFreeMargin());
return(0);
}

if(

)
{
if(ticket>0)
{
{
}
}
return(0);
}

if(
(Price1<Price_sell1 && Price2>Price_sell1)

)
{
if(ticket>0)
{
{
Print("SELL : ",OrderOpenPrice());
lastSignalUsed="Sell";
}
}
else Print("SELL  Error: ",GetLastError());
return(0);
}
return(0);
}

for(cnt=0;cnt<total;cnt++)
{
{
Print("OrderSelect() failed with error :  "+GetLastError());
}
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
{

(Price1<Price_sell1 && Price2>Price_sell1)

)
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Red))
{
Print("OrderClose() failed with error :  "+GetLastError());
return(0);
}
}

if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Gray))
{
Print("OrderModify() failed with error :  "+GetLastError());
}
return(0);
}
}
}
}
else
{
if(        //CLOSE SELL

)

{
{
Print("OrderClose() failed with error :  "+GetLastError());
return(0);
}
}
if(TrailingStop>0)
{
{
{
{
Print("OrderModify() failed with error :  "+GetLastError());
return(0);
}
}
}
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
```
Files:
manual_sr.zip 246 kb
30

someone help me?
1399