gringoh Posted August 3, 2010 Report Share Posted August 3, 2010 Hello, I am a beginner in mql and I need your help to have a few explanations on an EA and to help me to modify it. Bellow you can find the code of the EASY EA which is a free EA from FF. The main function of this EA is to place a trendline on a chart and in the "name" portion to write either: “bs” for a buy stop “ss” for a sell stop Then you define in the inputs tab the lots value, the TP value and the SL value and the EA enter the trade when the price breaks the trendline. Here are my questions: - Is it possible to set the stop loss by drawing a trendline on the chart as for the buy stop? This would mean that the lots would be calculated by the EA with the difference between the buy stop trendline and the stop loss trendline. And so the EA would need another information in the inputs tab: the % of risk you want to take. - Can somebody explain me this part of the code? int TOOC() { int li_ret_0; for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { if (OrderSelect(l_pos_4, SELECT_BY_POS)) if (OrderSymbol() == Symbol()) li_ret_0++; } return (li_ret_0); } Thanks in advance for any help. Best regards, Gringoh Quote Link to comment Share on other sites More sharing options...
gringoh Posted August 3, 2010 Author Report Share Posted August 3, 2010 (edited) And bellow the code of the EA : /* Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] Website: http://purebeam.biz E-mail : [email protected] */ #property copyright "Dan I. Ostapyuk; [email protected]" #property link "www.marketprogramming.com; [email protected]" extern double Lots = 0.1; extern int StopLoss = 10; extern int TakeProfit = 20; int init() { start(); return (0); } int deinit() { if (ObjectGet("BuyStopLoss", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyStopLoss"); if (ObjectGet("BuyTakeProfit", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyTakeProfit"); if (ObjectGet("SellStopLoss", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellStopLoss"); if (ObjectGet("SellTakeProfit", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellTakeProfit"); if (ObjectGet("BuyStopLossText", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyStopLossText"); if (ObjectGet("BuyTakeProfitText", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyTakeProfitText"); if (ObjectGet("SellStopLossText", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellStopLossText"); if (ObjectGet("SellTakeProfitText", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellTakeProfitText"); return (0); } int start() { if (ObjectGet("bs", OBJPROP_PRICE1) > 0.0) { ObjectSet("bs", OBJPROP_COLOR, Green); ObjectCreate("bsText", OBJ_TEXT, 0, 0, 0); ObjectSet("bsText", OBJPROP_TIME1, Time[0]); ObjectSet("bsText", OBJPROP_PRICE1, ObjectGet("bs", OBJPROP_PRICE1)); ObjectSetText("bsText", " BuyStop", 10, "Book Antiqua", Green); if (Close[0] >= ObjectGet("bs", OBJPROP_PRICE1)) { OrderSend(Symbol(), OP_BUY, Lots, Ask, 25, 0, 0, 0, 0, 0, Green); if (ObjectGet("bs", OBJPROP_PRICE1) > 0.0) ObjectDelete("bs"); if (ObjectGet("bsText", OBJPROP_PRICE1) > 0.0) ObjectDelete("bsText"); if (ObjectGet("bl", OBJPROP_PRICE1) > 0.0) ObjectDelete("bl"); if (ObjectGet("blText", OBJPROP_PRICE1) > 0.0) ObjectDelete("blText"); } } if (ObjectGet("bl", OBJPROP_PRICE1) > 0.0) { ObjectSet("bl", OBJPROP_COLOR, Green); ObjectCreate("blText", OBJ_TEXT, 0, 0, 0); ObjectSet("blText", OBJPROP_TIME1, Time[0]); ObjectSet("blText", OBJPROP_PRICE1, ObjectGet("bl", OBJPROP_PRICE1)); ObjectSetText("blText", " BuyLimit", 10, "Book Antiqua", Green); if (Close[0] <= ObjectGet("bl", OBJPROP_PRICE1)) { OrderSend(Symbol(), OP_BUY, Lots, Ask, 25, 0, 0, 0, 0, 0, Green); if (ObjectGet("bs", OBJPROP_PRICE1) > 0.0) ObjectDelete("bs"); if (ObjectGet("bsText", OBJPROP_PRICE1) > 0.0) ObjectDelete("bsText"); if (ObjectGet("bl", OBJPROP_PRICE1) > 0.0) ObjectDelete("bl"); if (ObjectGet("blText", OBJPROP_PRICE1) > 0.0) ObjectDelete("blText"); } } if (ObjectGet("ss", OBJPROP_PRICE1) > 0.0) { ObjectSet("ss", OBJPROP_COLOR, Green); ObjectCreate("ssText", OBJ_TEXT, 0, 0, 0); ObjectSet("ssText", OBJPROP_TIME1, Time[0]); ObjectSet("ssText", OBJPROP_PRICE1, ObjectGet("ss", OBJPROP_PRICE1)); ObjectSetText("ssText", " SellStop", 10, "Book Antiqua", Green); if (Close[0] <= ObjectGet("ss", OBJPROP_PRICE1)) { OrderSend(Symbol(), OP_SELL, Lots, Bid, 25, 0, 0, 0, 0, 0, Red); if (ObjectGet("ss", OBJPROP_PRICE1) > 0.0) ObjectDelete("ss"); if (ObjectGet("ssText", OBJPROP_PRICE1) > 0.0) ObjectDelete("ssText"); if (ObjectGet("sl", OBJPROP_PRICE1) > 0.0) ObjectDelete("sl"); if (ObjectGet("slText", OBJPROP_PRICE1) > 0.0) ObjectDelete("slText"); } } if (ObjectGet("sl", OBJPROP_PRICE1) > 0.0) { ObjectSet("sl", OBJPROP_COLOR, Green); ObjectCreate("slText", OBJ_TEXT, 0, 0, 0); ObjectSet("slText", OBJPROP_TIME1, Time[0]); ObjectSet("slText", OBJPROP_PRICE1, ObjectGet("sl", OBJPROP_PRICE1)); ObjectSetText("slText", " SellLimit", 10, "Book Antiqua", Green); if (Close[0] >= ObjectGet("sl", OBJPROP_PRICE1)) { OrderSend(Symbol(), OP_SELL, Lots, Bid, 25, 0, 0, 0, 0, 0, Red); if (ObjectGet("ss", OBJPROP_PRICE1) > 0.0) ObjectDelete("ss"); if (ObjectGet("ssText", OBJPROP_PRICE1) > 0.0) ObjectDelete("ssText"); if (ObjectGet("sl", OBJPROP_PRICE1) > 0.0) ObjectDelete("sl"); if (ObjectGet("slText", OBJPROP_PRICE1) > 0.0) ObjectDelete("slText"); } } if (TOOC() > 0) { for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { if (OrderSelect(l_pos_0, SELECT_BY_POS)) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { ObjectCreate("BuyStopLoss", OBJ_HLINE, 0, 0, OrderOpenPrice() - StopLoss * Point); ObjectSet("BuyStopLoss", OBJPROP_COLOR, Crimson); ObjectSet("BuyStopLoss", OBJPROP_STYLE, STYLE_DOT); if (ObjectGet("BuyStopLoss", OBJPROP_PRICE1) > 0.0) { ObjectCreate("BuyStopLossText", OBJ_TEXT, 0, 0, 0); ObjectSet("BuyStopLossText", OBJPROP_TIME1, Time[0]); ObjectSet("BuyStopLossText", OBJPROP_PRICE1, ObjectGet("BuyStopLoss", OBJPROP_PRICE1)); ObjectSetText("BuyStopLossText", " BuyStopLoss", 10, "Book Antiqua", Crimson); } ObjectCreate("BuyTakeProfit", OBJ_HLINE, 0, 0, OrderOpenPrice() + TakeProfit * Point); ObjectSet("BuyTakeProfit", OBJPROP_COLOR, RoyalBlue); ObjectSet("BuyTakeProfit", OBJPROP_STYLE, STYLE_DOT); if (ObjectGet("BuyTakeProfit", OBJPROP_PRICE1) > 0.0) { ObjectCreate("BuyTakeProfitText", OBJ_TEXT, 0, 0, 0); ObjectSet("BuyTakeProfitText", OBJPROP_TIME1, Time[0]); ObjectSet("BuyTakeProfitText", OBJPROP_PRICE1, ObjectGet("BuyTakeProfit", OBJPROP_PRICE1)); ObjectSetText("BuyTakeProfitText", " BuyTakeProfit", 10, "Book Antiqua", RoyalBlue); } if (Close[0] <= ObjectGet("BuyStopLoss", OBJPROP_PRICE1) || Close[0] >= ObjectGet("BuyTakeProfit", OBJPROP_PRICE1)) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 25, White); if (ObjectGet("BuyStopLoss", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyStopLoss"); if (ObjectGet("BuyTakeProfit", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyTakeProfit"); if (ObjectGet("BuyStopLossText", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyStopLossText"); if (ObjectGet("BuyTakeProfitText", OBJPROP_PRICE1) > 0.0) ObjectDelete("BuyTakeProfitText"); } } if (OrderType() == OP_SELL) { ObjectCreate("SellStopLoss", OBJ_HLINE, 0, 0, OrderOpenPrice() + StopLoss * Point); ObjectSet("SellStopLoss", OBJPROP_COLOR, Crimson); ObjectSet("SellStopLoss", OBJPROP_STYLE, STYLE_DOT); if (ObjectGet("SellStopLoss", OBJPROP_PRICE1) > 0.0) { ObjectCreate("SellStopLossText", OBJ_TEXT, 0, 0, 0); ObjectSet("SellStopLossText", OBJPROP_TIME1, Time[0]); ObjectSet("SellStopLossText", OBJPROP_PRICE1, ObjectGet("SellStopLoss", OBJPROP_PRICE1)); ObjectSetText("SellStopLossText", " SellStopLoss", 10, "Book Antiqua", Crimson); } ObjectCreate("SellTakeProfit", OBJ_HLINE, 0, 0, OrderOpenPrice() - TakeProfit * Point); ObjectSet("SellTakeProfit", OBJPROP_COLOR, RoyalBlue); ObjectSet("SellTakeProfit", OBJPROP_STYLE, STYLE_DOT); if (ObjectGet("SellTakeProfit", OBJPROP_PRICE1) > 0.0) { ObjectCreate("SellTakeProfitText", OBJ_TEXT, 0, 0, 0); ObjectSet("SellTakeProfitText", OBJPROP_TIME1, Time[0]); ObjectSet("SellTakeProfitText", OBJPROP_PRICE1, ObjectGet("SellTakeProfit", OBJPROP_PRICE1)); ObjectSetText("SellTakeProfitText", " SellTakeProfit", 10, "Book Antiqua", RoyalBlue); } if (Close[0] >= ObjectGet("SellStopLoss", OBJPROP_PRICE1) || Close[0] <= ObjectGet("SellTakeProfit", OBJPROP_PRICE1)) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 25, White); if (ObjectGet("SellStopLoss", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellStopLoss"); if (ObjectGet("SellTakeProfit", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellTakeProfit"); if (ObjectGet("SellStopLossText", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellStopLossText"); if (ObjectGet("SellTakeProfitText", OBJPROP_PRICE1) > 0.0) ObjectDelete("SellTakeProfitText"); } } } } } } Comment("Programmed by Dan I. Ostapyuk; [email protected]"); return (0); } int TOOC() { int li_ret_0; for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { if (OrderSelect(l_pos_4, SELECT_BY_POS)) if (OrderSymbol() == Symbol()) li_ret_0++; } return (li_ret_0); } Edited August 3, 2010 by gringoh Quote Link to comment Share on other sites More sharing options...
kennyhubbard Posted August 3, 2010 Report Share Posted August 3, 2010 int TOOC() { int li_ret_0; for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { if (OrderSelect(l_pos_4, SELECT_BY_POS)) if (OrderSymbol() == Symbol()) li_ret_0++; } return (li_ret_0); } This code returns a count of the number of current trades(open & pending) for the specific symbol that the EA is placed on. gringoh 1 Quote Link to comment Share on other sites More sharing options...
gringoh Posted August 30, 2010 Author Report Share Posted August 30, 2010 Hello, The developer of the EA has recently released a new version of the Easy EA including Money Management. I still have one question about the possibility to set the Stop Loss directly on the chart instead of putting a value in the EA inputs tab. (For example by putting BSSL in the line name). EA http://www.mediafire.com/?m8d6vn15p15bc Easy thread http://www.f0rexfact0ry.c0m/showthread.php?t=98061 Best regards, Gringoh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.