Jump to content

ref0rmer

Members
  • Posts

    36
  • Joined

  • Last visited

Posts posted by ref0rmer

  1. multiplier indi

    ------------------------

     

    #property indicator_chart_window

    #property indicator_buffers 2

    #property indicator_color1 Blue

    #property indicator_color2 Red

     

    double gd_76 = 2.0;

    double g_ibuf_84[];

    double gd_88;

    double g_ibuf_96[];

    double gd_100;

     

    int init() {

    SetIndexBuffer(0, g_ibuf_84);

    SetIndexBuffer(1, g_ibuf_96);

    SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);

    SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);

    return (0);

    }

     

    int start() {

    string ls_0 = "2011.11.02";

    int l_str2time_8 = StrToTime(ls_0);

    if (TimeCurrent() >= l_str2time_8) {

    Comment("Your indicator has been expired");

    return (0);

    }

    int li_16 = Bars - IndicatorCounted() - 1;

    for (int li_12 = li_16; li_12 >= 0; li_12--) {

    if (Close[li_12] > gd_88 && Close[li_12] > Close[li_12 + 1]) gd_88 = g_ibuf_84[li_12 + 1] + (Close[li_12] - (g_ibuf_84[li_12 + 1])) / gd_76;

    if (Close[li_12] < gd_88 && Close[li_12] < Close[li_12 + 1]) gd_88 = g_ibuf_84[li_12 + 1] + (Close[li_12] - (g_ibuf_84[li_12 + 1])) / gd_76;

    if (Close[li_12] > gd_100 && Close[li_12] < Close[li_12 + 1]) gd_100 = g_ibuf_96[li_12 + 1] + (Close[li_12] - (g_ibuf_96[li_12 + 1])) / gd_76;

    if (Close[li_12] < gd_100 && Close[li_12] > Close[li_12 + 1]) gd_100 = g_ibuf_96[li_12 + 1] + (Close[li_12] - (g_ibuf_96[li_12 + 1])) / gd_76;

    if (li_12 > Bars - 5) {

    gd_88 = Close[li_12];

    gd_100 = gd_88;

    }

    g_ibuf_84[li_12] = gd_88;

    g_ibuf_96[li_12] = gd_100;

    }

    return (0);

    }

  2. Re: Fx Profit Moutain Ea

     

    /*

    Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []

    Website: http://purebeam.biz

    E-mail : [email protected]

    */

    #property copyright "www.fxprofitmountain.net"

    #property link ""

     

    extern string Remark1 = "+++ Main Settings +++";

    extern bool ECN_Broker = FALSE;

    extern int MagicNumber = 0;

    extern bool AlertMail = FALSE;

    extern bool SignalsOnly = FALSE;

    extern bool Alerts = FALSE;

    extern bool Sound = FALSE;

    extern bool EachTickMode = FALSE;

    extern double Lots = 0.1;

    extern int Slippage = 5;

    extern bool UseStopLoss = TRUE;

    extern int StopLoss = 100;

    extern bool UseTakeProfit = FALSE;

    extern int TP = 60;

    extern bool UseTrailingStop = TRUE;

    extern int TrailingStop = 35;

    extern bool MoveStopOnce = FALSE;

    extern int MoveStopWhenPrice = 50;

    extern int MoveStopTo = 1;

    extern bool GBPJPYsettings = FALSE;

    extern int K = 5;

    extern int D = 3;

    extern int S = 3;

    int g_bars_176;

    int gi_180;

    bool gi_184 = FALSE;

    double gd_188 = 1.0;

    string gs_196;

     

    int init() {

    g_bars_176 = Bars;

    if (EachTickMode) gi_180 = 0;

    else gi_180 = 1;

    if (Digits == 3 || Digits == 5) {

    gd_188 = 10;

    if (GBPJPYsettings) {

    StopLoss = 130;

    TrailingStop = 40;

    }

    gs_196 = WindowExpertName();

    }

    return (0);

    }

     

    int deinit() {

    return (0);

    }

     

    int start() {

    int l_ticket_8;

    double l_price_12;

    double l_price_20;

    // if (10000 * Year() + 100 * Month() + Day() >= 20101101) {

    // Alert(gs_196 + " expired!");

    // return (-1);

    // }

    // if (AccountNumber() != 1305043 && 1) {

    // Alert(gs_196 + " is not licensed to work on this account number!");

    // return (-1);

    // }

    int li_0 = 0;

    if (EachTickMode && Bars != g_bars_176) gi_184 = FALSE;

    int l_ord_total_4 = OrdersTotal();

    li_0 = 0;

    double l_iac_28 = iAC(NULL, 0, gi_180 + 0);

    double ld_36 = 0;

    double l_iac_44 = iAC(NULL, 0, gi_180 + 1);

    double ld_52 = 0;

    double l_istochastic_60 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_180 + 0);

    double ld_68 = 50;

    double l_iac_76 = iAC(NULL, 0, gi_180 + 0);

    double ld_84 = 0;

    double l_iac_92 = iAC(NULL, 0, gi_180 + 1);

    double ld_100 = 0;

    double l_istochastic_108 = iStochastic(NULL, 0, K, D, S, MODE_SMA, 0, MODE_MAIN, gi_180 + 0);

    double ld_116 = 50;

    double l_iac_124 = iAC(NULL, 0, gi_180 + 0);

    double ld_132 = 0;

    double l_iac_140 = iAC(NULL, 0, gi_180 + 1);

    double ld_148 = 0;

    double l_istochastic_156 = iStochastic(NULL, 0, K, D, S, MODE_SMA, 0, MODE_MAIN, gi_180 + 0);

    double ld_164 = 50;

    double l_iac_172 = iAC(NULL, 0, gi_180 + 0);

    double ld_180 = 0;

    double l_iac_188 = iAC(NULL, 0, gi_180 + 1);

    double ld_196 = 0;

    double l_istochastic_204 = iStochastic(NULL, 0, K, D, S, MODE_SMA, 0, MODE_MAIN, gi_180 + 0);

    double ld_212 = 50;

    bool li_220 = FALSE;

    for (int l_pos_224 = 0; l_pos_224 < l_ord_total_4; l_pos_224++) {

    OrderSelect(l_pos_224, SELECT_BY_POS, MODE_TRADES);

    if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {

    li_220 = TRUE;

    if (OrderType() == OP_BUY) {

    if (l_iac_124 < ld_132 && l_iac_140 > ld_148 && l_istochastic_156 < ld_164) li_0 = 3;

    if (li_0 == 3 && (EachTickMode && !gi_184) || (!EachTickMode && Bars != g_bars_176)) {

    OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");

    if (!EachTickMode) g_bars_176 = Bars;

    li_220 = FALSE;

    } else {

    if (MoveStopOnce && MoveStopWhenPrice > 0) {

    if (Bid - OrderOpenPrice() >= Point * (gd_188 * MoveStopWhenPrice)) {

    if (OrderStopLoss() < OrderOpenPrice() + Point * (gd_188 * MoveStopTo)) {

    OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Point * (gd_188 * MoveStopTo), OrderTakeProfit(), 0, Red);

    if (!(!EachTickMode)) continue;

    g_bars_176 = Bars;

    continue;

    }

    }

    }

    if (UseTrailingStop && TrailingStop > 0) {

    if (Bid - OrderOpenPrice() > Point * (gd_188 * TrailingStop)) {

    if (OrderStopLoss() < Bid - Point * (gd_188 * TrailingStop)) {

    OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * (gd_188 * TrailingStop), OrderTakeProfit(), 0, MediumSeaGreen);

    if (!EachTickMode) g_bars_176 = Bars;

    }

    }

    }

    }

    } else {

    if (l_iac_172 > ld_180 && l_iac_188 < ld_196 && l_istochastic_204 > ld_212) li_0 = 4;

    if (li_0 == 4 && (EachTickMode && !gi_184) || (!EachTickMode && Bars != g_bars_176)) {

    OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");

    if (!EachTickMode) g_bars_176 = Bars;

    li_220 = FALSE;

    } else {

    if (MoveStopOnce && MoveStopWhenPrice > 0) {

    if (OrderOpenPrice() - Ask >= Point * (gd_188 * MoveStopWhenPrice)) {

    if (OrderStopLoss() > OrderOpenPrice() - Point * (gd_188 * MoveStopTo)) {

    OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Point * (gd_188 * MoveStopTo), OrderTakeProfit(), 0, Red);

    if (!(!EachTickMode)) continue;

    g_bars_176 = Bars;

    continue;

    }

    }

    }

    if (UseTrailingStop && TrailingStop > 0) {

    if (OrderOpenPrice() - Ask > Point * (gd_188 * TrailingStop)) {

    if (OrderStopLoss() > Ask + Point * (gd_188 * TrailingStop) || OrderStopLoss() == 0.0) {

    OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * (gd_188 * TrailingStop), OrderTakeProfit(), 0, DarkOrange);

    if (!EachTickMode) g_bars_176 = Bars;

    }

    }

    }

    }

    }

    }

    }

    if (l_iac_28 > ld_36 && l_iac_44 < ld_52 && l_istochastic_60 > ld_68) li_0 = 1;

    if (l_iac_76 < ld_84 && l_iac_92 > ld_100 && l_istochastic_108 < ld_116) li_0 = 2;

    if (li_0 == 1 && (EachTickMode && !gi_184) || (!EachTickMode && Bars != g_bars_176)) {

    if (!li_220) {

    if (AccountFreeMargin() < 1000.0 * Lots) {

    Print("We have no money. Free Margin = ", AccountFreeMargin());

    return (0);

    }

    if (UseStopLoss) l_price_12 = Ask - gd_188 * StopLoss * Point;

    else l_price_12 = 0.0;

    if (UseTakeProfit) l_price_20 = Ask + gd_188 * TP * Point;

    else l_price_20 = 0.0;

    if (ECN_Broker) {

    l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "Buy(#" + MagicNumber + ")" + Symbol() + "", MagicNumber, 0, DodgerBlue);

    if (l_ticket_8 > 0) {

    OrderSelect(l_ticket_8, SELECT_BY_TICKET);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(l_price_12, Digits), NormalizeDouble(l_price_20, Digits), 0, Red);

    }

    } else l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, l_price_12, l_price_20, "Buy(#" + MagicNumber + ")" + Symbol() + "", MagicNumber, 0, DodgerBlue);

    if (l_ticket_8 > 0) {

    if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) {

    Print("BUY order opened : ", OrderOpenPrice());

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");

    } else Print("Error opening BUY order : ", GetLastError());

    }

    if (SignalsOnly) {

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal");

    if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal");

    if (Sound) PlaySound("alert.wav");

    }

    if (!li_220 && !SignalsOnly) {

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal");

    if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal");

    if (Sound) PlaySound("alert.wav");

    if (EachTickMode) gi_184 = TRUE;

    if (!EachTickMode) g_bars_176 = Bars;

    return (0);

    }

    }

    }

    if (li_0 == 2 && (EachTickMode && !gi_184) || (!EachTickMode && Bars != g_bars_176)) {

    if (!li_220) {

    if (AccountFreeMargin() < 1000.0 * Lots) {

    Print("We have no money. Free Margin = ", AccountFreeMargin());

    return (0);

    }

    if (UseStopLoss) l_price_12 = Bid + gd_188 * StopLoss * Point;

    else l_price_12 = 0.0;

    if (UseTakeProfit) l_price_20 = Bid - gd_188 * TP * Point;

    else l_price_20 = 0.0;

    if (ECN_Broker) {

    l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "Sell(#" + MagicNumber + ")" + Symbol() + "", MagicNumber, 0, DeepPink);

    if (l_ticket_8 > 0) {

    OrderSelect(l_ticket_8, SELECT_BY_TICKET);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(l_price_12, Digits), NormalizeDouble(l_price_20, Digits), 0, Red);

    }

    } else l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, l_price_12, l_price_20, "Sell(#" + MagicNumber + ")" + Symbol() + "", MagicNumber, 0, DeepPink);

    if (l_ticket_8 > 0) {

    if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) {

    Print("SELL order opened : ", OrderOpenPrice());

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");

    } else Print("Error opening SELL order : ", GetLastError());

    }

    if (SignalsOnly) {

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal");

    if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal");

    if (Sound) PlaySound("alert.wav");

    }

    if (!li_220 && !SignalsOnly) {

    if (AlertMail) SendMail("[signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal");

    if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal");

    if (Sound) PlaySound("alert.wav");

    if (EachTickMode) gi_184 = TRUE;

    if (!EachTickMode) g_bars_176 = Bars;

    return (0);

    }

    }

    if (!EachTickMode) g_bars_176 = Bars;

    }

    return (0);

    }

    //kudos welcom

  3. Re: 2008 ATC "AME Cross Trader"

     

    /*

    Generated by EX4-TO-MQ4 decompiler V4.0.220.2 []

    Website: http://purebeam.biz

    E-mail : [email protected]

    */

    #property copyright "Copyright ?2008, AME Labs"

    #property link "http://forex.ameLabs.com"

     

    #include <amelib.mqh>

     

    extern string licenseKey;

    extern double minTradeSize = 0.1;

    extern int scaleDivisor = 500;

    extern double stopDollars = 20000.0;

    extern int shortMaBars = 66;

    extern int longMaBars = 240;

    extern int stopBars = 114;

    extern int useLimit = 1;

    extern int limitPips = 40;

    extern int useMM = 1;

    extern int aggressiveMode = 0;

    extern int slippage = 10;

    extern int panicMode = 0;

    extern double maxTotalLots = 15.0;

    double gd_unused_148 = 0.0;

    double gd_unused_156 = 1000.0;

    int gi_unused_164 = 0;

    double gd_168;

    bool gi_176 = FALSE;

    double gd_180 = 0.0;

     

    int init() {

    ame_InitLibrary(WindowExpertName());

    // gi_176 = ame_SetLicenseKey(licenseKey);

    // ame_SetSendEmail(1);

    if (stopDollars > 0.0) {

    ame_ResetTrailingStop();

    ame_BeginTrailingStop(stopDollars);

    }

    gd_168 = 0;

    // if (IsTesting()) gi_176 = TRUE;

    // else

    // if (!gi_176) MessageBox("The License Key you provided is invalid or expired. Please check it and try again.", "Invalid License Key");

    return (0);

    }

     

    int deinit() {

    Print("maxBalance=" + ame_GetValue("maxBalance"));

    Print("minTradeSize=" + ame_GetValue("minTradeSize"));

    Print("scaleDivisor=" + ame_GetValue("scaleDivisor"));

    Print("tradeSizeResetPoint=" + ame_GetValue("tradeSizeResetPoint"));

    Print("shortMaBars=" + ame_GetValue("shortMaBars"));

    Print("longMaBars=" + ame_GetValue("longMaBars"));

    Print("stopBars=" + ame_GetValue("stopBars"));

    Print("useLimit=" + ame_GetValue("useLimit"));

    Print("limitPips=" + ame_GetValue("limitPips"));

    Print("useMM=" + ame_GetValue("useMM"));

    Print("aggressiveMode=" + ame_GetValue("aggressiveMode"));

    Print("slippage=" + ame_GetValue("slippage"));

    Print("panicMode=" + ame_GetValue("panicMode"));

    ame_CloseLibrary();

    return (0);

    }

     

    int start() {

    int li_0;

    string ls_unused_4;

    /* if (!gi_176) {

    Comment("Invalid License Key. Expert Advisor is disabled.");

    return (0);

    } */

    if (IsOptimization()) {

    if (AccountBalance() > ame_GetValue("maxBalance")) {

    ame_SetValue("maxBalance", AccountBalance());

    ame_SetValue("minTradeSize", minTradeSize);

    ame_SetValue("scaleDivisor", scaleDivisor);

    ame_SetValue("stopDollars", stopDollars);

    ame_SetValue("shortMaBars", shortMaBars);

    ame_SetValue("longMaBars", longMaBars);

    ame_SetValue("stopBars", stopBars);

    ame_SetValue("useLimit", useLimit);

    ame_SetValue("limitPips", limitPips);

    ame_SetValue("useMM", useMM);

    ame_SetValue("aggressiveMode", aggressiveMode);

    ame_SetValue("slippage", slippage);

    ame_SetValue("panicMode", panicMode);

    }

    }

    if (anyOrdersOpen()) {

    if (gd_180 != 0.0) {

    li_0 = ame_FirstOrder();

    Sleep(120000);

    while (li_0 > 0) {

    ame_OrderModify(li_0, OrderOpenPrice(), gd_180, OrderTakeProfit(), OrderExpiration(), -1);

    li_0 = ame_NextOrder();

    }

    gd_180 = 0;

    } else

    if (findExitSignal()) closeAllOrders();

    return (0);

    }

    /* if (ame_CheckTrailingStop()) {

    Comment("Trading halted. Monetary trailing stop reached.");

    return (0);

    }*/

    int li_12 = findEntrySignal();

    if (li_12 == 1) placeBuyOrder();

    else

    if (li_12 == 2) placeSellOrder();

    return (0);

    }

     

    bool anyOrdersOpen() {

    return (ame_AnyOpenOrders());

    }

     

    void closeAllOrders() {

    ame_OrderCloseAll(slippage);

    }

     

    void placeBuyOrder() {

    double ld_0 = calculateTradeSize();

    double l_low_8 = Low[iLowest(Symbol(), 0, MODE_LOW, stopBars, 1)];

    int li_16 = ame_OrderSend(Symbol(), 0, ld_0, Ask, slippage, l_low_8, 0, "AME Cross Trader", ame_MagicNumber(), 0, 16711680);

    if (li_16 > 0) Sleep(60000 * Period());

    }

     

    void placeSellOrder() {

    double ld_0 = calculateTradeSize();

    double l_high_8 = High[iHighest(Symbol(), 0, MODE_HIGH, stopBars, 1)];

    int li_16 = ame_OrderSend(Symbol(), 1, ld_0, Bid, slippage, l_high_8, 0, "AME Cross Trader", ame_MagicNumber(), 0, 255);

    if (li_16 > 0) Sleep(60000 * Period());

    }

     

    bool findExitSignal() {

    double l_ticket_36;

    double l_ticket_44;

    double l_ticket_56;

    bool li_ret_0 = FALSE;

    double ld_4 = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;

    // if (ame_CheckTrailingStop()) return (TRUE);

    if (DayOfWeek() == 0) return (FALSE);

    if (!ame_FirstOrder()) return (FALSE);

    OrderSelect(ame_FirstOrder(), SELECT_BY_TICKET);

    if (Time[0] <= OrderOpenTime()) return (FALSE);

    double ld_12 = OrderStopLoss();

    double ld_20 = 0;

    double ld_28 = 0;

    if (OrderType() == OP_BUY) {

    if (ld_12 == 0.0 || ld_12 < OrderOpenPrice()) ld_12 = OrderOpenPrice();

    if (useLimit != 0 && OrderTakeProfit() == 0.0 && High[1] > OrderOpenPrice() + limitPips * Point && High[1] > Open[0]) ld_28 = High[1];

    } else {

    if (ld_12 == 0.0 || ld_12 > OrderOpenPrice()) ld_12 = OrderOpenPrice();

    if (useLimit != 0 && OrderTakeProfit() == 0.0 && Low[1] < OrderOpenPrice() - limitPips * Point && Low[1] < Open[0]) ld_28 = Low[1];

    }

    if (OrderType() == OP_BUY) {

    l_ticket_36 = Low[1];

    if (l_ticket_36 - ld_12 > ld_4) ld_20 = l_ticket_36;

    } else {

    l_ticket_44 = High[1];

    if (ld_12 - l_ticket_44 > ld_4) ld_20 = l_ticket_44;

    }

    if (ld_20 != 0.0 || ld_28 != 0.0) {

    if (ld_20 == 0.0) ld_20 = OrderStopLoss();

    if (ld_28 == 0.0) ld_28 = OrderTakeProfit();

    for (int li_52 = ame_FirstOrder(); li_52 > 0; li_52 = ame_NextOrder()) {

    ld_20 = fixStopPrice(OrderType(), ld_20, ld_28);

    if (ld_20 != 0.0) ame_OrderModify(li_52, OrderOpenPrice(), ld_20, ld_28, 0, -1);

    else return (TRUE);

    }

    OrderSelect(ame_FirstOrder(), SELECT_BY_TICKET);

    }

    if (panicMode > 0) {

    l_ticket_56 = Close[1];

    if (OrderType() == OP_BUY) {

    if (panicMode == 1) l_ticket_56 = High[1];

    if (l_ticket_56 < OrderOpenPrice()) li_ret_0 = TRUE;

    } else {

    if (panicMode == 1) l_ticket_56 = Low[1];

    if (l_ticket_56 > OrderOpenPrice()) li_ret_0 = TRUE;

    }

    }

    return (li_ret_0);

    }

     

    int findEntrySignal() {

    int li_ret_0 = 0;

    if (DayOfWeek() == 0) return (0);

    if (AccountEquity() < gd_168) return (0);

    if (!ame_IsNewBar()) return (0);

    // for (int li_4 = ame_FirstOrder(); li_4; li_4 = ame_NextOrder())

    if (iBarShift(Symbol(), 0, OrderOpenTime()) == 0) return (0);

    double l_ima_8 = iMA(Symbol(), 0, shortMaBars, 0, MODE_SMA, PRICE_MEDIAN, 1);

    double l_ima_16 = iMA(Symbol(), 0, longMaBars, 0, MODE_SMA, PRICE_MEDIAN, 1);

    if (Low[1] >= l_ima_8 && l_ima_8 >= l_ima_16) li_ret_0 = 1;

    else

    if (High[1] <= l_ima_8 && l_ima_8 <= l_ima_16) li_ret_0 = 2;

    return (li_ret_0);

    }

     

    double calculateTradeSize() {

    double ld_12;

    int li_8 = 1;

    if (useMM == 1) {

    ld_12 = calculateEquity();

    li_8 = ld_12 / scaleDivisor;

    if (li_8 < 1) li_8 = 1;

    }

    double ld_ret_0 = ame_FixLots(Symbol(), minTradeSize * li_8);

    if (ld_ret_0 > maxTotalLots) ld_ret_0 = maxTotalLots;

    return (ld_ret_0);

    }

     

    double calculateEquity() {

    double ld_ret_0 = AccountEquity();

    if (gd_168 > ld_ret_0) return (0);

    if (aggressiveMode == 0) ld_ret_0 -= gd_168;

    return (ld_ret_0);

    }

     

    double fixStopPrice(int ai_0, double ad_4, double ad_12) {

    double l_price_28;

    double ld_20 = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;

    if (ai_0 == 1) {

    l_price_28 = Ask;

    if (MathAbs(ad_4 - l_price_28) < ld_20) ad_4 = l_price_28 + ld_20;

    } else {

    l_price_28 = Bid;

    if (MathAbs(ad_4 - l_price_28) < ld_20) ad_4 = l_price_28 - ld_20;

    }

    if (MathAbs(ad_12 - l_price_28) < ld_20) ad_4 = 0;

    return (ad_4);

    }

    __________________

    try this guys

  4. Re: [req] forex autokey

     

    /*

    Generated by EX4-TO-MQ4 decompiler V4.0.223.1c []

    Website: http://purebeam.biz

    E-mail : [email protected]

    */

    #property copyright "Copyright ?2009, Accura-FX Limited"

    #property link "http://www.accura-fx.com"

     

    #include <stdlib.mqh>

     

    #import "AutoKey.dll"

    int Activate(double a0, int a1, int a2, string a3, int a4);

    bool KeyScan(int a0, int a1);

    #import "kernel32.dll"

    int GetTimeZoneInformation(int& a0[]);

    #import

     

    extern string TradeKey = "";

    extern double LotSize = 0.0;

    extern int Target = 0;

    extern int StopLoss = 0;

    extern int Slippage = 3;

    extern string TradeNote = "";

    extern int Reference = 1000;

    extern string AuthentiCode;

    int gi_124 = 10;

    double gd_128 = 4.0;

    double gd_136 = 25.0;

    string gs_144 = "V1_1_4";

    string gs_152 = "OrderReliable fname unset";

    int gi_unused_160 = 0/* NO_ERROR */;

    int gi_164 = 3;

    bool gi_168 = FALSE;

    bool gi_172 = FALSE;

    string gs_176 = " ";

    string gs_184 = "";

     

    int init() {

    int li_4 = 9 * (Digits == 3 || Digits == 5) + 1;

    gi_168 = TRUE;

    Comment(gs_176 + "Initialising...");

    if (!IsDllsAllowed()) {

    Comment(gs_176 + "*** Change MetaTrader Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Common\' tab\n" + gs_176 +

    "- \'Allow DLL imports\' must be checked\n" + gs_176 + "- \'Confirm DLL function calls\' must be unchecked");

    gi_168 = FALSE;

    return (0);

    }

    if (!IsTesting() && !IsExpertEnabled()) {

    Comment(gs_176 + "*** Change MetaTrader Options ***\n" + gs_176 + "Click the red \'Expert Advisors\' button to enable EA processing\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog then click the \'OK\' button");

    gi_168 = FALSE;

    return (0);

    }

    if (StringLen(TradeKey) != 1) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter a suitable TradeKey\n" + gs_176 + "- for example: A..Z or 0..9");

    gi_168 = FALSE;

    return (0);

    }

    if (LotSize == 0.0) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter a suitable LotSize value\n" + gs_176 + "- for example: 0.1 (fixed lots)");

    gi_168 = FALSE;

    return (0);

    }

    if (Target != 0 && Target < 10 * li_4) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter a suitable Target distance (minimum = " + DoubleToStr(10 * li_4, 0) + ")\n" + gs_176 + "- for example: 0 (no target) or " + DoubleToStr(50 * li_4, 0) + " (" + DoubleToStr(50 * li_4, 0) + " pips)");

    gi_168 = FALSE;

    return (0);

    }

    if (StopLoss != 0 && StopLoss < 10 * li_4) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter a suitable StopLoss distance (minimum = " + DoubleToStr(10 * li_4, 0) + ")\n" + gs_176 + "- for example: 0 (no stoploss) or " + DoubleToStr(50 * li_4, 0) + " (" + DoubleToStr(50 * li_4, 0) + " pips)");

    gi_168 = FALSE;

    return (0);

    }

    if (Slippage != 0 && Slippage < 1 * li_4) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter a suitable Slippage distance (minimum = " + DoubleToStr(1 * li_4, 0) + ")\n" + gs_176 + "- for example: 0 (no slippage) or " + DoubleToStr(3 * li_4, 0) + " (" + DoubleToStr(3 * li_4, 0) + " pips)");

    gi_168 = FALSE;

    return (0);

    }

    /* string ls_8 = StringTrimLeft(StringTrimRight(AuthentiCode));

    int li_0 = Activate(1.0, AccountNumber(), IsDemo(), CharToStr(StringLen(ls_8)) + ls_8, 1);

    gs_184 = "";

    if (li_0 == 1) gs_184 = " - Upgrade required";

    if (li_0 == 2) {

    Comment(gs_176 + "*** Change Expert Advisor Options ***\n" + gs_176 + "Press \'F7\' to access the Expert Advisor properties dialog and click the \'Inputs\' tab\n" +

    gs_176 + "Enter your AuthentiCode (this is the RECEIPT NUMBER of your qualifying purchase)");

    gi_168 = FALSE;

    return (0);

    }

    if (li_0 > 2) {

    gs_184 = " - Error detected";

    Comment(gs_176 + "Initialisation complete - Code: " + li_0);

    Print("Initialisation complete - Code: " + li_0);

    } else Comment(gs_176 + "Initialisation complete - Code: " + li_0);

    return (0);*/

    }

     

    int deinit() {

    return (0);

    }

     

    int start() {

    if (!gi_168) return (0);

    Comment(gs_176 + "AutoKey v" + DoubleToStr(1.0, 2) + "A" + gs_184

    + "\n"

    + gs_176 + "====================================\n" + gs_176 + "Local: " + TimeToStr(TimeLocal(), TIME_SECONDS) + " GMT: " + TimeToStr(TimeGMT(), TIME_SECONDS) + " Server: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + " (" + StrTimeZoneServer() + ")\n" + gs_176 + "====================================\n");

    if (!gi_172) {

    if (KeyScan(StringGetChar(TradeKey, 0), 1)) gi_172 = OrderSendReliable2Step(Symbol(), 0, LotSize, MarketInfo(Symbol(), MODE_ASK), Slippage, StopLoss, Target, TradeNote, Reference, 0, 32768);

    else

    if (KeyScan(StringGetChar(TradeKey, 0), -1)) gi_172 = OrderSendReliable2Step(Symbol(), 1, LotSize, MarketInfo(Symbol(), MODE_BID), Slippage, StopLoss, Target, TradeNote, Reference, 0, 255);

    } else

    if (!KeyScan(StringGetChar(TradeKey, 0), 1) && !KeyScan(StringGetChar(TradeKey, 0), -1)) gi_172 = FALSE;

    return (0);

    }

     

    double TimeZoneLocal() {

    int lia_0[43];

    switch (GetTimeZoneInformation(lia_0)) {

    case 0:

    return (lia_0[0] / (-60.0));

    case 1:

    return (lia_0[0] / (-60.0));

    case 2:

    return ((lia_0[0] + lia_0[42]) / (-60.0));

    }

    Print("Unknown return value from GetTimeZoneInformation in kernel32.dll. Returning 0");

    return (0);

    }

     

    double TimeZoneServer() {

    int li_0 = (TimeCurrent() - TimeLocal()) / 60;

    int li_4 = MathRound(li_0 / 30.0);

    li_0 = 30 * li_4;

    return (TimeZoneLocal() + li_0 / 60.0);

    }

     

    string StrTimeZoneServer() {

    string ls_ret_0;

    if (TimeZoneServer() >= 0.0) ls_ret_0 = "GMT+" + DoubleToStr(TimeZoneServer(), 0);

    else ls_ret_0 = "GMT" + DoubleToStr(TimeZoneServer(), 0);

    return (ls_ret_0);

    }

     

    int TimeGMT() {

    int li_ret_0 = TimeLocal() - 3600.0 * TimeZoneLocal();

    int li_ret_4 = TimeCurrent() - 3600.0 * TimeZoneServer();

    if (li_ret_0 > li_ret_4 + 300) return (li_ret_0);

    return (li_ret_4);

    }

     

    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;

    a_price_20 = NormalizeDouble(a_price_20, Digits);

    a_price_32 = NormalizeDouble(a_price_32, Digits);

    a_price_40 = NormalizeDouble(a_price_40, Digits);

    gs_152 = "OrderSendReliable";

    OrderReliablePrint("Attempting to open an " + OrderReliableTypeToString(a_cmd_8) + " order (Lots: " + a_lots_12 + ", Price: " + a_price_20 + ", SL: " + a_price_32 +

    ", TP: " + a_price_40 + ")");

    if (!IsConnected()) {

    OrderReliablePrint("Error: IsConnected() == false");

    gi_unused_160 = 6;

    return (-1);

    }

    if (IsStopped()) {

    OrderReliablePrint("Error: IsStopped() == True");

    gi_unused_160 = 2;

    return (-1);

    }

    for (int l_count_68 = 0; !IsTradeAllowed() && l_count_68 < gi_124; l_count_68++) OrderReliableSleepRandomTime(gd_128, gd_136);

    if (!IsTradeAllowed()) {

    if (gi_164 > 1) OrderReliablePrint("Error: No operation possible because IsTradeAllowed() == False, even after retries.");

    gi_unused_160 = 146;

    return (-1);

    }

    int l_digits_72 = MarketInfo(a_symbol_0, MODE_DIGITS);

    Print("Digits: ", Digits, " digits: ", l_digits_72);

    if (l_digits_72 > 0) {

    a_price_20 = NormalizeDouble(a_price_20, l_digits_72);

    a_price_32 = NormalizeDouble(a_price_32, l_digits_72);

    a_price_40 = NormalizeDouble(a_price_40, l_digits_72);

    }

    if (a_price_32 != 0.0) OrderReliableEnsureValidLevels(a_symbol_0, a_price_20, a_price_32, a_price_40);

    int l_error_76 = GetLastError();

    l_error_76 = 0;

    gi_unused_160 = 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 || a_cmd_8 == OP_BUYLIMIT || a_cmd_8 == OP_SELLLIMIT) {

    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();

    gi_unused_160 = l_error_76;

    } 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_124) li_80 = TRUE;

    if (li_80) {

    if (l_error_76 != 0/* NO_ERROR */) OrderReliablePrint("Non-retryable error: " + OrderReliableErrTxt(l_error_76));

    if (l_count_68 > gi_124) OrderReliablePrint("Retry attempts maxed out at " + gi_124);

    }

    if (!li_80) {

    OrderReliablePrint("Retryable error (" + l_count_68 + "/" + gi_124 + "): " + OrderReliableErrTxt(l_error_76));

    OrderReliableSleepRandomTime(gd_128, gd_136);

    RefreshRates();

    }

    }

    if (l_error_76 == 0/* NO_ERROR */) {

    OrderReliablePrint("Apparently successful OP_BUYSTOP or OP_SELLSTOP order placement - order details are:");

    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);

    OrderPrint();

    return (l_ticket_88);

    }

    if (!li_84) {

    OrderReliablePrint("Failed to execute stop or limit order after " + l_count_68 + " retries");

    OrderReliablePrint("Failed to open order: " + OrderReliableTypeToString(a_cmd_8) + " (" + a_symbol_0 + ", Price: " + a_price_20 + ", SL: " + a_price_32 + ", TP: " +

    a_price_40 + ")");

    OrderReliablePrint("Last error: " + OrderReliableErrTxt(l_error_76));

    return (-1);

    }

    }

    if (li_84) {

    OrderReliablePrint("Switching from a limit order to a market order because market price is too close.");

    if (a_cmd_8 == OP_BUYSTOP || a_cmd_8 == OP_BUYLIMIT) {

    a_cmd_8 = 0;

    a_price_20 = Ask;

    } else {

    if (a_cmd_8 == OP_SELLSTOP || a_cmd_8 == OP_SELLLIMIT) {

    a_cmd_8 = 1;

    a_price_20 = Bid;

    }

    }

    }

    l_error_76 = GetLastError();

    l_error_76 = 0;

    gi_unused_160 = 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();

    gi_unused_160 = l_error_76;

    } 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;

    default:

    li_80 = TRUE;

    }

    if (l_count_68 > gi_124) li_80 = TRUE;

    if (!li_80) {

    OrderReliablePrint("Retryable error (" + l_count_68 + "/" + gi_124 + "): " + OrderReliableErrTxt(l_error_76));

    OrderReliableSleepRandomTime(gd_128, gd_136);

    RefreshRates();

    }

    if (li_80) {

    if (l_error_76 != 0/* NO_ERROR */) OrderReliablePrint("Non-retryable error: " + OrderReliableErrTxt(l_error_76));

    if (l_count_68 > gi_124) OrderReliablePrint("Retry attempts maxed out at " + gi_124);

    }

    }

    if (l_error_76 == 0/* NO_ERROR */) {

    OrderReliablePrint("Apparently successful OP_BUY or OP_SELL order placement - order details are:");

    OrderSelect(l_ticket_88, SELECT_BY_TICKET, MODE_TRADES);

    OrderPrint();

    return (l_ticket_88);

    }

    OrderReliablePrint("Failed to execute OP_BUY/OP_SELL, after " + l_count_68 + " retries");

    OrderReliablePrint("Failed to open order: " + OrderReliableTypeToString(a_cmd_8) + " (" + a_symbol_0 + ", Price: " + a_price_20 + ", SL: " + a_price_32 + ", TP: " +

    a_price_40 + ")");

    OrderReliablePrint("Last error: " + OrderReliableErrTxt(l_error_76));

    return (-1);

    }

    return (0);

    }

     

    int OrderSendReliable2Step(string as_0, int ai_8, double ad_12, double ad_20, int ai_28, double a_pips_32, double a_pips_40, string as_48, int ai_56, int ai_60 = 0, int ai_64 = -1) {

    int li_unused_72;

    gs_152 = "OrderSendReliable2Step";

    OrderReliablePrint("Attempting to open an " + OrderReliableTypeToString(ai_8) + " order (Lots: " + ad_12 + ", Price: " + ad_20 + ", SL: " + a_pips_32 + ", TP: " +

    a_pips_40 + ")");

    int l_ticket_68 = OrderSendReliable(as_0, ai_8, ad_12, ad_20, ai_28, 0, 0, as_48, ai_56, ai_60, ai_64);

    if (l_ticket_68 > 0 && a_pips_32 != 0.0 || a_pips_40 != 0.0) {

    OrderSelect(l_ticket_68, SELECT_BY_TICKET);

    li_unused_72 = 0;

    if (ai_8 == 0) OrderModifyReliable(l_ticket_68, OrderOpenPrice(), OrderOpenPrice() - a_pips_32 * Point, OrderOpenPrice() + a_pips_40 * Point, 0, ai_64);

    else OrderModifyReliable(l_ticket_68, OrderOpenPrice(), OrderOpenPrice() + a_pips_32 * Point, OrderOpenPrice() - a_pips_40 * Point, 0, ai_64);

    }

    return (l_ticket_68);

    }

     

    int OrderModifyReliable(int a_ticket_0, double a_price_4, double a_price_12, double a_price_20, int a_datetime_28, color a_color_32 = -1) {

    string ls_40;

    gs_152 = "OrderModifyReliable";

    OrderReliablePrint("Attempting to modify order - ticket #" + a_ticket_0 + " (Price: " + a_price_4 + ", SL: " + a_price_12 + ", TP: " + a_price_20 + ")");

    if (!IsConnected()) {

    OrderReliablePrint("Error: IsConnected() == False");

    gi_unused_160 = 6;

    return (0);

    }

    if (IsStopped()) {

    OrderReliablePrint("Error: IsStopped() == True");

    return (0);

    }

    for (int l_count_36 = 0; !IsTradeAllowed() && l_count_36 < gi_124; l_count_36++) OrderReliableSleepRandomTime(gd_128, gd_136);

    if (!IsTradeAllowed()) {

    if (gi_164 > 1) OrderReliablePrint("Error: No operation possible because IsTradeAllowed()==False, even after retries.");

    gi_unused_160 = 146;

    return (0);

    }

    int l_error_52 = GetLastError();

    l_error_52 = 0;

    gi_unused_160 = 0;

    bool li_56 = FALSE;

    l_count_36 = 0;

    bool l_bool_60 = FALSE;

    while (!li_56) {

    if (IsTradeAllowed()) {

    l_bool_60 = OrderModify(a_ticket_0, a_price_4, a_price_12, a_price_20, a_datetime_28, a_color_32);

    l_error_52 = GetLastError();

    gi_unused_160 = l_error_52;

    } else l_count_36++;

    if (l_bool_60 == TRUE) li_56 = TRUE;

    switch (l_error_52) {

    case 0/* NO_ERROR */:

    li_56 = TRUE;

    break;

    case 1/* NO_RESULT */:

    li_56 = 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 */:

    case 128/* TRADE_TIMEOUT */:

    l_count_36++;

    break;

    case 135/* PRICE_CHANGED */:

    case 138/* REQUOTE */:

    RefreshRates();

    continue;

    break;

    default:

    li_56 = TRUE;

    }

    if (l_count_36 > gi_124) li_56 = TRUE;

    if (!li_56) {

    OrderReliablePrint("Retryable error (" + l_count_36 + "/" + gi_124 + "): " + OrderReliableErrTxt(l_error_52));

    OrderReliableSleepRandomTime(gd_128, gd_136);

    RefreshRates();

    }

    if (li_56) {

    if (l_error_52 != 0/* NO_ERROR */ && l_error_52 != 1/* NO_RESULT */) OrderReliablePrint("Non-retryable error: " + OrderReliableErrTxt(l_error_52));

    if (l_count_36 > gi_124) OrderReliablePrint("Retry attempts maxed out at " + gi_124);

    }

    }

    if (l_bool_60 == TRUE || l_error_52 == 0/* NO_ERROR */) {

    OrderReliablePrint("Apparently successful order modification - updated order details are:");

    OrderSelect(a_ticket_0, SELECT_BY_TICKET, MODE_TRADES);

    OrderPrint();

    return (1);

    }

    if (l_error_52 == 1/* NO_RESULT */) {

    OrderReliablePrint("Server reported that order modification did not actually change any parameters");

    OrderReliablePrint("Redundant modification of ticket #" + a_ticket_0 + " (" + ls_40 + ", Price: " + a_price_4 + ", SL: " + a_price_12 + ", TP: " + a_price_20 + ")");

    return (1);

    }

    OrderReliablePrint("Failed to execute modification after " + l_count_36 + " retries");

    OrderReliablePrint("Failed to modify ticket #" + a_ticket_0 + " (" + ls_40 + ", Price: " + a_price_4 + ", SL: " + a_price_12 + ", TP: " + a_price_20 + ")");

    OrderReliablePrint("Last error: " + OrderReliableErrTxt(l_error_52));

    return (0);

    }

     

    string OrderReliableErrTxt(int ai_0) {

    return ("" + ai_0 + ":" + ErrorDescription(ai_0));

    }

     

    void OrderReliablePrint(string as_0) {

    if (!(IsTesting() || IsOptimization()))

    if (gi_164 > 0) Print(gs_152 + " " + gs_144 + ":" + as_0);

    }

     

    string OrderReliableTypeToString(int ai_0) {

    if (ai_0 == 0) return ("OP_BUY");

    if (ai_0 == 1) return ("OP_SELL");

    if (ai_0 == 4) return ("OP_BUYSTOP");

    if (ai_0 == 5) return ("OP_SELLSTOP");

    if (ai_0 == 2) return ("OP_BUYLIMIT");

    if (ai_0 == 3) return ("OP_SELLLIMIT");

    return ("(Type == " + ai_0 + ")");

    }

     

    void OrderReliableEnsureValidLevels(string a_symbol_0, double ad_8, double &ad_16, double &ad_24) {

    double ld_32;

    if (ad_8 > 0.0) {

    ad_16 = MathMax(ad_16, 0);

    ad_24 = MathMax(ad_24, 0);

    ld_32 = MarketInfo(a_symbol_0, MODE_STOPLEVEL) * MarketInfo(a_symbol_0, MODE_POINT);

    if (MathAbs(ad_8 - ad_16) <= ld_32) {

    if (ad_8 > ad_16) ad_16 = ad_8 - ld_32;

    else {

    if (ad_8 < ad_16) ad_16 = ad_8 + ld_32;

    else OrderReliablePrint("Error: Requested price == StopLoss level");

    }

    ad_16 = NormalizeDouble(ad_16, MarketInfo(a_symbol_0, MODE_DIGITS));

    }

    if (MathAbs(ad_8 - ad_24) <= ld_32) {

    if (ad_8 < ad_24) ad_24 = ad_8 + ld_32;

    else {

    if (ad_8 > ad_24) ad_24 = ad_8 - ld_32;

    else OrderReliablePrint("Error: Requested price == TakeProfit level");

    }

    ad_24 = NormalizeDouble(ad_24, MarketInfo(a_symbol_0, MODE_DIGITS));

    }

    }

    }

     

    void OrderReliableSleepRandomTime(double ad_0, double ad_8) {

    double ld_16;

    double ld_24;

    int li_32;

    if (IsTesting() == 0) {

    ld_16 = MathCeil(ad_0 / 0.1);

    if (ld_16 > 0.0) {

    li_32 = MathRound(ad_8 / 0.1);

    ld_24 = 1.0 - 1.0 / ld_16;

    Sleep(100);

    for (int l_count_36 = 0; l_count_36 < li_32; l_count_36++) {

    if (MathRand() > 32768.0 * ld_24) break;

    Sleep(100);

    }

    }

    }

    }

  5. Re: THE LONDON RUSH FOREX SYSTEM By All Russell

     

    indicator decomplied....

    #property copyright "?2008, London Forex Rush system"

    #property link "www.LondonForexRush.com"

     

    #property indicator_chart_window

    #property indicator_buffers 2

    #property indicator_color1 Aqua

    #property indicator_color2 Fuchsia

     

    extern double AccountSize = 10000.0;

    extern int TokyoStart = 0;

    extern int TokyoEnd = 8;

    extern color TokyoHighColor = Aqua;

    extern color TokyoLowColor = Fuchsia;

    extern int LondonStart = 9;

    extern int Countdown = 2;

    extern color CountdownColor = Aqua;

    extern color TextColor = Yellow;

    extern double RiskRatio = 0.03;

    int g_color_124 = LimeGreen;

    int g_color_128 = OrangeRed;

    int g_color_132 = Gray;

    int g_fontsize_136 = 30;

    string gs_arial_140 = "Arial";

    string gs_mainind1_148 = "MainInd1";

    int g_fontsize_156 = 12;

    string gs_arial_160 = "Arial";

    string g_name_168 = "Countdown1";

    int g_fontsize_176 = 10;

    string gs_arial_180 = "Arial";

    double g_ibuf_188[];

    double g_ibuf_192[];

    int gi_196 = 1;

    int gi_200 = 0;

    bool gi_204 = TRUE;

    int gi_208 = 0;

    double gd_212 = 0.0;

    double gd_220 = 0.0;

     

    void objectCreate(string a_name_0, int a_x_8, int a_y_12, string a_text_16 = "-", int a_fontsize_24 = 40, string a_fontname_28 = "Arial", color a_color_36 = -1) {

    int l_window_40 = WindowOnDropped();

    ObjectCreate(a_name_0, OBJ_LABEL, l_window_40, 0, 0);

    ObjectSet(a_name_0, OBJPROP_CORNER, 0);

    ObjectSet(a_name_0, OBJPROP_COLOR, a_color_36);

    ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8);

    ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12);

    ObjectSetText(a_name_0, a_text_16, a_fontsize_24, a_fontname_28, a_color_36);

    }

     

    int HourToTime(int ai_0, int ai_4 = 0, int ai_8 = -1) {

    int li_ret_12;

    int l_index_16 = 0;

    if (ai_0 < 0 || ai_0 > 23) return (0);

    if (ai_8 == -1) li_ret_12 = StrToTime(DoubleToStr(Year(), 0) + "." + DoubleToStr(Month(), 0) + "." + DoubleToStr(Day(), 0) + " " + DoubleToStr(ai_0, 0) + ":00");

    else {

    li_ret_12 = StrToTime(DoubleToStr(TimeYear(Time[ai_8]), 0) + "." + DoubleToStr(TimeMonth(Time[ai_8]), 0) + "." + DoubleToStr(TimeDay(Time[ai_8]), 0) + " " + DoubleToStr(ai_0, 0) +

    ":00");

    }

    if (ai_4 == -1) {

    for (l_index_16 = ai_8; l_index_16 < Bars && TimeDay(Time[ai_8]) == TimeDay(Time[l_index_16]); l_index_16++) {

    }

    li_ret_12 = StrToTime(DoubleToStr(TimeYear(Time[l_index_16]), 0) + "." + DoubleToStr(TimeMonth(Time[l_index_16]), 0) + "." + DoubleToStr(TimeDay(Time[l_index_16]), 0) +

    " " + DoubleToStr(ai_0, 0) + ":00");

    } else

    if (ai_4 == 1) li_ret_12 += 86400;

    return (li_ret_12);

    }

     

    int init() {

    SetIndexBuffer(0, g_ibuf_188);

    SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 4, TokyoHighColor);

    SetIndexBuffer(1, g_ibuf_192);

    SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 4, TokyoLowColor);

    string ls_0 = "Main Indicator";

    IndicatorShortName(ls_0);

    SetIndexLabel(0, "Tokyo High");

    SetIndexLabel(1, "Tokyo Low");

    gi_208 = LondonStart + Countdown;

    if (gi_208 > 23) gi_208 -= 24;

    return (0);

    }

     

    int deinit() {

    ObjectDelete(gs_mainind1_148);

    ObjectDelete(g_name_168);

    ObjectDelete("lmn1");

    ObjectDelete("lmn2");

    ObjectDelete("lmn3");

    ObjectDelete("lmn4");

    ObjectDelete("lmn5");

    ObjectDelete("lmn6");

    ObjectDelete("lmn7");

    return (0);

    }

     

    int start() {

    double ld_16;

    double ld_24;

    string l_dbl2str_40;

    string ls_48;

    double ld_104;

    double ld_112;

    double ld_120;

    double ld_128;

    if (TokyoStart < 0 || TokyoStart > 23) return (1);

    if (TokyoEnd < 0 || TokyoEnd > 23) return (1);

    if (LondonStart < 0 || LondonStart > 23) return (2);

    if (gi_208 < 0 || gi_208 > 23) return (2);

    if (Countdown < 0 || Countdown > 24) return (2);

    if (Bars < 50) return (3);

    double ld_0 = 0.9 * iATR(NULL, PERIOD_D1, 14, 0);

    int l_index_8 = 0;

    int l_index_12 = 0;

    int li_32 = 0;

    int li_36 = 0;

    string l_dbl2str_56 = "";

    int li_64 = 0;

    int li_68 = 0;

    int li_72 = 0;

    int li_76 = 0;

    int li_80 = 0;

    int li_84 = 0;

    int li_88 = 0;

    int li_92 = 0;

    int li_96 = 0;

    int li_100 = 0;

    double l_spread_136 = 0;

    double l_tickvalue_144 = 0;

    bool li_152 = FALSE;

    bool li_156 = FALSE;

    int l_ind_counted_160 = IndicatorCounted();

    int li_164 = Bars - l_ind_counted_160;

    double ld_168 = 0;

    if (l_ind_counted_160 > 0) li_164++;

    if (gi_204) {

    objectCreate(gs_mainind1_148, 10, 25, "", g_fontsize_136, gs_arial_140, g_color_132);

    objectCreate(g_name_168, 10, 70, "", g_fontsize_156, gs_arial_160, CountdownColor);

    objectCreate("lmn1", 10, 110, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn2", 10, 140, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn3", 10, 160, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn4", 10, 190, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn5", 10, 210, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn6", 10, 240, "-", g_fontsize_176, gs_arial_180, TextColor);

    objectCreate("lmn7", 10, 260, "-", g_fontsize_176, gs_arial_180, TextColor);

    }

    for (l_index_8 = li_164; l_index_8 >= 0; l_index_8--) {

    li_84 = HourToTime(TokyoStart, 0, l_index_8);

    if (TokyoStart > TokyoEnd) li_88 = HourToTime(TokyoEnd, 1, l_index_8);

    else li_88 = HourToTime(TokyoEnd, 0, l_index_8);

    li_96 = HourToTime(TokyoEnd, 0, l_index_8);

    if (TokyoStart > TokyoEnd) li_92 = HourToTime(TokyoStart, -1, l_index_8);

    else li_92 = HourToTime(TokyoStart, 0, l_index_8);

    li_152 = FALSE;

    if (Time[l_index_8] >= li_84 && Time[l_index_8] <= li_88) {

    li_152 = TRUE;

    li_100 = li_84;

    }

    if (Time[l_index_8] >= li_92 && Time[l_index_8] <= li_96) {

    li_152 = TRUE;

    li_100 = li_92;

    }

    if (li_152) {

    if (g_ibuf_188[l_index_8 + 1] != EMPTY_VALUE) {

    if (High[l_index_8] <= g_ibuf_188[l_index_8 + 1]) g_ibuf_188[l_index_8] = g_ibuf_188[l_index_8 + 1];

    else {

    g_ibuf_188[l_index_8] = High[l_index_8];

    for (l_index_12 = l_index_8 + 1; Time[l_index_12] >= li_100 && l_index_12 < Bars; l_index_12++) g_ibuf_188[l_index_12] = High[l_index_8];

    }

    } else g_ibuf_188[l_index_8] = High[l_index_8];

    if (g_ibuf_192[l_index_8 + 1] != EMPTY_VALUE) {

    if (Low[l_index_8] >= g_ibuf_192[l_index_8 + 1]) g_ibuf_192[l_index_8] = g_ibuf_192[l_index_8 + 1];

    else {

    g_ibuf_192[l_index_8] = Low[l_index_8];

    for (l_index_12 = l_index_8 + 1; Time[l_index_12] >= li_100 && l_index_12 < Bars; l_index_12++) g_ibuf_192[l_index_12] = Low[l_index_8];

    }

    } else g_ibuf_192[l_index_8] = Low[l_index_8];

    }

    }

    int l_count_176 = 0;

    int l_count_180 = 0;

    for (l_index_8 = 1; l_index_8 <= 20; l_index_8++) {

    if (iMA(NULL, PERIOD_H1, 10, 0, MODE_SMA, PRICE_CLOSE, l_index_8 - 1) - iMA(NULL, PERIOD_H1, 30, 0, MODE_SMA, PRICE_CLOSE, l_index_8 - 1) > 0.0) l_count_176++;

    else

    if (iMA(NULL, PERIOD_H1, 10, 0, MODE_SMA, PRICE_CLOSE, l_index_8 - 1) - iMA(NULL, PERIOD_H1, 30, 0, MODE_SMA, PRICE_CLOSE, l_index_8 - 1) < 0.0) l_count_180++;

    }

    if (l_count_176 >= 20) gi_196 = 1;

    else {

    if (l_count_180 >= 20) gi_196 = 2;

    else gi_196 = 3;

    }

    ld_168 = gd_212 - gd_220;

    if (gi_196 == 1 && ld_168 < ld_0 / 2.0) gi_200 = 1;

    else {

    if (gi_196 == 2 && ld_168 < ld_0 / 2.0) gi_200 = 2;

    else gi_200 = 3;

    }

    li_64 = HourToTime(LondonStart);

    if (LondonStart > gi_208) li_68 = HourToTime(gi_208, 1, 0);

    else li_68 = HourToTime(gi_208);

    li_76 = HourToTime(gi_208);

    if (LondonStart > gi_208) li_72 = HourToTime(LondonStart, -1, 0);

    else li_72 = HourToTime(LondonStart);

    li_156 = FALSE;

    if (TimeCurrent() >= li_64 && TimeCurrent() <= li_68) {

    li_156 = TRUE;

    li_80 = li_68;

    }

    if (TimeCurrent() >= li_72 && TimeCurrent() <= li_76) {

    li_156 = TRUE;

    li_80 = li_76;

    }

    if (li_156) {

    li_32 = MathFloor((li_80 - TimeCurrent()) / 3600);

    li_36 = MathFloor((li_80 - TimeCurrent() - 3600 * li_32) / 60) + 1.0;

    l_dbl2str_40 = DoubleToStr(li_32, 0);

    if (li_36 < 10) ls_48 = "0" + DoubleToStr(li_36, 0);

    else ls_48 = DoubleToStr(li_36, 0);

    ObjectSetText(g_name_168, "COUNTDOWN: " + l_dbl2str_40 + ":" + ls_48, g_fontsize_156, gs_arial_160, CountdownColor);

    } else {

    ObjectSetText(g_name_168, "COUNTDOWN: -", g_fontsize_156, gs_arial_160, CountdownColor);

    gi_200 = 3;

    }

    l_spread_136 = MarketInfo(Symbol(), MODE_SPREAD);

    l_tickvalue_144 = MarketInfo(Symbol(), MODE_TICKVALUE);

    if (gi_200 == 1) {

    for (l_index_12 = 0; l_index_12 < Bars && g_ibuf_188[l_index_12] == EMPTY_VALUE; l_index_12++) {

    }

    if (g_ibuf_188[l_index_12] != EMPTY_VALUE) {

    gd_212 = g_ibuf_188[l_index_12];

    gd_220 = g_ibuf_192[l_index_12];

    ld_104 = gd_212 + 5.0 * Point;

    ld_112 = gd_220 + (gd_212 - gd_220) / 2.0 - 5.0 * Point;

    ld_120 = gd_220 - 5.0 * Point;

    ObjectSetText("lmn1", "Entry: " + DoubleToStr(ld_104, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn2", "Aggressive Stop Loss: " + DoubleToStr(ld_112, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn3", "Conservative Stop Loss: " + DoubleToStr(ld_120, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ld_128 = gd_220 + ld_0;

    ObjectSetText("lmn4", "Aggressive Target: " + DoubleToStr(ld_128, Digits), g_fontsize_176, gs_arial_180, TextColor);

    l_dbl2str_56 = DoubleToStr(ld_128, Digits);

    ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, StringLen(l_dbl2str_56) - 2, 2));

    if (ld_16 >= 0.0 && ld_16 <= 15.0) ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, 0, StringLen(l_dbl2str_56) - 2) + "00") - 5.0 * Point;

    else {

    if (ld_16 >= 50.0 && ld_16 <= 65.0) ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, 0, StringLen(l_dbl2str_56) - 2) + "50") - 5.0 * Point;

    else ld_16 = ld_128;

    }

    ObjectSetText("lmn5", "Conservative Target: " + DoubleToStr(ld_16, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ld_16 = (ld_104 - ld_112) / Point + l_spread_136;

    ld_16 *= l_tickvalue_144;

    ld_16 = RiskRatio * AccountSize / ld_16;

    ld_24 = (ld_104 - ld_120) / Point + l_spread_136;

    ld_24 *= l_tickvalue_144;

    ld_24 = RiskRatio * AccountSize / ld_24;

    ObjectSetText("lmn6", "Aggressive Lot Size Multiplier: " + DoubleToStr(ld_16, 2), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn7", "Conservative Lot Size Multiplier: " + DoubleToStr(ld_24, 2), g_fontsize_176, gs_arial_180, TextColor);

    }

    } else {

    if (gi_200 == 2) {

    for (l_index_12 = 0; l_index_12 < Bars && g_ibuf_188[l_index_12] == EMPTY_VALUE; l_index_12++) {

    }

    if (g_ibuf_188[l_index_12] != EMPTY_VALUE) {

    gd_212 = g_ibuf_188[l_index_12];

    gd_220 = g_ibuf_192[l_index_12];

    ld_104 = gd_220 - 5.0 * Point;

    ld_112 = gd_220 + (gd_212 - gd_220) / 2.0 + 5.0 * Point;

    ld_120 = gd_212 + 5.0 * Point;

    ObjectSetText("lmn1", "Entry: " + DoubleToStr(ld_104, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn2", "Aggressive Stop Loss: " + DoubleToStr(ld_112, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn3", "Conservative Stop Loss: " + DoubleToStr(ld_120, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ld_128 = gd_212 - ld_0;

    ObjectSetText("lmn4", "Aggressive Target: " + DoubleToStr(ld_128, Digits), g_fontsize_176, gs_arial_180, TextColor);

    l_dbl2str_56 = DoubleToStr(ld_128, Digits);

    ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, StringLen(l_dbl2str_56) - 2, 2));

    if (ld_16 >= 85.0 && ld_16 <= 0.0) ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, 0, StringLen(l_dbl2str_56) - 2) + "00") + 5.0 * Point;

    else {

    if (ld_16 >= 35.0 && ld_16 <= 50.0) ld_16 = StrToDouble(StringSubstr(l_dbl2str_56, 0, StringLen(l_dbl2str_56) - 2) + "50") + 5.0 * Point;

    else ld_16 = ld_128;

    }

    ObjectSetText("lmn5", "Conservative Target: " + DoubleToStr(ld_16, Digits), g_fontsize_176, gs_arial_180, TextColor);

    ld_16 = (ld_112 - ld_104) / Point + l_spread_136;

    ld_16 *= l_tickvalue_144;

    ld_16 = RiskRatio * AccountSize / ld_16;

    ld_24 = (ld_120 - ld_104) / Point + l_spread_136;

    ld_24 *= l_tickvalue_144;

    ld_24 = RiskRatio * AccountSize / ld_24;

    ObjectSetText("lmn6", "Aggressive Lot Size Multiplier: " + DoubleToStr(ld_16, 2), g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn7", "Conservative Lot Size Multiplier: " + DoubleToStr(ld_24, 2), g_fontsize_176, gs_arial_180, TextColor);

    }

    } else {

    ObjectSetText("lmn1", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn2", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn3", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn4", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn5", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn6", "", g_fontsize_176, gs_arial_180, TextColor);

    ObjectSetText("lmn7", "", g_fontsize_176, gs_arial_180, TextColor);

    }

    }

    if (gi_200 == 1) ObjectSetText(gs_mainind1_148, "LONG TRADE", g_fontsize_136, gs_arial_140, g_color_124);

    else {

    if (gi_200 == 2) ObjectSetText(gs_mainind1_148, "SHORT TRADE", g_fontsize_136, gs_arial_140, g_color_128);

    else {

    if (gi_200 == 3) ObjectSetText(gs_mainind1_148, "NO TRADE", g_fontsize_136, gs_arial_140, g_color_132);

    else ObjectSetText(gs_mainind1_148, "", g_fontsize_136, gs_arial_140, g_color_124);

    }

    }

    return (0);

    }

     

    __________________________

     

    #property copyright "?2008, London Forex Rush system"

    #property link "www.LondonForexRush.com"

     

    #property indicator_separate_window

    #property indicator_minimum 0.0

    #property indicator_maximum 1.0

    #property indicator_buffers 3

    #property indicator_color1 GreenYellow

    #property indicator_color2 Tomato

    #property indicator_color3 Gray

     

    double g_ibuf_76[];

    double g_ibuf_80[];

    double g_ibuf_84[];

     

    void DrawBar(int ai_0, int ai_4) {

    if (ai_4 == 1) {

    g_ibuf_76[ai_0] = 1;

    g_ibuf_80[ai_0] = EMPTY_VALUE;

    g_ibuf_84[ai_0] = EMPTY_VALUE;

    return;

    }

    if (ai_4 == 2) {

    g_ibuf_76[ai_0] = EMPTY_VALUE;

    g_ibuf_80[ai_0] = 1;

    g_ibuf_84[ai_0] = EMPTY_VALUE;

    return;

    }

    if (ai_4 == 3) {

    g_ibuf_76[ai_0] = EMPTY_VALUE;

    g_ibuf_80[ai_0] = EMPTY_VALUE;

    g_ibuf_84[ai_0] = 1;

    return;

    }

    g_ibuf_76[ai_0] = EMPTY_VALUE;

    g_ibuf_80[ai_0] = EMPTY_VALUE;

    g_ibuf_84[ai_0] = EMPTY_VALUE;

    }

     

    int init() {

    SetIndexBuffer(0, g_ibuf_76);

    SetIndexStyle(0, DRAW_HISTOGRAM);

    SetIndexBuffer(1, g_ibuf_80);

    SetIndexStyle(1, DRAW_HISTOGRAM);

    SetIndexBuffer(2, g_ibuf_84);

    SetIndexStyle(2, DRAW_HISTOGRAM);

    string ls_0 = "Market Trend indicator";

    IndicatorShortName(ls_0);

    SetIndexLabel(0, "Green");

    SetIndexLabel(1, "Red");

    SetIndexLabel(2, "Gray");

    return (0);

    }

     

    int deinit() {

    return (0);

    }

     

    int start() {

    int li_12;

    int li_16;

    int l_ind_counted_0 = IndicatorCounted();

    if (l_ind_counted_0 < 0) return (-1);

    int li_4 = Bars - l_ind_counted_0;

    if (l_ind_counted_0 > 0) li_4++;

    int l_count_20 = 0;

    int l_count_24 = 0;

    double ld_28 = 0;

    for (int li_8 = li_4; li_8 >= 0; li_8--) {

    li_12 = li_8;

    l_count_20 = 0;

    l_count_24 = 0;

    while (li_12 < Bars && li_12 < li_8 + 20) {

    ld_28 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, li_12) - iMA(NULL, 0, 30, 0, MODE_SMA, PRICE_CLOSE, li_12);

    if (ld_28 > 0.0) l_count_20++;

    else

    if (ld_28 < 0.0) l_count_24++;

    li_12++;

    }

    if (l_count_20 >= 20) li_16 = 1;

    else {

    if (l_count_24 >= 20) li_16 = 2;

    else li_16 = 3;

    }

    DrawBar(li_8, li_16);

    }

    return (0);

    }

×
×
  • Create New...