Results 1 to 4 of 4

Thread: How to change an EA to use Partial Lots

  1. #1
    Might it be possible to alter that EA to operate with Partial Lots? My trading platform allows .1, .2, .3 and so forth. There is a Close Part of the order at X pips within this EA but you have to be trading at least two lots for the purpose to work.

    Is this something I can modify?




    // ------------------------------------------------------------------
    //| luktom visual order editor.mq4 |
    //| luktom :: #ukasz Tomaszkiewicz |
    //| http://luktom.biz/ |
    // ------------------------------------------------------------------
    #property copyright luktom :: #ukasz Tomaszkiewicz
    #property link http://luktom.biz/
    #include lt;stderror.mqhgt;
    #include lt;stdlib.mqhgt;
    extern bool use_timer=true;
    extern int default_sl_level=10;
    extern int default_tp_level=500;
    extern color sl_color=Red;
    extern int sl_style=STYLE_DASH;
    extern color tp_color=Aqua;
    extern int tp_style=STYLE_DASH;
    extern color be_color=Yellow;
    extern int be_style=STYLE_DASH;
    extern int be_offset=1;
    extern color cl_color=Purple;
    extern int cl_style=STYLE_DASH;
    extern bool use_cp=false;
    extern color cp_color=Blue;
    extern int cp_style=STYLE_DASH;
    extern int cp_level=0;
    extern int cp_closedlevel=0;
    extern double cp_lots=0;
    extern color ol_sell_color=Orange;
    extern int ol_sell_style=STYLE_DASH;
    extern color ol_buy_color=Blue;
    extern int ol_buy_style=STYLE_DASH;
    extern bool use_be=false;
    extern int default_be_level=10;
    extern bool use_cl=false;
    extern int default_cl_level=0;
    extern bool delete_on_deinit=true;
    void init()

    if(use_timer)
    timer();




    void timer()
    while(true)
    Sleep(1000);

    if(IsStopped())
    return;


    start();



    void deinit()

    if(delete_on_deinit)
    for(int I=0;ilt;ObjectsTotal();I )
    string name=ObjectName(I);

    if(StringSubstr(name,0,4)==lvoe)
    ObjectDelete(name);





    void start() {
    for(int I=0; ilt;OrdersTotal();I ) {
    if(OrderSelect(I,SELECT_BY_POS)) {
    if(OrderSymbol()==Symbol()) {
    int dgts=MarketInfo(OrderSymbol(),MODE_DIGITS);

    if(ObjectFind(lvoe_ol_ OrderTicket())==-1) else

    if(OrderStopLoss()gt;0 || default_sl_levelgt;0)
    if(ObjectFind(lvoe_sl_ OrderTicket())==-1)

    if(OrderStopLoss()==0)
    ObjectCreate(lvoe_sl_ OrderTicket(),OBJ_HLINE,0,Time[0],OrderOpenPrice()-orderDir(OrderType())*default_sl_level*Point);
    else
    ObjectCreate(lvoe_sl_ OrderTicket(),OBJ_HLINE,0,Time[0],OrderStopLoss());

    ObjectSet(lvoe_sl_ OrderTicket(),OBJPROP_COLOR,sl_color);
    ObjectSet(lvoe_sl_ OrderTicket(),OBJPROP_STYLE,sl_style);
    ObjectSetText(lvoe_sl_ OrderTicket(),# OrderTicket() stop reduction,11);

    else
    align(lvoe_sl_ OrderTicket());
    if(NormalizeDouble(OrderStopLoss(),dgts)!) =NormalizeDouble(ObjectGet(lvoe_sl_ OrderTicket(),OBJPROP_PRICE1),dgts))
    if(! OrderModify(OrderTicket(),OrderOpenPrice(),ObjectG et(lvoe_sl_ OrderTicket(),OBJPROP_PRICE1),OrderTakeProfit(),Or derExpiration(),CLR_NONE))
    //Alert(ErrorDescription(GetLastError()));

    persist;



    else
    if(ObjectFind(lvoe_sl_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_sl_ OrderTicket());



    if(OrderTakeProfit()gt;0 || default_tp_level)
    if(ObjectFind(lvoe_tp_ OrderTicket())==-1)

    if(OrderTakeProfit()==0)
    ObjectCreate(lvoe_tp_ OrderTicket(),OBJ_HLINE,0,Time[0],OrderOpenPrice() orderDir(OrderType())*default_tp_level*Point);
    else
    ObjectCreate(lvoe_tp_ OrderTicket(),OBJ_HLINE,0,Time[0],OrderTakeProfit());

    ObjectSet(lvoe_tp_ OrderTicket(),OBJPROP_COLOR,tp_color);
    ObjectSet(lvoe_tp_ OrderTicket(),OBJPROP_STYLE,tp_style);

    else
    align(lvoe_tp_ OrderTicket());
    if(NormalizeDouble(OrderTakeProfit(),4)! =NormalizeDouble(ObjectGet(lvoe_tp_ OrderTicket(),OBJPROP_PRICE1),4))
    if(! OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss(),ObjectGet(lvoe_tp_ OrderTicket(),OBJPROP_PRICE1),OrderExpiration(),CL R_NONE))
    //Alert(ErrorDescription(GetLastError()));

    persist;



    else
    if(ObjectFind(lvoe_tp_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_tp_ OrderTicket());



    if(use_cp cp_levelgt;0)
    if(ObjectFind(lvoe_cp_ OrderTicket())==-1)
    if(OrderType()==OP_BUY else
    if(OrderType()==OP_BUY)
    if(MarketInfo(OrderSymbol(),MODE_BID)gt;ObjectGet( lvoe_cp_ OrderTicket(),OBJPROP_PRICE1))
    if(OrderClose(OrderTicket(),cp_lots,MarketInfo(Ord erSymbol(),MODE_BID),0))
    ObjectSet(lvoe_cp_ OrderTicket(),OBJPROP_PRICE1,MarketInfo(OrderSymbo l(),MODE_BID) cp_closedlevel*MarketInfo(OrderSymbol(),MODE_POINT ));

    persist;


    if(OrderType()==OP_SELL)
    if(MarketInfo(OrderSymbol(),MODE_ASK)lt;ObjectGet( lvoe_cp_ OrderTicket(),OBJPROP_PRICE1))
    if(OrderClose(OrderTicket(),cp_lots,MarketInfo(Ord erSymbol(),MODE_ASK),0))
    ObjectSet(lvoe_cp_ OrderTicket(),OBJPROP_PRICE1,MarketInfo(OrderSymbo l(),MODE_ASK)-cp_closedlevel*MarketInfo(OrderSymbol(),MODE_POINT ));

    persist;





    if(use_be) {
    if(ObjectFind(lvoe_be_ OrderTicket())==-1) else {
    if(OrderType()==OP_BUY) {
    if(MarketInfo(OrderSymbol(),MODE_BID)gt;ObjectGet( lvoe_be_ OrderTicket(),OBJPROP_PRICE1)) {
    ObjectSet(lvoe_sl_ OrderTicket(),OBJPROP_PRICE1,OrderOpenPrice() be_offset*MarketInfo(OrderSymbol(),MODE_POINT));
    /*
    if(! OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice(),OrderTakeProfit(),OrderExpiration(),CLR_ NONE))
    //Alert(ErrorDescription(GetLastError()));

    */
    persist;
    }
    }
    if(OrderType()==OP_SELL)
    if(MarketInfo(OrderSymbol(),MODE_ASK)lt;ObjectGet( lvoe_be_ OrderTicket(),OBJPROP_PRICE1))
    ObjectSet(lvoe_sl_ OrderTicket(),OBJPROP_PRICE1,OrderOpenPrice()-be_offset*MarketInfo(OrderSymbol(),MODE_POINT));
    /*
    if(! OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice(),OrderTakeProfit(),OrderExpiration(),CLR_ NONE))
    //Alert(ErrorDescription(GetLastError()));

    */
    persist;


    }
    }

    if(use_cl)
    if(ObjectFind(lvoe_cl_ OrderTicket())==-1)
    if(OrderType()!) =OP_BUY OrderType()! =OP_SELL)
    else OrderType()==OP_SELLSTOP)
    if(MarketInfo(OrderSymbol(),MODE_ASK)gt;ObjectGet( lvoe_cl_ OrderTicket(),OBJPROP_PRICE1))
    OrderDelete(OrderTicket());


    if(OrderType()==OP_BUY


    }

    }
    }

    for(I=0;ilt;OrdersHistoryTotal();I )
    if(OrderSelect(I,SELECT_BY_POS,MODE_HISTORY))
    if(ObjectFind(lvoe_ol_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_ol_ OrderTicket());

    if(ObjectFind(lvoe_tp_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_tp_ OrderTicket());

    if(ObjectFind(lvoe_sl_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_sl_ OrderTicket());

    if(ObjectFind(lvoe_be_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_be_ OrderTicket());

    if(ObjectFind(lvoe_cl_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_cl_ OrderTicket());

    if(ObjectFind(lvoe_cp_ OrderTicket())!) =-1)
    ObjectDelete(lvoe_cp_ OrderTicket());



    }
    void align(string name)
    ObjectSet(title,OBJPROP_PRICE1,NormalizeDouble(Obj ectGet(title,OBJPROP_PRICE1),Digits));

    int orderDir(int oType)

  2. #2
    Please encase your codes in code tags. Or simply post up your mq4 file. It is very tedious for anybody to read codes that are unindented or indented.

  3. #3

  4. #4
    Is there a part of code which defines if an EA will have the ability to operate in pips?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information