Results 1 to 8 of 8
 0 Attachment(s)    

Thread: Maximum Orders

  1. #1
    Member
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    227

    Default Maximum Orders

    Hi funyoo,

    do you have a module to add "maxOrder"?
    So that I can determine, how much trade concurrently per pair are allowed.
    Best regards and thanks for your efforts!!!!!

    j_l
    Last edited by j_l; 03-27-2009 at 12:56.

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by j_l View Post
    Hi funyoo,

    do you have a module to add "maxOrder"?
    So that I can determine, how much trade concurrently per pair are allowed.
    Best regards and thanks for your efforts!!!!!

    j_l
    Hi j_l,

    Add :

    After the other functions :

    Code:
    //|---------count orders
    
    int CountOrders(int Type,int Magic)
    {
       int _CountOrd;
       _CountOrd=0;
       for(int i=0;i<OrdersTotal();i++)
       {
          OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
          if(OrderSymbol()==Symbol())
          {
             if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CountOrd++;
          }
       }
       return(_CountOrd);
    }
    Before the ordersend functions :

    Code:
    if((CountOrders(OP_BUY,Magic)+CountOrders(OP_SELL,Magic))<MaxOrders)
       {
    After the ordersend functions :

    Code:
    }
    In the extern parameters :

    Code:
    extern int MaxOrders=100;//|---------------------maximum orders allowed

  3. #3
    Member
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    227

    Default

    Thank You So Much

  4. #4
    Junior Member
    Join Date
    Mar 2009
    Posts
    15

    Default Multiple orders at a time

    So is this the code I would use to have more than one order opened by a single ea? If not, can you point me to the right spot on the forum or explain to me here how I can get my ea to open up to 5 orders at a time. Not at the same time, but to continue looking for trading opportunities when a trade is already opened.

    Thanks

    Shawn

  5. #5
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by snkpool View Post
    So is this the code I would use to have more than one order opened by a single ea?
    Hi snkpool,

    That's correct.

  6. #6
    Junior Member
    Join Date
    Mar 2009
    Posts
    15

    Default

    I am getting several variable undefined errors with type, magic, count_ord, and total.

    I copied and pasted as is. Am I doing something wrong?

  7. #7
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by snkpool View Post
    I am getting several variable undefined errors with type, magic, count_ord, and total.

    I copied and pasted as is. Am I doing something wrong?
    Hi snkpool,

    Without the entire code, it's hard to know.

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    3

    Thumbs up need maxorder function

    Quote Originally Posted by funyoo View Post
    Hi j_l,

    Add :

    After the other functions :

    Code:
    //|---------count orders
    
    int CountOrders(int Type,int Magic)
    {
       int _CountOrd;
       _CountOrd=0;
       for(int i=0;i<OrdersTotal();i++)
       {
          OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
          if(OrderSymbol()==Symbol())
          {
             if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CountOrd++;
          }
       }
       return(_CountOrd);
    }
    Before the ordersend functions :

    Code:
    if((CountOrders(OP_BUY,Magic)+CountOrders(OP_SELL,Magic))<MaxOrders)
       {
    After the ordersend functions :

    Code:
    }
    In the extern parameters :

    Code:
    extern int MaxOrders=100;//|---------------------maximum orders allowed


    Hi Funyoo

    Help me please to modified this ea
    How do I add maxorders function to this EA ? I have tried but doesnt work

    Regards


    /*
    Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
    Website: Purebeam: Professional software for Forex
    E-mail : purebeam@gmail.com
    */
    #property copyright "Dominic R. Millan"
    #property link "www.fxirobot.com"

    #include <stdlib.mqh>

    string gs_76 = "";
    string gs_84 = "333333333";
    string gs_64530_92 = "64530";
    string gs_100 = "2088203881";
    string gs_24934_108 = "24934";
    string gs_228220_116 = "228220";
    string gs_217232_124 = "217232";
    string gs_2370_132 = "2370";
    string gs_140 = "999349080";
    string gs_1006170_148 = "1006170";
    string gs_156 = "2088212912";
    string gs_164 = "2088227181";
    string gs_172 = "2088142569";
    string gs_180 = "2088142572";
    string gs_188 = "999344002";
    string gs_196 = "999344004";
    string gs_204 = "500403909";
    string gs_8824_212 = "8824";
    string gs_8824_220 = "8824";
    string gs_8824_228 = "8824";
    string gs_8824_236 = "8824";
    string gs_8824_244 = "8824";
    string gs_252 = "";
    extern string orderComment = "";
    extern double Order_Size = 0.1;
    extern int Order_Count = 1;
    extern int Satefy_Margin = 0;
    extern int Exit_Gap = 2;
    extern bool closeOrderWhenSamePrice = TRUE;
    extern double trailingStopLoss = 2.0;
    extern int closeOrderDelay = 0;
    extern double Risk_Management = 5.0;
    extern bool Trade_OnHalfHour = FALSE;
    extern bool pendingOrders = TRUE;
    extern bool Use_ECN = TRUE;
    extern int takeProfitPoints = 200;
    extern int Extra_StopLoss = 0;
    string gs_332 = "ManiaeslowPC0FXvv";
    double gd_340 = 1.0;
    bool gi_348 = FALSE;
    bool gi_352 = FALSE;
    double gd_356 = 10.0;
    double gd_364 = 0.0;
    bool gi_372 = FALSE;
    int gi_376 = 1;
    string g_symbol_380 = "";
    string gs_388 = "";
    double gd_396 = -1.0;
    int gi_404 = 110999;
    int gi_408 = 0;
    int gi_412 = -1;
    double gd_416;
    double gd_424;
    double gd_432 = 1.0;
    string gs_440 = "ODL MetaTrader 4\\experts\\files";

    int init() {
    double ld_8;
    int l_file_68;
    double ld_72;
    int lia_120[20];
    int lia_124[20];
    int li_unused_132;
    int li_unused_136;
    double ld_140;
    int li_148;
    string ls_152;
    string ls_160;
    double l_str2dbl_168;
    double ld_176;
    double ld_184;
    int li_192;
    int li_196;
    int li_200;
    int li_216;
    double ld_220;
    if (StringLen(gs_252) != 0 && StringFind(AccountCompany(), gs_252) == -1) {
    Print("Invalid Account Company");
    return (0);
    }
    /*
    if (StringLen(gs_76) != 0 && StringFind(AccountName(), gs_76) == -1) {
    Print("Invalid Account Name");
    return (0);
    }
    if (StringLen(gs_84) != 0 && (StringFind("" + AccountNumber(), gs_64530_92) == -1 && StringFind("" + AccountNumber(), gs_100) == -1 && StringFind("" + AccountNumber(), gs_24934_108) == -1 &&
    StringFind("" + AccountNumber(), gs_228220_116) == -1 && StringFind("" + AccountNumber(), gs_217232_124) == -1 && StringFind("" + AccountNumber(), gs_2370_132) == -1 && StringFind("" +
    AccountNumber(), gs_140) == -1 && StringFind("" + AccountNumber(), gs_1006170_148) == -1 && StringFind("" + AccountNumber(), gs_156) == -1 && StringFind("" + AccountNumber(), gs_164) == -1 &&
    StringFind("" + AccountNumber(), gs_172) == -1 && StringFind("" + AccountNumber(), gs_180) == -1 && StringFind("" + AccountNumber(), gs_188) == -1 && StringFind("" +
    AccountNumber(), gs_196) == -1 && StringFind("" + AccountNumber(), gs_204) == -1 && StringFind("" + AccountNumber(), gs_8824_212) == -1 && StringFind("" + AccountNumber(), gs_8824_220) == -1 &&
    StringFind("" + AccountNumber(), gs_8824_228) == -1 && StringFind("" + AccountNumber(), gs_8824_236) == -1 && StringFind("" + AccountNumber(), gs_8824_244) == -1)) {
    Print("Invalid Account Number");
    return (0);
    }
    */
    gd_356 = (1 - Risk_Management / 100.0) * AccountBalance();
    gi_404 = 0;
    for (int l_str_len_0 = StringLen(gs_332); l_str_len_0 > 0; l_str_len_0--) gi_404 += StringGetChar(gs_332, l_str_len_0);
    gs_388 = StringSubstr(Symbol(), 6, StringLen(Symbol()) - 6);
    g_symbol_380 = Symbol();
    Print("started: currencyPair=" + g_symbol_380);
    int li_4 = TimeLocal();
    li_4 -= 18000;
    double l_stoplevel_16 = MarketInfo(g_symbol_380, MODE_STOPLEVEL);
    gd_396 = l_stoplevel_16 + Extra_StopLoss;
    double l_point_24 = MarketInfo(g_symbol_380, MODE_POINT);
    double ld_32 = (Satefy_Margin + 2.0 * ld_8) * l_point_24;
    string ls_40 = "";
    string ls_48 = "";
    ls_40 = "";
    ls_40 = "" + TimeYear(li_4);
    ls_40 = ls_40 + "-" + TimeMonth(li_4);
    ls_40 = ls_40 + "-" + TimeDay(li_4);
    ls_48 = ls_40;
    string l_name_56 = gs_440 + "\\" + "log_mania_server_expert_" + StringSubstr(g_symbol_380, 0, 6) + "_" + ls_40 + ".csv";
    int li_64 = -1;
    gd_416 = MarketInfo(Symbol(), MODE_ASK);
    gd_424 = MarketInfo(Symbol(), MODE_BID);
    double ld_80 = gd_424 + (gd_416 - gd_424) / 2.0;
    double ld_88 = -1;
    int li_96 = -1;
    double ld_100 = -1;
    int li_108 = 0;
    string ls_unused_112 = "";
    bool li_128 = FALSE;
    if (MarketInfo(Symbol(), MODE_POINT) < 0.00009) li_128 = TRUE;
    while (true) {
    if (gd_416 != MarketInfo(Symbol(), MODE_ASK) + gd_364 * l_point_24) {
    gd_416 = MarketInfo(Symbol(), MODE_ASK) + gd_364 * l_point_24;
    gd_424 = MarketInfo(Symbol(), MODE_BID) + gd_364 * l_point_24;
    gi_408++;
    }
    li_4 = TimeLocal();
    li_4 -= 18000;
    ls_40 = "";
    ls_40 = "" + TimeYear(li_4);
    ls_40 = ls_40 + "-" + TimeMonth(li_4);
    ls_40 = ls_40 + "-" + TimeDay(li_4);
    if (ls_48 != ls_40) li_64 = -1;
    ls_48 = ls_40;
    l_name_56 = gs_440 + "\\" + "log_mania_server_expert_" + StringSubstr(g_symbol_380, 0, 6) + "_" + ls_40 + ".csv";
    ld_8 = MathRound((MarketInfo(g_symbol_380, MODE_ASK) - MarketInfo(g_symbol_380, MODE_BID)) / l_point_24);
    li_unused_132 = MathRound((MarketInfo(g_symbol_380, MODE_ASK) - MarketInfo(g_symbol_380, MODE_BID)) / l_point_24);
    li_unused_136 = MarketInfo(g_symbol_380, MODE_SPREAD);
    ld_32 = (Satefy_Margin + 2.0 * ld_8) * l_point_24;
    ld_140 = gi_376 * l_point_24;
    l_file_68 = FileOpen(l_name_56, FILE_CSV|FILE_READ);
    if (l_file_68 == -1) {
    Sleep(10);
    continue;
    }
    if (li_64 != FileSize(l_file_68) || gi_408 != gi_412) {
    if (li_64 != FileSize(l_file_68)) {
    li_148 = FileSize(l_file_68);
    if (li_64 != -1) {
    gi_412 = gi_408;
    ld_72 = gd_424 + (gd_416 - gd_424) / 2.0;
    if (li_128) ld_72 = 10.0 * MathRound(ld_72 / l_point_24 / 10.0) * l_point_24;
    FileSeek(l_file_68, li_64, SEEK_SET);
    ls_152 = FileReadString(l_file_68, li_148 - li_64);
    ls_160 = FileReadString(l_file_68, li_148 - li_64);
    l_str2dbl_168 = StrToDouble(ls_160);
    if (l_str2dbl_168 == 0.0) {
    Print("no price");
    FileClose(l_file_68);
    continue;
    }
    }
    ld_176 = MathAbs(ld_72 - l_str2dbl_168);
    ld_184 = MathAbs(ld_80 - ld_72);
    li_192 = (ld_72 - l_str2dbl_168) / l_point_24;
    if (li_128) li_192 = MathRound(li_192 / 10);
    li_192 += 10;
    li_196 = ld_8;
    lia_124[li_196]++;
    if (li_192 < ArraySize(lia_120) && li_192 >= 0) lia_120[li_192]++;
    li_200 = 0;
    for (int l_index_204 = 0; l_index_204 < ArraySize(lia_120); l_index_204++)
    if (lia_120[l_index_204] > lia_120[li_200]) li_200 = l_index_204;
    Print("Market Analysis in Progress");
    if (gi_352 == TRUE) {
    Print("l=" + ((l_str2dbl_168 - ld_72)) + ", m=" + l_str2dbl_168 + ", s=" + ld_72 + ", mil=" + ld_32 + ", mol=" + ((li_200 - 10)) + ", cml=" + lia_120[li_200] + ", lp=" +
    ((li_192 - 10)) + ", ed=" + li_128 + ",cl:," + gd_364);
    }
    if (ld_176 > ld_140 || gd_432 > ld_140) {
    log(",masterPrice:," + l_str2dbl_168 + ",slaveMarketPrice:," + ld_72 + ",lag:," + ((ld_72 - l_str2dbl_168)) + ",slaveJump:," + ld_184 + ",spread:," + ld_8 + ",comment:," +
    orderComment + ",cl:," + gd_364);
    }
    gd_432 = ld_176;
    if (li_192 - ArraySize(lia_120) / 2 > 9 || li_192 - ArraySize(lia_120) / 2 < -9) {
    gi_372 = FALSE;
    gd_364 = 0;
    for (int l_index_208 = 0; l_index_208 < ArraySize(lia_120); l_index_208++) lia_120[l_index_208] = 0;
    }
    if ((lia_120[li_200] > 10 && gi_372 == FALSE) || lia_120[li_200] > 20) {
    gd_364 -= li_200 - 10;
    gi_372 = TRUE;
    for (int l_index_212 = 0; l_index_212 < ArraySize(lia_120); l_index_212++) lia_120[l_index_212] = 0;
    }
    if (ld_176 >= ld_32 && ld_184 == 0.0 && ld_88 == -1.0 && gi_372 && isOnHalfHour() == 1 || Trade_OnHalfHour == FALSE) {
    log(",PlaceOrder:," + l_str2dbl_168 + ",slaveMarketPrice:," + ld_72 + ",lag:," + ((ld_72 - l_str2dbl_168)) + ",slave market ask:," + MarketInfo(Symbol(), MODE_ASK) +
    ",slave market bid:," + MarketInfo(Symbol(), MODE_BID) + ",comment:," + orderComment);
    if (gi_352 == TRUE) Print(",PlaceOrder:," + l_str2dbl_168 + ",slaveMarketPrice:," + ld_72 + ",lag:," + ((ld_72 - l_str2dbl_168)) + ",O" + ",comment:," + orderComment);
    ld_100 = gd_416;
    ld_72 = gd_424 + (gd_416 - gd_424) / 2.0;
    li_108 = 0;
    while (l_str2dbl_168 > ld_72 && ld_176 > ld_32 && li_108 < 1) {
    log(",,,spreadNow=" + MarketInfo(g_symbol_380, MODE_SPREAD) + ",spreadWas=" + ld_8 + ",askPrice=" + gd_416 + ",lagSizeOffsetPoints=" + gd_364 + ",stopsLevel=" + MarketInfo(g_symbol_380, MODE_STOPLEVEL) +
    ",point=" + l_point_24);
    if (pendingOrders) {
    ld_100 = gd_416 - gd_364 * l_point_24 + (l_stoplevel_16 + ld_8) * l_point_24;
    li_216 = 4;
    ld_220 = ld_100 - (gd_396 + ld_8) * l_point_24;
    } else {
    ld_100 = gd_416 - gd_364 * l_point_24;
    li_216 = 0;
    ld_220 = ld_100 - gd_396 * l_point_24;
    }
    if (gi_348) Order_Size = getMaxOrder_Size(li_216);
    li_108 = sendOrder(g_symbol_380, li_216, Order_Size, ld_100, ld_220, ld_100 + takeProfitPoints * l_point_24, li_108);
    if (li_108 == 0) {
    for (int li_228 = 1; li_228 < Order_Count; li_228++) sendOrder(g_symbol_380, li_216, Order_Size, ld_100, ld_220, ld_100 + takeProfitPoints * l_point_24, li_108);
    ld_88 = ld_100;
    li_96 = li_216;
    break;
    }
    ld_72 = gd_424 + (gd_416 - gd_424) / 2.0;
    ld_176 = MathAbs(ld_72 - l_str2dbl_168);
    }
    ld_100 = gd_424;
    ld_72 = gd_424 + (gd_416 - gd_424) / 2.0;
    li_108 = 0;
    while (l_str2dbl_168 < ld_72 && ld_176 > ld_32 && li_108 < 1) {
    log(",,,,spreadNow=" + MarketInfo(g_symbol_380, MODE_SPREAD) + ",spreadWas=" + ld_8 + ",bidPrice=" + gd_424 + ",lagSizeOffsetPoints=" + gd_364 + ",stopsLevel=" + l_stoplevel_16 +
    ",point=" + l_point_24);
    if (pendingOrders) {
    ld_100 = gd_424 - gd_364 * l_point_24 - (l_stoplevel_16 + ld_8) * l_point_24;
    li_216 = 5;
    ld_220 = ld_100 + (gd_396 + ld_8) * l_point_24;
    } else {
    ld_100 = gd_424 - gd_364 * l_point_24;
    li_216 = 1;
    ld_220 = ld_100 + gd_396 * l_point_24;
    }
    if (gi_348) Order_Size = getMaxOrder_Size(li_216);
    li_108 = sendOrder(g_symbol_380, li_216, Order_Size, ld_100, ld_220, ld_100 - takeProfitPoints * l_point_24, li_108);
    if (li_108 == 0) {
    for (int li_232 = 1; li_232 < Order_Count; li_232++) sendOrder(g_symbol_380, li_216, Order_Size, ld_100, ld_220, ld_100 - takeProfitPoints * l_point_24, li_108);
    ld_88 = ld_100;
    li_96 = li_216;
    break;
    }
    ld_72 = gd_424 + (gd_416 - gd_424) / 2.0;
    ld_176 = MathAbs(ld_72 - l_str2dbl_168);
    }
    if (ld_88 != -1.0) Print("Placed: orderOpenPrice=" + ld_88);
    }
    if (ld_88 != -1.0) {
    if ((l_str2dbl_168 - ld_72 <= l_point_24 * Exit_Gap && li_96 == 0 || li_96 == 4) || (ld_72 - l_str2dbl_168 <= l_point_24 * Exit_Gap && li_96 == 1 || li_96 == 5) ||
    (ld_88 - ld_72 > l_point_24 * trailingStopLoss && li_96 == 0 || li_96 == 4) || (ld_72 - ld_88 > l_point_24 * trailingStopLoss && li_96 == 1 || li_96 == 5)) {
    log(",CloseOrderRequest:," + l_str2dbl_168 + ",slaveMarketPrice:," + ld_72 + ",lag:," + ((ld_72 - l_str2dbl_168)) + ",comment:," + orderComment);
    Sleep(1000 * closeOrderDelay);
    if (closeOrderWhenSamePrice) {
    for (int li_236 = 600; li_236 != 0; li_236--) {
    if (closeOpenOrdersAndPending(g_symbol_380, encript(gi_404)) == 1) break;
    Sleep(100);
    }
    }
    ld_88 = -1;
    }
    }
    updateTrailingStop(g_symbol_380, encript(gi_404), gd_396);
    if (ld_72 != ld_80) ld_80 = ld_72;
    }
    li_64 = li_148;
    }
    FileClose(l_file_68);
    Sleep(100);
    }
    return /*(WARN)*/;
    }

    int deinit() {
    return (0);
    }

    int start() {
    return (0);
    }

    int encript(int ai_0) {
    for (int l_str_len_4 = StringLen(gs_332); l_str_len_4 > 0; l_str_len_4--) ai_0 += StringGetChar(gs_332, l_str_len_4);
    return (ai_0);
    }

    int closeOpenOrdersAndPending(string as_0, int a_magic_8) {
    int li_12;
    int l_cmd_20;
    double l_price_32;
    int l_error_40;
    bool li_ret_16 = TRUE;
    int l_ord_total_24 = OrdersTotal();
    for (int l_pos_28 = l_ord_total_24 - 1; l_pos_28 >= 0; l_pos_28--) {
    if (OrderSelect(l_pos_28, SELECT_BY_POS, MODE_TRADES)) {
    l_cmd_20 = OrderType();
    if (l_cmd_20 == OP_BUY || l_cmd_20 == OP_SELL) {
    OrderPrint();
    if (OrderMagicNumber() == a_magic_8 && StringFind(OrderSymbol(), as_0, 0) != -1) {
    while (true) {
    if (OrderType() == OP_BUY) l_price_32 = MarketInfo(as_0, MODE_BID);
    else l_price_32 = MarketInfo(as_0, MODE_ASK);
    li_12 = OrderClose(OrderTicket(), OrderLots(), l_price_32, 3, CLR_NONE);
    if (li_12 != 1) {
    l_error_40 = GetLastError();
    Print("Error = ", ErrorDescription(l_error_40), " code=", l_error_40);
    log("Close error," + l_error_40 + ",price=," + l_price_32 + ",currencyPair=," + as_0);
    li_ret_16 = FALSE;
    } else l_error_40 = 0;
    if (l_error_40 != 135/* PRICE_CHANGED */) break;
    RefreshRates();
    }
    }
    }
    if (l_cmd_20 != OP_BUY && l_cmd_20 != OP_SELL) {
    OrderPrint();
    li_12 = OrderDelete(OrderTicket());
    if (li_12 != 1) Print("LastError = ", GetLastError());
    }
    } else {
    Print("Error when order select ", GetLastError());
    break;
    }
    }
    return (li_ret_16);
    }

    int sendOrder(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, double a_price_28, double a_price_36, int ai_44) {
    int l_error_60;
    if (AccountBalance() < gd_356) return (ai_44 + 10);
    double l_point_48 = MarketInfo(a_symbol_0, MODE_POINT);
    int l_slippage_64 = 0;
    double l_price_68 = a_price_28;
    double l_price_76 = a_price_36;
    if (Use_ECN) a_price_28 = 0;
    if (Use_ECN) a_price_36 = 0;
    int l_ticket_56 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, l_slippage_64, a_price_28, a_price_36, orderComment, encript(gi_404), 0, Green);
    log("send order" + ",currencyPair=" + a_symbol_0 + ",command=" + getOrderTypeName(a_cmd_8) + ",Order_Size=" + a_lots_12 + ",currencyPrice=" + a_price_20 + ",stopLoss=" +
    a_price_28 + ",takeProfit=" + 0 + ",magicNumber=" + gi_404 + ",comment:," + orderComment + ",ticket:," + l_ticket_56);
    if (l_ticket_56 <= 0) {
    l_error_60 = GetLastError();
    log("Error:send order" + ",error code=" + l_error_60);
    Print(" --**-- send order error :", ErrorDescription(l_error_60), " code=", l_error_60);
    return (ai_44 + 1);
    }
    if (Use_ECN) addStopLossTakeProfit(l_ticket_56, l_price_68, l_price_76);
    return (0);
    }

    string getOrderTypeName(int ai_0) {
    string ls_ret_4 = "?" + ai_0 + "?";
    switch (ai_0) {
    case 0:
    ls_ret_4 = "OP_BUY";
    break;
    case 4:
    ls_ret_4 = "OP_BUYSTOP";
    break;
    case 1:
    ls_ret_4 = "OP_SELL";
    break;
    case 5:
    ls_ret_4 = "OP_SELLSTOP";
    }
    return (ls_ret_4);
    }

    void addStopLossTakeProfit(int a_ticket_0, double a_price_4, double a_price_12) {
    OrderSelect(a_ticket_0, SELECT_BY_TICKET);
    bool l_bool_20 = FALSE;
    for (int l_count_24 = 0; l_count_24 < 15 && l_bool_20 == FALSE; l_count_24++) {
    l_bool_20 = OrderModify(OrderTicket(), OrderOpenPrice(), a_price_4, a_price_12, 0, Blue);
    if (l_bool_20 == FALSE) Sleep(200);
    }
    }

    double getFreeMarginInBaseCurrency() {
    double l_free_magrin_0 = AccountFreeMargin();
    return (convertToBaseCurrency(l_free_magrin_0));
    }

    double convertToBaseCurrency(double ad_0) {
    string ls_8 = StringSubstr(g_symbol_380, 3, 3);
    if (StringFind(AccountCurrency(), ls_8, 0) == -1) {
    if (MarketInfo(ls_8 + AccountCurrency() + gs_388, MODE_ASK) != 0.0) ad_0 /= MarketInfo(ls_8 + AccountCurrency() + gs_388, MODE_ASK);
    else ad_0 /= 1 / MarketInfo(AccountCurrency() + ls_8 + gs_388, MODE_ASK);
    }
    return (ad_0);
    }

    bool isFixedMaxOrder_Size() {
    if (MarketInfo("AUDUSD" + gs_388, MODE_MARGINREQUIRED) == MarketInfo("USDJPY" + gs_388, MODE_MARGINREQUIRED) && MarketInfo("AUDUSD" + gs_388, MODE_MARGINREQUIRED) == MarketInfo("EURUSD" +
    gs_388, MODE_MARGINREQUIRED)) return (TRUE);
    return (FALSE);
    }

    double getMaxOrder_Size(int ai_0) {
    double ld_16;
    int l_stoplevel_4 = MarketInfo(g_symbol_380, MODE_STOPLEVEL);
    double l_point_8 = MarketInfo(g_symbol_380, MODE_POINT);
    if (ai_0 == 4) ld_16 = MarketInfo(g_symbol_380, MODE_ASK) + l_stoplevel_4 * l_point_8;
    if (ai_0 == 5) ld_16 = MarketInfo(g_symbol_380, MODE_BID) - l_stoplevel_4 * l_point_8;
    if (ai_0 == 0) ld_16 = MarketInfo(g_symbol_380, MODE_ASK);
    if (ai_0 == 1) ld_16 = MarketInfo(g_symbol_380, MODE_BID);
    double ld_24 = getFreeMarginInBaseCurrency();
    int l_leverage_32 = AccountLeverage();
    int li_36 = 1 / MarketInfo(g_symbol_380, MODE_LOTSTEP);
    int li_40 = 100000;
    if (isFixedMaxOrder_Size()) {
    ld_16 = convertToBaseCurrency(MarketInfo(g_symbol_380, MODE_MARGINREQUIRED));
    l_leverage_32 = 100;
    li_40 = 100;
    }
    double ld_ret_44 = MathFloor(gd_340 * li_36 * (ld_24 / ld_16 / (li_40 / 100) * (l_leverage_32 / 100))) / li_36;
    return (ld_ret_44);
    }

    void updateTrailingStop(string as_0, int a_magic_8, double a_pips_12) {
    int l_cmd_28;
    double l_price_32;
    double l_point_44;
    bool l_bool_52;
    int l_ord_total_20 = OrdersTotal();
    for (int l_pos_24 = l_ord_total_20 - 1; l_pos_24 >= 0; l_pos_24--) {
    if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES)) {
    l_cmd_28 = OrderType();
    if (l_cmd_28 == OP_BUY || l_cmd_28 == OP_SELL) {
    if (OrderMagicNumber() == a_magic_8 || a_magic_8 == 0 && StringFind(OrderSymbol(), as_0, 0) != -1) {
    l_point_44 = MarketInfo(as_0, MODE_POINT);
    if (OrderType() == OP_BUY) l_price_32 = MarketInfo(as_0, MODE_BID);
    else l_price_32 = MarketInfo(as_0, MODE_ASK);
    log("TS eval: OrderStopLoss=" + OrderStopLoss() + " stopLossOffset=" + (a_pips_12 * l_point_44) + " price=" + l_price_32 + " OP_BUY =" + ((l_cmd_28 == OP_BUY)));
    if (OrderStopLoss() < l_price_32 - l_point_44 * a_pips_12 - 0.000001 && l_cmd_28 == OP_BUY) {
    log("TS update: --- OrderStopLoss=" + OrderStopLoss() + " stopLossOffset=" + (a_pips_12 * l_point_44) + " price=" + l_price_32 + " OrderOpenPrice=" + OrderOpenPrice() +
    " OP_BUY =" + ((l_cmd_28 == OP_BUY)));
    l_bool_52 = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_32 - l_point_44 * a_pips_12, OrderTakeProfit(), 0, Blue);
    if (l_bool_52 != TRUE) log("Failed TS update!!! error=" + GetLastError());
    }
    if (OrderStopLoss() == 0.0 || OrderStopLoss() > l_price_32 + l_point_44 * a_pips_12 + 0.000001 && l_cmd_28 == OP_SELL) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_32 + l_point_44 * a_pips_12, OrderTakeProfit(), 0, Blue);
    }
    }
    }
    }
    }

    void log(string as_0) {
    int li_12 = TimeLocal();
    li_12 -= 18000;
    string ls_16 = "";
    ls_16 = "" + TimeYear(li_12);
    ls_16 = ls_16 + "-" + TimeMonth(li_12);
    ls_16 = ls_16 + "-" + TimeDay(li_12);
    int l_file_8 = FileOpen("log_mania_slave_expert_" + ls_16 + ".csv", FILE_CSV|FILE_WRITE|FILE_READ, ';');
    if (l_file_8 > 0) {
    FileSeek(l_file_8, 0, SEEK_END);
    FileWrite(l_file_8, ls_16 + " " + TimeHour(li_12) + ":" + TimeMinute(li_12) + ":" + TimeSeconds(li_12), as_0);
    FileClose(l_file_8);
    }
    }

    int isOnHalfHour() {
    int l_datetime_0 = TimeCurrent();
    if (TimeMinute(l_datetime_0) == 0 || TimeMinute(l_datetime_0) == 30) return (1);
    return (0);
    }

Similar Threads

  1. RSI Power Maximum v2
    By fxtester in forum Expert advisors live statements
    Replies: 7
    Last Post: 04-19-2010, 23:11
  2. RSI Power Maximum v2
    By funyoo in forum Expert advisors backtesting
    Replies: 6
    Last Post: 01-22-2010, 14:58
  3. RSI Power Maximum v2
    By funyoo in forum Expert advisors live statements
    Replies: 1
    Last Post: 12-16-2009, 18:21
  4. RSI Power Maximum
    By funyoo in forum Expert advisors live statements
    Replies: 3
    Last Post: 03-03-2009, 22:25

Tags for this Thread

100, add, analysis, decompiler, ecn, eurusd, ex4, ex4-to-mq4, experts, forex, funyoo, index, magic, maxorder, metatrader, mq4, sells, server, slippage, spread, thank you, time, trading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •