extern int MA_length = 10;
extern double Percent = 0.2;
extern int TradeOnFriday =1; // >0 trades on friday
extern int MAtype=0;//0=close, 1=HL
extern int slip = 100;//exits only
extern int Lots = 1;
extern int TakeProfit = 30;
extern int Stoploss = 200;// total loss on all open positions in pips
extern int PipStep = 30;//if position goes this amount of pips against you add another.
extern double IncreasementType =0;//0=just add every PipStep, >0 =OrdersToal()^x *Pipstep
double Stopper=0;
double KeepStopLoss=0;
double KeepAverage;
double dummy;
double spread=0;
double CurrentPipStep;
int OrderWatcher=0;
int start()
{
// код доступен только после оплаты
}
double PriceTarget;
double AveragePrice;
int OpeningDay;
CurrentPipStep=PipStep;
if(IncreasementType>0)
{
CurrentPipStep=MathSqrt(OrdersTotal())*PipStep;
CurrentPipStep=MathPow(OrdersTotal(),IncreasementType)*PipStep;
}
int Direction=0;//1=long, 11=avoid long, 2=short, 22=avoid short
if (Day()!=5 || TradeOnFriday >0)
{
int cnt=0, total,OpenTradesOnSymbol=0;
total=OrdersTotal();
for (cnt=total;cnt>0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol()) // check for symbol
{
double LastPrice=OrderOpenPrice();
break;
}
}
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_SELL || OrderType()==OP_BUY &&
OrderSymbol()==Symbol() ) OpenTradesOnSymbol++;
}
double MagicNumber=0;
datetime orderclosetime;
string rightnow;
int rightnow2;
int TheHistoryTotal=HistoryTotal();
int difference;
int flag=0;
for(cnt=0;cnt<TheHistoryTotal;cnt++) {
if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==true)
{
if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) ) {
orderclosetime=OrderCloseTime();
rightnow=Year()+"-"+Month()+"-"+Day()+" "+Hour()+":"+Minute()+":"+Seconds();
rightnow2=StrToTime(rightnow);
difference=rightnow2-orderclosetime;
if(Period()*60*2>difference) { // At least 2 periods away!
flag=1; // Throw a flag
break;
}
}
}
}
if(flag!=1) {
OrderWatcher=0;
if(MAtype==0)
{
if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_OPEN,0)*(1+Percent/100))<Bid && Direction!=22 && (Bid>=(LastPrice+(CurrentPipStep*Point))||OpenTradesOnSymbol==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),0,0,Red);
OrderWatcher=1;
Direction=2;
}
if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_OPEN,0)*(1-Percent/100))>Ask && Direction!=11 && (Ask<=(LastPrice-(CurrentPipStep*Point))||OpenTradesOnSymbol==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),0,0,Blue);
OrderWatcherПоказано первые 50% кода (символов: 4764)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.