Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Здравствуйте,
у меня есть советник, хочу добавить туда добавление/изменение уровней лос и профит, прописал в коде, ничего не выходит, подскажите, что длаю не так, в какой строке ошибка
extern double lots = 1;
extern double POS_tp = 5;
extern double POS_sl = 30;
extern int prsi = 29;
extern int fastmacd = 55;
extern int slowmacd = 90;
extern int signalmacd = 65;
extern int ptenkan = 60;
extern int pema = 86;
extern int plwma = 85;
extern int psmma = 42;
extern int stochD = 62;
extern int stochK = 82;
extern int stochS = 65;
extern int magic = 888;
extern int slippage = 0;
static int prevtime = 0;
int init() {
prevtime = Time[0];
return(0);
}
int start() {
double pos_tp = 0.0;
double pos_sl = 0.0;
if (! IsTradeAllowed()) {
return(0);
}
if (Time[0] == prevtime) {
return(0);
}
prevtime = Time[0];
int ticket = -1;
int total = OrdersTotal();
for (int i = total - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == magic)) {
int prevticket = OrderTicket();
if (OrderType() == OP_BUY) {
if (shortsignal()) {
ticket = OrderSend(Symbol(), OP_SELL, 2.0 * lots, slippage, pos_sl, pos_tp, Bid, WindowExpertName(), magic, 0, Red);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
return(0);
} else {
OrderCloseBy(ticket, prevticket, Red);
}
}
} else {
if (longsignal()) {
ticket = OrderSend(Symbol(), OP_BUY, 2.0 * lots, slippage, pos_sl, pos_tp, Ask, WindowExpertName(), magic, 0, Blue);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
return(0);
} else {
OrderCloseBy(ticket, prevticket, Blue);
}
}
}
return(0);
}
}
if (longsignal()) {
ticket = OrderSend(Symbol(), OP_BUY, lots, slippage, pos_sl, pos_tp, Ask, WindowExpertName(), magic, 0, Blue);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
}
return(0);
}
if (shortsignal()) {
ticket = OrderSend(Symbol(), OP_SELL, lots, slippage, pos_sl, pos_tp, Bid, WindowExpertName(), magic, 0, Red);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
}
return(0);
}
return(0);
}
bool longsignal() {
if (fcandle() < 0) {
return(false);
}
if (frsi() < 0) {
return(false);
}
if (fao() < 0) {
return(false);
}
if (fmacd() < 0) {
return(false);
}
if (fosma1() < 0) {
return(false);
}
if (fema() < 0) {
return(false);
}
if (fema1() < 0) {
return(false);
}
if (fichimoku() < 0) {
return(false);
}
if (flwma() < 0) {
return(false);
}
if (flwma1() < 0) {
return(false);
}
if (fsmma() < 0) {
return(false);
}
if (fsmma1() < 0) {
return(false);
}
if (fstoch() < 0) {
return(false);
}
if (fstoch2() < 0) {
return(false);
}
return(true);
}
bool shortsignal() {
if (fcandle() > 0) {
return(false);
}
if (frsi() > 0) {
return(false);
}
if (fao() > 0) {
return(false);
}
if (fmacd() > 0) {
return(false);
}
if (fosma1() > 0) {
return(false);
}
if (fema() > 0) {
return(false);
}
if (fema1() > 0) {
return(false);
}
if (fichimoku() > 0) {
return(false);
}
if (flwma() > 0) {
return(false);
}
if (flwma1() > 0) {
return(false);
}
if (fsmma() > 0) {
return(false);
}
if (fsmma1() > 0) {
return(false);
}
if (fstoch() > 0) {
return(false);
}
if (fstoch2() > 0) {
return(false);
}
return(true);
}
int fcandle() {
int result = 0;
if (Open[0] < Open[1]) {
result = 1;
}
if (Open[0] > Open[1]) {
result = -1;
}
return(result);
}
int frsi() {
int result = 0;
double ind = iRSI(Symbol(), 0, prsi, PRICE_OPEN, 0) - 50.0;
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int fao() {
int result = 0;
double ind = iAO(Symbol(), 0, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int fmacd() {
int result = 0;
double ind = iMACD(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, MODE_MAIN, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int fosma1() {
int result = 0;
double ind = iOsMA(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, 0);
double ind1 = iOsMA(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, 1);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fema() {
int result = 0;
double ind = Open[0] - iMA(Symbol(), 0, pema, 0, MODE_EMA, PRICE_OPEN, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int fema1() {
int result = 0;
double ind = iMA(Symbol(), 0, pema, 0, MODE_EMA, PRICE_OPEN, 0);
double ind1 = iMA(Symbol(), 0, pema, 0, MODE_EMA, PRICE_OPEN, 1);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fichimoku() {
int result = 0;
double ind = Open[0] - iIchimoku(Symbol(), 0, ptenkan, 83, 28, MODE_TENKANSEN, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int flwma() {
int result = 0;
double ind = Open[0] - iMA(Symbol(), 0, plwma, 0, MODE_LWMA, PRICE_OPEN, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int flwma1() {
int result = 0;
double ind = iMA(Symbol(), 0, plwma, 0, MODE_LWMA, PRICE_OPEN, 0);
double ind1 = iMA(Symbol(), 0, plwma, 0, MODE_LWMA, PRICE_OPEN, 1);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fsmma() {
int result = 0;
double ind = Open[0] - iMA(Symbol(), 0, psmma, 0, MODE_SMMA, PRICE_OPEN, 0);
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}
int fsmma1() {
int result = 0;
double ind = iMA(Symbol(), 0, psmma, 0, MODE_SMMA, PRICE_OPEN, 0);
double ind1 = iMA(Symbol(), 0, psmma, 0, MODE_SMMA, PRICE_OPEN, 1);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fstoch() {
int result = 0;
double ind = iStochastic(Symbol(), 0, stochK, stochD, stochS, MODE_SMMA, 0,MODE_SIGNAL, 0);
double ind1 = iStochastic(Symbol(), 0, stochK, stochD, stochS, MODE_SMMA, 0,MODE_MAIN, 0);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fstoch2() {
int result = 0;
double ind = iStochastic(Symbol(), 0, stochK, stochD, stochS, MODE_SMMA, 0,MODE_SIGNAL, 0) - 50.0;
if (ind > 0) {
result = 1;
}
if (ind < 0) {
result = -1;
}
return(result);
}