Если сов как-то нумерует ведомые ордерки, может как-то можно ему подсказать, чтобы учитывал их через 1 или через 2?
Лот начинает изменяться до того как баланс увеличивается (в данном случае) на 1000, т.е., допустим, начальный баланс 1000, как только баланс переваливает за 1501, лот уже начинает увеличивается!?.. А надо чтобы лот начинал увеличиваться на каждую полную (в данном случае) 1000!?.. Как это сделать, не могу понять?!..
// баланс уменьшился с 3100 до 2900
if(AccountBalance()< PrevBalance && (int)AccountBalance()/1000<(int)PrevBalance/1000)lot=lot-0.1;
Прошу вас только добавить общий траал, и тогда все будет круто
Извините, появилась другая проблемка. Советник не раскрывает замок когда цена находится выше замка.
input int bar = 4; //расстояние между линиями
input int sdvig = 10; //сдвиг назад от нулевого бара
input int bars = 150; //баров для расчета
input int width = 1; //толщина линии
Всё бы было Хорошо, только 2 дня назад он выкинул ошибку 129 «Ошибка закрытия ордера », цена дошла до стопа покрутилась там пару свечей и вышла ошибка.
Уважаемые программисты, поправьте его пожалуйста
double Lot()
{
double LotSize=MarketInfo(Symbol(),MODE_LOTSIZE);
double MinLot=MarketInfo(Symbol(),MODE_MINLOT);
double lot=Lots;
lot=NormalizeDouble(AccountBalance()/10000,1);
//баланс меньше 1000
if(AccountBalance()<1000)
{
lot=NormalizeDouble(AccountBalance()*Risk/LotSize,2);
if(lot<=MinLot) lot=MinLot;
if(lot>=MaxLot) lot=MaxLot;
}
// баланс уменьшился с 3100 до 2900
if(AccountBalance()< PrevBalance && (int)AccountBalance()/1000<(int)PrevBalance/1000)lot=lot-0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Lot.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double MaxLot = 10; // максимальный лот
extern double Risk = 5; // риск
extern int StopLoss = 500; // лось
extern int TakeProfit = 500; // язь
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
int Lock=0;
double PrevBalance=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=clrNONE;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double LotSize=MarketInfo(Symbol(),MODE_LOTSIZE);
double MinLot=MarketInfo(Symbol(),MODE_MINLOT);
double lot=Lots;
lot=NormalizeDouble(AccountBalance()/10000,1);
//баланс меньше 1000
if(AccountBalance()<1000)
{
lot=NormalizeDouble(AccountBalance()*Risk/LotSize,2);
if(lot<=MinLot) lot=MinLot;
if(lot>=MaxLot) lot=MaxLot;
}
// баланс уменьшился с 3100 до 2900
if(AccountBalance()< PrevBalance && (int)AccountBalance()/1000<(int)PrevBalance/1000)lot=lot-0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double rsi=iRSI(NULL,0,14,PRICE_CLOSE,1);
if(CountTrades()<1 && rsi<30)
{
PrevBalance=AccountBalance();
PutOrder(0,Ask);
//PutOrder(1,Bid);
}
Comment("\n Lot: ",Lot(),
"\n Balance: ",NormalizeDouble(AccountBalance(),2),
"\n PrevBalance: ",PrevBalance,
"\n LotSize: ",MarketInfo(Symbol(),MODE_LOTSIZE),
"\n Balance/1000: ",NormalizeDouble(AccountBalance()/1000,0),
"\n int Balance/1000: ",(int)AccountBalance()/1000, //
"\n int PrevBalance/1000: ",(int)PrevBalance/1000);
}
//+------------------------------------------------------------------+
Можете подправить советник, надо чтоб после закрытия по общему профиту ждать сигнала ( время ) для открытия замка, а то сейчас он сразу открывает замок.
AM2