MQL4: полезные функции пишем сюда

Тема в разделе "Индикаторы, скрипты и эксперты для МТ4", создана пользователем RickD, 5 июн 2006.

Метки:
  1. finger

    finger Alex

    Существует нет кода
    где start() Функция?
    Что такое Warp,Deviation,Amplitude,Distortion?
     
  2. Herkules

    Herkules Новичок

    void init() {
    if (SL_long_EQUAL_SL_short == TRUE) SL_short = SL_long;
    }

    void deinit() {
    }

    void start() {
    int li_0;
    int li_4;
    int l_ord_total_8;
    int l_ticket_16;
    ExternalParametersCheck();
    CheckConditions();
    if (Time[0] != gi_148) {
    gi_148 = Time[0];
    li_0 = 3;
    if (IsTradeAllowed()) {
    RefreshRates();
    li_0 = MarketInfo(Symbol(), MODE_SPREAD);
    } else {
    gi_148 = Time[1];
    return;
    }
    li_4 = -1;
    l_ord_total_8 = OrdersTotal();
    for (int l_pos_12 = l_ord_total_8 - 1; l_pos_12 >= 0; l_pos_12--) {
    OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
    l_ticket_16 = OrderTicket();
    if (OrderType() == OP_BUY) {
    if (Bid <= OrderStopLoss() + (2.0 * SL_long + li_0) * Point) return;
    if (Direction(Warp, Deviation, Amplitude, Distortion) < 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_SELL, lots, Bid, Slippage, Ask + SL_short * Point, 0, gs_140, MagicNumber, 0, Red);
    Sleep(30000);
    if (li_4 < 0) {
    gi_148 = Time[1];
    return;
    }
    OrderSelect(l_ticket_16, SELECT_BY_TICKET);
    OrderClose(l_ticket_16, OrderLots(), Bid, 3, Blue);
    return;
    }
    if (!(!OrderModifyReliable(OrderTicket(), OrderOpenPrice(), Bid - SL_long * Point, 0, 0, Blue))) return;
    Sleep(30000);
    gi_148 = Time[1];
    return;
    }
    if (Ask >= OrderStopLoss() - (2.0 * SL_short + li_0) * Point) return;
    if (Direction(Warp, Deviation, Amplitude, Distortion) > 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_BUY, lots, Ask, Slippage, Bid - SL_long * Point, 0, gs_140, MagicNumber, 0, Blue);
    Sleep(30000);
    if (li_4 < 0) {
    gi_148 = Time[1];
    return;
    }
    OrderSelect(l_ticket_16, SELECT_BY_TICKET);
    OrderClose(l_ticket_16, OrderLots(), Ask, 3, Blue);
    return;
    }
    if (!(!OrderModifyReliable(OrderTicket(), OrderOpenPrice(), Ask + SL_short * Point, 0, 0, Blue))) return;
    Sleep(30000);
    gi_148 = Time[1];
    return;
    }
    }
    if (Direction(Warp, Deviation, Amplitude, Distortion) > 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_BUY, lots, Ask, Slippage, Bid - SL_long * Point, 0, gs_140, MagicNumber, 0, Blue);
    if (li_4 < 0) {
    Sleep(30000);
    gi_148 = Time[1];
    }
    } else {
    li_4 = OrderSendReliable(Symbol(), OP_SELL, lots, Bid, Slippage, Ask + SL_short * Point, 0, gs_140, MagicNumber, 0, Red);
    if (li_4 < 0) {
    Sleep(30000);
    gi_148 = Time[1];
    }
    }
    }
    }

    double Direction(int ai_0, double ad_4, int ai_12, double ad_16) {
    double ld_ret_24 = 0;
    double l_iac_32 = iAC(Symbol(), 0, 0);
    double l_iac_40 = iAC(Symbol(), 0, 7);
    double l_iac_48 = iAC(Symbol(), 0, 14);
    double l_iac_56 = iAC(Symbol(), 0, 21);
    ld_ret_24 = ai_0 * l_iac_32 + 100.0 * (ad_4 - 1.0) * l_iac_40 + (ai_12 - 100) * l_iac_48 + 100.0 * ad_16 * l_iac_56;
    return (ld_ret_24);
    }

    void ExternalParametersCheck() {
    if (Slippage > 10) {
    Comment("... Задано слишком высокое значение проскальзывания Slippage,",
    "\n", "... Скорректируйте чтобы было не более 10п и перезапустите эксперт.");
    return;
    }
    if (Warp > 100 || Warp < -100) {
    Comment("... Неправильно задан параметр искажения Warp,",
    "\n", "... Диапазон допустимых значений от -100 до +100 с шагом 1,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Deviation > 2.0 || Warp < 0) {
    Comment("... Неправильно задан параметр девиации Deviation,",
    "\n", "... Диапазон допустимых значений от 0 до +2 с шагом 0.01,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Amplitude > 200 || Amplitude < 0) {
    Comment("... Неправильно задан параметр девиации Amplitude,",
    "\n", "... Диапазон допустимых значений от 0 до +200 с шагом 1,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Distortion > 1.0 || Distortion < -1.0) {
    Comment("... Неправильно задан параметр девиации Distortion,",
    "\n", "... Диапазон допустимых значений от -1 до +1 с шагом 0.01,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    }

    void CheckConditions() {
    if (IsConnected() == FALSE) {
    Comment(" ... ОТСУТСТВУЕТ связь с торговым сервером\n" + " ... Приём торговых команд ОСТАНОВЛЕН");
    return;
    }
    if (IsTradeContextBusy() == TRUE) Comment(" ... Торговый поток ЗАНЯТ\n" + " ... Торговая команда на сервер не отослана");
    }

    int OrderSendReliable(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, int a_slippage_28, double a_price_32, double a_price_40, string a_comment_48, int a_magic_56, int a_datetime_60 = 0, color a_color_64 = -1) {
    double ld_96;
    if (!IsConnected()) {
    Print("OrderSendReliable: error: IsConnected() == false");
    return (-1);
    }
    if (IsStopped()) {
    Print("OrderSendReliable: error: IsStopped() == true");
    return (-1);
    }
    for (int l_count_68 = 0; !IsTradeAllowed() && l_count_68 < gi_152; l_count_68++) OrderReliable_SleepRandomTime(gd_156, gd_164);
    if (!IsTradeAllowed()) {
    Print("OrderSendReliable: error: no operation possible because IsTradeAllowed()==false, even after retries.");
    return (-1);
    }
    int li_72 = MarketInfo(a_symbol_0, MODE_DIGITS);
    if (li_72 > 0) {
    a_price_20 = NormalizeDouble(a_price_20, li_72);
    a_price_32 = NormalizeDouble(a_price_32, li_72);
    a_price_40 = NormalizeDouble(a_price_40, li_72);
    }
    if (a_price_32 != 0.0) OrderReliable_EnsureValidStop(a_symbol_0, a_price_20, a_price_32);
    int l_error_76 = GetLastError();
    l_error_76 = 0;
    bool li_80 = FALSE;
    bool li_84 = FALSE;
    int l_ticket_88 = -1;
    if (a_cmd_8 == OP_BUYSTOP || a_cmd_8 == OP_SELLSTOP) {
    l_count_68 = 0;
    while (!li_80) {
    if (IsTradeAllowed()) {
    l_ticket_88 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, a_slippage_28, a_price_32, a_price_40, a_comment_48, a_magic_56, a_datetime_60, a_color_64);
    l_error_76 = GetLastError();
    } else l_count_68++;
    switch (l_error_76) {
    case 0/* NO_ERROR */:
    li_80 = TRUE;
    break;
    case 4/* SERVER_BUSY */:
    case 6/* NO_CONNECTION */:
    case 129/* INVALID_PRICE */:
    case 136/* OFF_QUOTES */:
    case 137/* BROKER_BUSY */:
    case 146/* TRADE_CONTEXT_BUSY */:
    l_count_68++;
    break;
    case 135/* PRICE_CHANGED */:
    case 138/* REQUOTE */:
    RefreshRates();
    continue;
    break;
    case 130/* INVALID_STOPS */:
    ld_96 = MarketInfo(a_symbol_0, MODE_STOPLEVEL) * MarketInfo(a_symbol_0, MODE_POINT);
    if (a_cmd_8 == OP_BUYSTOP) {
    if (MathAbs(Ask - a_price_20) <= ld_96) li_84 = TRUE;
    } else {
    if (a_cmd_8 == OP_SELLSTOP)
    if (MathAbs(Bid - a_price_20) <= ld_96) li_84 = TRUE;
    }
    li_80 = TRUE;
    break;
    default:
    li_80 = TRUE;
    }
    if (l_count_68 > gi_152) li_80 = TRUE;
    if (li_80) {
    if (l_error_76 != 0/* NO_ERROR */) Print("OrderSendReliable: non-retryable error: " + ErrorDescription(l_error_76));
    if (l_count_68 > gi_152) Print("OrderSendReliable: retry attempts maxed at " + gi_152);
    }
    if (!li_80) {
    Print("OrderSendReliable: retryable error (" + l_count_68 + "/" + gi_152 + "): " + ErrorDescription(l_error_76));
    OrderReliable_SleepRandomTime(gd_156, gd_164);
    RefreshRates();
    }
    }
    if (l_error_76 == 0/* NO_ERROR */) {
    Print("OrderSendReliable: apparently successful OP_BUYSTOP or OP_SELLSTOP order placed, details follow.");
    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);
    OrderPrint();
    return (l_ticket_88);
    }
    if (!li_84) {
    Print("OrderSendReliable: failed to execute OP_BUYSTOP/OP_SELLSTOP, after " + l_count_68 + " retries");
    Print("OrderSendReliable: failed trade: " + OrderReliable_CommandString(a_cmd_8) + " " + a_symbol_0 + "@" + a_price_20 + " tp@" + a_price_40 + " sl@" + a_price_32);
    Print("OrderSendReliable: last error: " + ErrorDescription(l_error_76));
    return (-1);
    }
    }
    if (li_84) {
    Print("OrderSendReliable: going from limit order to market order because market is too close.");
    if (a_cmd_8 == OP_BUYSTOP) {
    a_cmd_8 = 0;
    a_price_20 = Ask;
    } else {
    if (a_cmd_8 == OP_SELLSTOP) {
    a_cmd_8 = 1;
    a_price_20 = Bid;
    }
    }
    }
    l_error_76 = GetLastError();
    l_error_76 = 0;
    l_ticket_88 = -1;
    if (a_cmd_8 == OP_BUY || a_cmd_8 == OP_SELL) {
    l_count_68 = 0;
    while (!li_80) {
    if (IsTradeAllowed()) {
    l_ticket_88 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, a_slippage_28, a_price_32, a_price_40, a_comment_48, a_magic_56, a_datetime_60, a_color_64);
    l_error_76 = GetLastError();
    } else l_count_68++;
    switch (l_error_76) {
    case 0/* NO_ERROR */:
    li_80 = TRUE;
    break;
    case 4/* SERVER_BUSY */:
    case 6/* NO_CONNECTION */:
    case 129/* INVALID_PRICE */:
    case 136/* OFF_QUOTES */:
    case 137/* BROKER_BUSY */:
    case 146/* TRADE_CONTEXT_BUSY */:
    l_count_68++;
    break;
    case 135/* PRICE_CHANGED */:
    case 138/* REQUOTE */:
    RefreshRates();
    continue;
    default:
    li_80 = TRUE;
    }
    if (l_count_68 > gi_152) li_80 = TRUE;
    if (!li_80) {
    Print("OrderSendReliable: retryable error (" + l_count_68 + "/" + gi_152 + "): " + ErrorDescription(l_error_76));
    OrderReliable_SleepRandomTime(gd_156, gd_164);
    RefreshRates();
    }
    if (li_80) {
    if (l_error_76 != 0/* NO_ERROR */) Print("OrderSendReliable: non-retryable error: " + ErrorDescription(l_error_76));
    if (l_count_68 > gi_152) Print("OrderSendReliable: retry attempts maxed at " + gi_152);
    }
    }
    if (l_error_76 == 0/* NO_ERROR */) {
    Print("OrderSendReliable: apparently successful OP_BUY or OP_SELL order placed, details follow.");
    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);
    OrderPrint();
    return (l_ticket_88);
    }
    Print("OrderSendReliable: failed to execute OP_BUY/OP_SELL, after " + l_count_68 + " retries");
    Print("OrderSendReliable: failed trade: " + OrderReliable_CommandString(a_cmd_8) + " " + a_symbol_0 + "@" + a_price_20 + " tp@" + a_price_40 + " sl@" + a_price_32);
    Print("OrderSendReliable: last error: " + ErrorDescription(l_error_76));
    return (-1);
    }
    return (0);
    }

     
  3. Herkules

    Herkules Новичок

    void init() {
    if (SL_long_EQUAL_SL_short == TRUE) SL_short = SL_long;
    }

    void deinit() {
    }

    void start() {
    int li_0;
    int li_4;
    int l_ord_total_8;
    int l_ticket_16;
    ExternalParametersCheck();
    CheckConditions();
    if (Time[0] != gi_148) {
    gi_148 = Time[0];
    li_0 = 3;
    if (IsTradeAllowed()) {
    RefreshRates();
    li_0 = MarketInfo(Symbol(), MODE_SPREAD);
    } else {
    gi_148 = Time[1];
    return;
    }
    li_4 = -1;
    l_ord_total_8 = OrdersTotal();
    for (int l_pos_12 = l_ord_total_8 - 1; l_pos_12 >= 0; l_pos_12--) {
    OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
    l_ticket_16 = OrderTicket();
    if (OrderType() == OP_BUY) {
    if (Bid <= OrderStopLoss() + (2.0 * SL_long + li_0) * Point) return;
    if (Direction(Warp, Deviation, Amplitude, Distortion) < 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_SELL, lots, Bid, Slippage, Ask + SL_short * Point, 0, gs_140, MagicNumber, 0, Red);
    Sleep(30000);
    if (li_4 < 0) {
    gi_148 = Time[1];
    return;
    }
    OrderSelect(l_ticket_16, SELECT_BY_TICKET);
    OrderClose(l_ticket_16, OrderLots(), Bid, 3, Blue);
    return;
    }
    if (!(!OrderModifyReliable(OrderTicket(), OrderOpenPrice(), Bid - SL_long * Point, 0, 0, Blue))) return;
    Sleep(30000);
    gi_148 = Time[1];
    return;
    }
    if (Ask >= OrderStopLoss() - (2.0 * SL_short + li_0) * Point) return;
    if (Direction(Warp, Deviation, Amplitude, Distortion) > 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_BUY, lots, Ask, Slippage, Bid - SL_long * Point, 0, gs_140, MagicNumber, 0, Blue);
    Sleep(30000);
    if (li_4 < 0) {
    gi_148 = Time[1];
    return;
    }
    OrderSelect(l_ticket_16, SELECT_BY_TICKET);
    OrderClose(l_ticket_16, OrderLots(), Ask, 3, Blue);
    return;
    }
    if (!(!OrderModifyReliable(OrderTicket(), OrderOpenPrice(), Ask + SL_short * Point, 0, 0, Blue))) return;
    Sleep(30000);
    gi_148 = Time[1];
    return;
    }
    }
    if (Direction(Warp, Deviation, Amplitude, Distortion) > 0.0) {
    li_4 = OrderSendReliable(Symbol(), OP_BUY, lots, Ask, Slippage, Bid - SL_long * Point, 0, gs_140, MagicNumber, 0, Blue);
    if (li_4 < 0) {
    Sleep(30000);
    gi_148 = Time[1];
    }
    } else {
    li_4 = OrderSendReliable(Symbol(), OP_SELL, lots, Bid, Slippage, Ask + SL_short * Point, 0, gs_140, MagicNumber, 0, Red);
    if (li_4 < 0) {
    Sleep(30000);
    gi_148 = Time[1];
    }
    }
    }
    }

    double Direction(int ai_0, double ad_4, int ai_12, double ad_16) {
    double ld_ret_24 = 0;
    double l_iac_32 = iAC(Symbol(), 0, 0);
    double l_iac_40 = iAC(Symbol(), 0, 7);
    double l_iac_48 = iAC(Symbol(), 0, 14);
    double l_iac_56 = iAC(Symbol(), 0, 21);
    ld_ret_24 = ai_0 * l_iac_32 + 100.0 * (ad_4 - 1.0) * l_iac_40 + (ai_12 - 100) * l_iac_48 + 100.0 * ad_16 * l_iac_56;
    return (ld_ret_24);
    }

    void ExternalParametersCheck() {
    if (Slippage > 10) {
    Comment("... Задано слишком высокое значение проскальзывания Slippage,",
    "\n", "... Скорректируйте чтобы было не более 10п и перезапустите эксперт.");
    return;
    }
    if (Warp > 100 || Warp < -100) {
    Comment("... Неправильно задан параметр искажения Warp,",
    "\n", "... Диапазон допустимых значений от -100 до +100 с шагом 1,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Deviation > 2.0 || Warp < 0) {
    Comment("... Неправильно задан параметр девиации Deviation,",
    "\n", "... Диапазон допустимых значений от 0 до +2 с шагом 0.01,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Amplitude > 200 || Amplitude < 0) {
    Comment("... Неправильно задан параметр девиации Amplitude,",
    "\n", "... Диапазон допустимых значений от 0 до +200 с шагом 1,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    if (Distortion > 1.0 || Distortion < -1.0) {
    Comment("... Неправильно задан параметр девиации Distortion,",
    "\n", "... Диапазон допустимых значений от -1 до +1 с шагом 0.01,",
    "\n", "... Скорректируйте и перезапустите эксперт.");
    return;
    }
    }

    void CheckConditions() {
    if (IsConnected() == FALSE) {
    Comment(" ... ОТСУТСТВУЕТ связь с торговым сервером\n" + " ... Приём торговых команд ОСТАНОВЛЕН");
    return;
    }
    if (IsTradeContextBusy() == TRUE) Comment(" ... Торговый поток ЗАНЯТ\n" + " ... Торговая команда на сервер не отослана");
    }

    int OrderSendReliable(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, int a_slippage_28, double a_price_32, double a_price_40, string a_comment_48, int a_magic_56, int a_datetime_60 = 0, color a_color_64 = -1) {
    double ld_96;
    if (!IsConnected()) {
    Print("OrderSendReliable: error: IsConnected() == false");
    return (-1);
    }
    if (IsStopped()) {
    Print("OrderSendReliable: error: IsStopped() == true");
    return (-1);
    }
    for (int l_count_68 = 0; !IsTradeAllowed() && l_count_68 < gi_152; l_count_68++) OrderReliable_SleepRandomTime(gd_156, gd_164);
    if (!IsTradeAllowed()) {
    Print("OrderSendReliable: error: no operation possible because IsTradeAllowed()==false, even after retries.");
    return (-1);
    }
    int li_72 = MarketInfo(a_symbol_0, MODE_DIGITS);
    if (li_72 > 0) {
    a_price_20 = NormalizeDouble(a_price_20, li_72);
    a_price_32 = NormalizeDouble(a_price_32, li_72);
    a_price_40 = NormalizeDouble(a_price_40, li_72);
    }
    if (a_price_32 != 0.0) OrderReliable_EnsureValidStop(a_symbol_0, a_price_20, a_price_32);
    int l_error_76 = GetLastError();
    l_error_76 = 0;
    bool li_80 = FALSE;
    bool li_84 = FALSE;
    int l_ticket_88 = -1;
    if (a_cmd_8 == OP_BUYSTOP || a_cmd_8 == OP_SELLSTOP) {
    l_count_68 = 0;
    while (!li_80) {
    if (IsTradeAllowed()) {
    l_ticket_88 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, a_slippage_28, a_price_32, a_price_40, a_comment_48, a_magic_56, a_datetime_60, a_color_64);
    l_error_76 = GetLastError();
    } else l_count_68++;
    switch (l_error_76) {
    case 0/* NO_ERROR */:
    li_80 = TRUE;
    break;
    case 4/* SERVER_BUSY */:
    case 6/* NO_CONNECTION */:
    case 129/* INVALID_PRICE */:
    case 136/* OFF_QUOTES */:
    case 137/* BROKER_BUSY */:
    case 146/* TRADE_CONTEXT_BUSY */:
    l_count_68++;
    break;
    case 135/* PRICE_CHANGED */:
    case 138/* REQUOTE */:
    RefreshRates();
    continue;
    break;
    case 130/* INVALID_STOPS */:
    ld_96 = MarketInfo(a_symbol_0, MODE_STOPLEVEL) * MarketInfo(a_symbol_0, MODE_POINT);
    if (a_cmd_8 == OP_BUYSTOP) {
    if (MathAbs(Ask - a_price_20) <= ld_96) li_84 = TRUE;
    } else {
    if (a_cmd_8 == OP_SELLSTOP)
    if (MathAbs(Bid - a_price_20) <= ld_96) li_84 = TRUE;
    }
    li_80 = TRUE;
    break;
    default:
    li_80 = TRUE;
    }
    if (l_count_68 > gi_152) li_80 = TRUE;
    if (li_80) {
    if (l_error_76 != 0/* NO_ERROR */) Print("OrderSendReliable: non-retryable error: " + ErrorDescription(l_error_76));
    if (l_count_68 > gi_152) Print("OrderSendReliable: retry attempts maxed at " + gi_152);
    }
    if (!li_80) {
    Print("OrderSendReliable: retryable error (" + l_count_68 + "/" + gi_152 + "): " + ErrorDescription(l_error_76));
    OrderReliable_SleepRandomTime(gd_156, gd_164);
    RefreshRates();
    }
    }
    if (l_error_76 == 0/* NO_ERROR */) {
    Print("OrderSendReliable: apparently successful OP_BUYSTOP or OP_SELLSTOP order placed, details follow.");
    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);
    OrderPrint();
    return (l_ticket_88);
    }
    if (!li_84) {
    Print("OrderSendReliable: failed to execute OP_BUYSTOP/OP_SELLSTOP, after " + l_count_68 + " retries");
    Print("OrderSendReliable: failed trade: " + OrderReliable_CommandString(a_cmd_8) + " " + a_symbol_0 + "@" + a_price_20 + " tp@" + a_price_40 + " sl@" + a_price_32);
    Print("OrderSendReliable: last error: " + ErrorDescription(l_error_76));
    return (-1);
    }
    }
    if (li_84) {
    Print("OrderSendReliable: going from limit order to market order because market is too close.");
    if (a_cmd_8 == OP_BUYSTOP) {
    a_cmd_8 = 0;
    a_price_20 = Ask;
    } else {
    if (a_cmd_8 == OP_SELLSTOP) {
    a_cmd_8 = 1;
    a_price_20 = Bid;
    }
    }
    }
    l_error_76 = GetLastError();
    l_error_76 = 0;
    l_ticket_88 = -1;
    if (a_cmd_8 == OP_BUY || a_cmd_8 == OP_SELL) {
    l_count_68 = 0;
    while (!li_80) {
    if (IsTradeAllowed()) {
    l_ticket_88 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, a_slippage_28, a_price_32, a_price_40, a_comment_48, a_magic_56, a_datetime_60, a_color_64);
    l_error_76 = GetLastError();
    } else l_count_68++;
    switch (l_error_76) {
    case 0/* NO_ERROR */:
    li_80 = TRUE;
    break;
    case 4/* SERVER_BUSY */:
    case 6/* NO_CONNECTION */:
    case 129/* INVALID_PRICE */:
    case 136/* OFF_QUOTES */:
    case 137/* BROKER_BUSY */:
    case 146/* TRADE_CONTEXT_BUSY */:
    l_count_68++;
    break;
    case 135/* PRICE_CHANGED */:
    case 138/* REQUOTE */:
    RefreshRates();
    continue;
    default:
    li_80 = TRUE;
    }
    if (l_count_68 > gi_152) li_80 = TRUE;
    if (!li_80) {
    Print("OrderSendReliable: retryable error (" + l_count_68 + "/" + gi_152 + "): " + ErrorDescription(l_error_76));
    OrderReliable_SleepRandomTime(gd_156, gd_164);
    RefreshRates();
    }
    if (li_80) {
    if (l_error_76 != 0/* NO_ERROR */) Print("OrderSendReliable: non-retryable error: " + ErrorDescription(l_error_76));
    if (l_count_68 > gi_152) Print("OrderSendReliable: retry attempts maxed at " + gi_152);
    }
    }
    if (l_error_76 == 0/* NO_ERROR */) {
    Print("OrderSendReliable: apparently successful OP_BUY or OP_SELL order placed, details follow.");
    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);
    OrderPrint();
    return (l_ticket_88);
    }
    Print("OrderSendReliable: failed to execute OP_BUY/OP_SELL, after " + l_count_68 + " retries");
    Print("OrderSendReliable: failed trade: " + OrderReliable_CommandString(a_cmd_8) + " " + a_symbol_0 + "@" + a_price_20 + " tp@" + a_price_40 + " sl@" + a_price_32);
    Print("OrderSendReliable: last error: " + ErrorDescription(l_error_76));
    return (-1);
    }
    return (0);
    }

     
  4. finger

    finger Alex

    Вы *. EX4 файл можно конвертировать в *. mql4

    это незаконно.
    ты плохой мальчик.
     
  5. Herkules

    Herkules Новичок

    что не законно ?? хороший мальчик...
     
  6. finger

    finger Alex

    -----------------------------------------------------------------------
    Функция возвращает Сдвиг от GMT Timzone брокер Server
    -----------------------------------------------------------------------
    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->#import "Kernel32.dll"
    &nbsp;&nbsp; void GetLocalTime(int& gLti[]);
    &nbsp;&nbsp; void GetSystemTime(int& gSt[]);
    &nbsp;&nbsp; int GetTimeZoneInformation(int& gtzI[]);


    //returns Offset from GMT Timzone(Broker Server)
    int GMTOffset() {
    &nbsp;&nbsp; int time_a[4];
    &nbsp;&nbsp; int time_b[43];
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetSystemTime(time_a);
    &nbsp;&nbsp; int time0 = time_a[0] & 65535;
    &nbsp;&nbsp; int time1 = time_a[0] >> 16;
    &nbsp;&nbsp; int time2 = time_a[1] >> 16;
    &nbsp;&nbsp; int time3 = time_a[2] & 65535;
    &nbsp;&nbsp; int time4 = time_a[2] >> 16;
    &nbsp;&nbsp; int time5 = time_a[3] & 65535;
    &nbsp;&nbsp; string fuse1 = FormatDateTime(time0, time1, time2, time4, time4, time5);
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetLocalTime(time_a);
    &nbsp;&nbsp; time0 = time_a[0] & 65535;
    &nbsp;&nbsp; time1 = time_a[0] >> 16;
    &nbsp;&nbsp; time2 = time_a[1] >> 16;
    &nbsp;&nbsp; time3 = time_a[2] & 65535;
    &nbsp;&nbsp; time4 = time_a[2] >> 16;
    &nbsp;&nbsp; time5 = time_a[3] & 65535;
    &nbsp;&nbsp; int time6 = time_a[3] >> 16;
    &nbsp;&nbsp; string fuse_sub = time6 + 1000;
    &nbsp;&nbsp; fuse_sub = StringSubstr(fuse_sub, 1);
    &nbsp;&nbsp; fuse1 = FormatDateTime(time0, time1, time2, time3, time4, time5);
    &nbsp;&nbsp; int t1 = 0;
    &nbsp;&nbsp; int gtt1 = GetTimeZoneInformation(time_b);
    &nbsp;&nbsp; if (gtt1 != 0) t1 = time_b[0];
    &nbsp;&nbsp; if (gtt1 == 2) t1 += time_b[42];
    &nbsp;&nbsp; int timex2 = StrToTime(fuse1);
    &nbsp;&nbsp; int tisu = TimeCurrent() - (timex2 + 60 * t1);
    &nbsp;&nbsp; double trmr = MathRound(tisu / 360);
    &nbsp;&nbsp; int tzoff = MathRound(trmr / 10.0);
    &nbsp;&nbsp; return (tzoff);
    }

    //format standart
    string FormatDateTime(int time0, int time1, int time2, int time3, int time4, int time5) {
    &nbsp;&nbsp; string sub1 = time1 + 100; sub1 = StringSubstr(sub1, 1);
    &nbsp;&nbsp; string sub2 = time2 + 100; sub2 = StringSubstr(sub2, 1);
    &nbsp;&nbsp; string sub3 = time3 + 100; sub3 = StringSubstr(sub3, 1);
    &nbsp;&nbsp; string sub4 = time4 + 100; sub4 = StringSubstr(sub4, 1);
    &nbsp;&nbsp; string sub5 = time5 + 100; sub5 = StringSubstr(sub5, 1);
    &nbsp;&nbsp; return (StringConcatenate(time0, ".", sub1, ".", sub2, " ", sub3, ":", sub4, ":", sub5));
    }<!--c2--></div><!--ec2-->



    -----------------
    Beispiel Script
    -----------------
    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->// FinGeR 11.02.2009

    #include <WinUser32.mqh>

    #import "Kernel32.dll"
    &nbsp;&nbsp; void GetLocalTime(int& gLti[]);
    &nbsp;&nbsp; void GetSystemTime(int& gSt[]);
    &nbsp;&nbsp; int GetTimeZoneInformation(int& gtzI[]);
    &nbsp;&nbsp;&nbsp;&nbsp;

    void start() {

    if(IsDllsAllowed()==false)
    &nbsp;&nbsp;&nbsp;&nbsp;{
    &nbsp;&nbsp;&nbsp;&nbsp; Alert("DLL call is not allowed. Script cannot run.");
    &nbsp;&nbsp;&nbsp;&nbsp; return(0);//arbeitet nur wenn DLL erlaubt sind ansonsten Stop hier
    &nbsp;&nbsp;&nbsp;&nbsp;}

    &nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;MessageBox("timezone offset from "+AccountCompany()+"= GMT("+vsign(GMTOffset())+")","Information ", MB_OK);

    }

    string vsign(int x){if(x+50>50)return("+"+x);return(x);}//mit Vorzeichen?

    //returns Offset from GMT Timzone(Broker Server)
    int GMTOffset() {
    &nbsp;&nbsp; int time_a[4];
    &nbsp;&nbsp; int time_b[43];
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetSystemTime(time_a);
    &nbsp;&nbsp; int time0 = time_a[0] & 65535;
    &nbsp;&nbsp; int time1 = time_a[0] >> 16;
    &nbsp;&nbsp; int time2 = time_a[1] >> 16;
    &nbsp;&nbsp; int time3 = time_a[2] & 65535;
    &nbsp;&nbsp; int time4 = time_a[2] >> 16;
    &nbsp;&nbsp; int time5 = time_a[3] & 65535;
    &nbsp;&nbsp; string fuse1 = FormatDateTime(time0, time1, time2, time4, time4, time5);
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetLocalTime(time_a);
    &nbsp;&nbsp; time0 = time_a[0] & 65535;
    &nbsp;&nbsp; time1 = time_a[0] >> 16;
    &nbsp;&nbsp; time2 = time_a[1] >> 16;
    &nbsp;&nbsp; time3 = time_a[2] & 65535;
    &nbsp;&nbsp; time4 = time_a[2] >> 16;
    &nbsp;&nbsp; time5 = time_a[3] & 65535;
    &nbsp;&nbsp; int time6 = time_a[3] >> 16;
    &nbsp;&nbsp; string fuse_sub = time6 + 1000;
    &nbsp;&nbsp; fuse_sub = StringSubstr(fuse_sub, 1);
    &nbsp;&nbsp; fuse1 = FormatDateTime(time0, time1, time2, time3, time4, time5);
    &nbsp;&nbsp; int t1 = 0;
    &nbsp;&nbsp; int gtt1 = GetTimeZoneInformation(time_b);
    &nbsp;&nbsp; if (gtt1 != 0) t1 = time_b[0];
    &nbsp;&nbsp; if (gtt1 == 2) t1 += time_b[42];
    &nbsp;&nbsp; int timex2 = StrToTime(fuse1);
    &nbsp;&nbsp; int tisu = TimeCurrent() - (timex2 + 60 * t1);
    &nbsp;&nbsp; double trmr = MathRound(tisu / 360);
    &nbsp;&nbsp; int tzoff = MathRound(trmr / 10.0);
    &nbsp;&nbsp; return (tzoff);
    }

    //format standart
    string FormatDateTime(int time0, int time1, int time2, int time3, int time4, int time5) {
    &nbsp;&nbsp; string sub1 = time1 + 100; sub1 = StringSubstr(sub1, 1);
    &nbsp;&nbsp; string sub2 = time2 + 100; sub2 = StringSubstr(sub2, 1);
    &nbsp;&nbsp; string sub3 = time3 + 100; sub3 = StringSubstr(sub3, 1);
    &nbsp;&nbsp; string sub4 = time4 + 100; sub4 = StringSubstr(sub4, 1);
    &nbsp;&nbsp; string sub5 = time5 + 100; sub5 = StringSubstr(sub5, 1);
    &nbsp;&nbsp; return (StringConcatenate(time0, ".", sub1, ".", sub2, " ", sub3, ":", sub4, ":", sub5));
    }<!--c2--></div><!--ec2-->
     

    Вложения:

  7. finger

    finger Alex

    ----------------------------------------------------------------------------------------
    Функция возвращает смещение от GMT Timzone локальном компьютере
    ---------------------------------------------------------------------------------------
    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->#import "Kernel32.dll"
    &nbsp;&nbsp; void GetLocalTime(int& gLti[]);
    &nbsp;&nbsp; void GetSystemTime(int& gSt[]);
    &nbsp;&nbsp; int GetTimeZoneInformation(int& gtzI[]);

    //return Timzone GMT offset from Local PC
    int LocalGMTOffset() {
    &nbsp;&nbsp; int time_a[4];
    &nbsp;&nbsp; int time_b[43];
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetSystemTime(time_a);
    &nbsp;&nbsp; int time0 = time_a[0] & 65535;
    &nbsp;&nbsp; int time1 = time_a[0] >> 16;
    &nbsp;&nbsp; int time2 = time_a[1] >> 16;
    &nbsp;&nbsp; int time3 = time_a[2] & 65535;
    &nbsp;&nbsp; int time4 = time_a[2] >> 16;
    &nbsp;&nbsp; int time5 = time_a[3] & 65535;
    &nbsp;&nbsp; string fuse1 = FormatDateTime(time0, time1, time2, time4, time4, time5);
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetLocalTime(time_a);
    &nbsp;&nbsp; time0 = time_a[0] & 65535;
    &nbsp;&nbsp; time1 = time_a[0] >> 16;
    &nbsp;&nbsp; time2 = time_a[1] >> 16;
    &nbsp;&nbsp; time3 = time_a[2] & 65535;
    &nbsp;&nbsp; time4 = time_a[2] >> 16;
    &nbsp;&nbsp; time5 = time_a[3] & 65535;
    &nbsp;&nbsp; int time6 = time_a[3] >> 16;
    &nbsp;&nbsp; string fuse_sub = time6 + 1000;
    &nbsp;&nbsp; fuse_sub = StringSubstr(fuse_sub, 1);
    &nbsp;&nbsp; fuse1 = FormatDateTime(time0, time1, time2, time3, time4, time5);
    &nbsp;&nbsp; int t1 = 0;
    &nbsp;&nbsp; int gtt1 = GetTimeZoneInformation(time_b);
    &nbsp;&nbsp; if (gtt1 != 0) t1 = time_b[0];
    &nbsp;&nbsp; if (gtt1 == 2) t1 += time_b[42];
    &nbsp;&nbsp; int timex2 = StrToTime(fuse1);
    &nbsp;&nbsp; int tisu = TimeLocal() - (timex2 + 60 * t1);
    &nbsp;&nbsp; double trmr = MathRound(tisu / 360);
    &nbsp;&nbsp; int tzoff = MathRound(trmr / 10.0);
    &nbsp;&nbsp; return (tzoff);
    }

    //format standart
    string FormatDateTime(int time0, int time1, int time2, int time3, int time4, int time5) {
    &nbsp;&nbsp; string sub1 = time1 + 100; sub1 = StringSubstr(sub1, 1);
    &nbsp;&nbsp; string sub2 = time2 + 100; sub2 = StringSubstr(sub2, 1);
    &nbsp;&nbsp; string sub3 = time3 + 100; sub3 = StringSubstr(sub3, 1);
    &nbsp;&nbsp; string sub4 = time4 + 100; sub4 = StringSubstr(sub4, 1);
    &nbsp;&nbsp; string sub5 = time5 + 100; sub5 = StringSubstr(sub5, 1);
    &nbsp;&nbsp; return (StringConcatenate(time0, ".", sub1, ".", sub2, " ", sub3, ":", sub4, ":", sub5));
    }<!--c2--></div><!--ec2-->


    ----------------
    Beispiel Script
    ----------------
    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->// FinGeR 11.02.2009

    #include <WinUser32.mqh>

    #import "Kernel32.dll"
    &nbsp;&nbsp; void GetLocalTime(int& gLti[]);
    &nbsp;&nbsp; void GetSystemTime(int& gSt[]);
    &nbsp;&nbsp; int GetTimeZoneInformation(int& gtzI[]);
    &nbsp;&nbsp;&nbsp;&nbsp;

    void start() {

    if(IsDllsAllowed()==false)
    &nbsp;&nbsp;&nbsp;&nbsp;{
    &nbsp;&nbsp;&nbsp;&nbsp; Alert("DLL call is not allowed. Script cannot run.");
    &nbsp;&nbsp;&nbsp;&nbsp; return(0);//arbeitet nur wenn DLL erlaubt sind ansonsten Stop hier
    &nbsp;&nbsp;&nbsp;&nbsp;}

    MessageBox("timezone offset from Local PC = GMT("+vsign(LocalGMTOffset())+")","Information ", MB_OK);

    }
    string vsign(int x){if(x+50>50)return("+"+x);return(x);}//mit Vorzeichen?


    //return Timzone GMT offset from Local PC
    int LocalGMTOffset() {
    &nbsp;&nbsp; int time_a[4];
    &nbsp;&nbsp; int time_b[43];
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetSystemTime(time_a);
    &nbsp;&nbsp; int time0 = time_a[0] & 65535;
    &nbsp;&nbsp; int time1 = time_a[0] >> 16;
    &nbsp;&nbsp; int time2 = time_a[1] >> 16;
    &nbsp;&nbsp; int time3 = time_a[2] & 65535;
    &nbsp;&nbsp; int time4 = time_a[2] >> 16;
    &nbsp;&nbsp; int time5 = time_a[3] & 65535;
    &nbsp;&nbsp; string fuse1 = FormatDateTime(time0, time1, time2, time4, time4, time5);
    &nbsp;&nbsp;
    &nbsp;&nbsp; GetLocalTime(time_a);
    &nbsp;&nbsp; time0 = time_a[0] & 65535;
    &nbsp;&nbsp; time1 = time_a[0] >> 16;
    &nbsp;&nbsp; time2 = time_a[1] >> 16;
    &nbsp;&nbsp; time3 = time_a[2] & 65535;
    &nbsp;&nbsp; time4 = time_a[2] >> 16;
    &nbsp;&nbsp; time5 = time_a[3] & 65535;
    &nbsp;&nbsp; int time6 = time_a[3] >> 16;
    &nbsp;&nbsp; string fuse_sub = time6 + 1000;
    &nbsp;&nbsp; fuse_sub = StringSubstr(fuse_sub, 1);
    &nbsp;&nbsp; fuse1 = FormatDateTime(time0, time1, time2, time3, time4, time5);
    &nbsp;&nbsp; int t1 = 0;
    &nbsp;&nbsp; int gtt1 = GetTimeZoneInformation(time_b);
    &nbsp;&nbsp; if (gtt1 != 0) t1 = time_b[0];
    &nbsp;&nbsp; if (gtt1 == 2) t1 += time_b[42];
    &nbsp;&nbsp; int timex2 = StrToTime(fuse1);
    &nbsp;&nbsp; int tisu = TimeLocal() - (timex2 + 60 * t1);
    &nbsp;&nbsp; double trmr = MathRound(tisu / 360);
    &nbsp;&nbsp; int tzoff = MathRound(trmr / 10.0);
    &nbsp;&nbsp; return (tzoff);
    }

    //format standart
    string FormatDateTime(int time0, int time1, int time2, int time3, int time4, int time5) {
    &nbsp;&nbsp; string sub1 = time1 + 100; sub1 = StringSubstr(sub1, 1);
    &nbsp;&nbsp; string sub2 = time2 + 100; sub2 = StringSubstr(sub2, 1);
    &nbsp;&nbsp; string sub3 = time3 + 100; sub3 = StringSubstr(sub3, 1);
    &nbsp;&nbsp; string sub4 = time4 + 100; sub4 = StringSubstr(sub4, 1);
    &nbsp;&nbsp; string sub5 = time5 + 100; sub5 = StringSubstr(sub5, 1);
    &nbsp;&nbsp; return (StringConcatenate(time0, ".", sub1, ".", sub2, " ", sub3, ":", sub4, ":", sub5));
    }<!--c2--></div><!--ec2-->


    ^drink
     

    Вложения:

  8. WiseMan

    WiseMan Новичок

    Помогите пожалуйста с кодом советника
    а. Высчитывает какой ордер сработал на профит (SELL или BUY). Тайм аут 15 секунд.
    б. Если BUY (например 1,3000 профит 1,3050), открывается новый BUY_LIMIT (1,3000 профит 1,3150)
    в. Если SELL (например 1,3100 профит 1,3050), открывается новый SELL_LIMIT (1,3100 профит 1,3050)
     
  9. Ice

    Ice Профи форума

    Я не эксперт в MQL4 но видел подобные советники. На форуме ссылки <a href="http://www.onix-trade.net/forum/index.php?showtopic=84389&setlanguage=1&langid=ru" target="_blank">тут</a> и <a href="http://www.onix-trade.net/forum/index.php?showtopic=84389&setlanguage=1&langid=ru" target="_blank">тут</a> можно в каком - нибудь из них подсмотреть идею.
     
  10. finger

    finger Alex

    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->Годы 2006, 2007, 2008, 2009...
    _______ _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _____&nbsp;&nbsp;_&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_&nbsp;&nbsp;&nbsp;&nbsp;_____&nbsp;&nbsp;
    |__&nbsp;&nbsp; __| |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;__ \(_)&nbsp;&nbsp;&nbsp;&nbsp;| |&nbsp;&nbsp;|&nbsp;&nbsp;__ \
    &nbsp;&nbsp; | |&nbsp;&nbsp;| |__&nbsp;&nbsp; __ _ _ __ | | _____&nbsp;&nbsp; | |__) |_&nbsp;&nbsp;___| | _| |&nbsp;&nbsp;| |
    &nbsp;&nbsp; | |&nbsp;&nbsp;| '_ \ / _` | '_ \| |/ / __|&nbsp;&nbsp;|&nbsp;&nbsp;_&nbsp;&nbsp;/| |/ __| |/ / |&nbsp;&nbsp;| |
    &nbsp;&nbsp; | |&nbsp;&nbsp;| | | | (_| | | | |&nbsp;&nbsp; <\__ \&nbsp;&nbsp;| | \ \| | (__|&nbsp;&nbsp; <| |__| |
    &nbsp;&nbsp; |_|&nbsp;&nbsp;|_| |_|\__,_|_| |_|_|\_\___/&nbsp;&nbsp;|_|&nbsp;&nbsp;\_\_|\___|_|\_\_____/<!--c2--></div><!--ec2-->

    Нур ТЗА так
    <i>У меня есть много вещей, вы узнали в MQL4 программирование</i>
    Спасибо RickD ^friends^ ^drink
     
  11. troll999

    troll999 Бегущий автостопом

    ^help^ просьба тут неожиданно образовалась в виде вопроса...
    может кто в курсе - есть ли скрипт, дающий сигнал (только сигнал) при достижении ценой заданного уровня (линия или горизонтальная, или трендовая)?

    о том, что бы мне хотелось (почти в идеале), мысли такие:
    - есть N-ное количество пар
    - ТФ M5-Н4 - хоть все, хоть нет
    - все пары загоняются на один шаблон
    - в угол экрана размещается таблица скромных размеров - пара / ТФ
    - ручками выставляются интересующие уровни по всем парам и ТФ (1-2 линии на график)
    - цена дошла - гудит гудок, в таблице мелькает ТФ "сработавшего" графика - жму на него - график во всей красе перед глазами - его "лампочка"гаснет...

    образец
    AUD USD M5 <b><!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro-->M15<!--colorc--></span><!--/colorc--></b> M30 H1 H4
    EUR JPY M5 M15 M30 H1 H4
    EUR USD <b><!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro-->M5<!--colorc--></span><!--/colorc--></b> M15 M30 H1 H4
    GBP USD M5 M15 M30 H1 H4
    NZD USD <!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro--><b>M5</b><!--colorc--></span><!--/colorc--> M15 M30 <b><!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro-->H1<!--colorc--></span><!--/colorc--></b> H4
    USD CAD M5 M15 M30 H1 H4
    USD CHF M5 M15 M30 H1 H4
    USD JPY M5 <!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro--><b>M15 </b><!--colorc--></span><!--/colorc-->M30 H1 H4

    сюда еще есть что добавить, но, возможно, мои желания превышают чьи-либо возможности :by: ;)
     
  12. finger

    finger Alex

    Возможно, это поможет Вам
    <span class='inv'><![CDATA[<noindex>]]></span><a href="http://www.onix-trade.net/forum/go.php?http://codebase.mql4.com/1024" rel="nofollow" target="_blank">http://codebase.mql4.com/1024</a><span class='inv'><![CDATA[</noindex>]]></span>

    --
     
  13. troll999

    troll999 Бегущий автостопом

    спасибо... попробую... что там и как...
     
  14. Binom

    Binom Новичок

    День добрый.
    Может у каво-то есть уже готовая функция, а если и нет, то хотя бы подскажите как реализовать..

    Требуется функция, возвращающая значение цены, на фибоначи значениях: 161.8, 261.8, 423,6

    пример функции:

    предположим что на графике в мета трейдере мы используем линии Фибоначи.
    выставляем их по ценам: цена1 , цена2
    Нулевая линия фибоначи устанавливается на цена1.
    Линия Фибоначи 100, устанавливается по цена2.

    Фибоначи линия 161.8 нам укажит цену которая нам требуется.

    Функция видится примерно такой:

    fib = getFib(цена1, цена2, 161.8);

    Если есть что то подобное буду рад посмотреть.
    Мне главное понять как расчитать все это.
    Заранее спасибо :)

    --------------
    Все оказалось проще пареной репы(задачка 3го класса) :)


    <!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->double getFibo(double price1, double price2, double num ){

    &nbsp;&nbsp; double fib;
    &nbsp;&nbsp; if ( price1 > price2){
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fib = price1 - ( price1 - price2 )*num/100;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp; }else{
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fib = price1 + ( price2 - price1 )*num/100;
    &nbsp;&nbsp; }

    &nbsp;&nbsp; return (fib);

    }<!--c2--></div><!--ec2-->
     
  15. AndBar

    AndBar Новичок

    Zdravstvyjte . Podskagute pojgalysta est lu vozmognost vuklyuchat expert na grafuke uz evo ge sobstvennogo koda. Ulu ge skudat ego s grafuka.
    Zaranne blagodaren. U pru vozmognostu eslu est prumer.
     
  16. RickD

    RickD MQL4 developer

    Можно попробовать послать чарту из эксперта сообщение WM_CLOSE.
    Чарт вместе с экспертом закроется.

    А можно просто добавить в эксперт условие выключаться и не торговать при заданном условии.
     
  17. Talex

    Talex Техник

    Пошлите сообщение PostMessageA(hwindow,WM_COMMAND,33020,0); и выключится кнопочка Советники в терминале. Ни один эксперт не будет торговать.
     
  18. RickD

    RickD MQL4 developer

    Убить всех - тоже хороший метод. :)
     
  19. AndBar

    AndBar Новичок

    Bolshoe spasubo za pomoshch
     
  20. Talex

    Talex Техник

    Кстати, совсем забыл. Можно просто удалить эксперта с графика.
    Вот так:
    void start() {
    int hwnd=WindowHandle (Symbol(), Period());
    //----------------------
    PostMessageA (hwnd,WM_COMMAND,33050,0);
    return;
    }
     

Поделиться этой страницей