#property copyright "Copyright ©2007 Forex on Autopilot" #property link "http://ForexAutopilot.com " int g_magic_76; int gi_unused_80; extern int TakeProfit = 10; extern int Step = 30; extern int Slippage = 3; extern string Comm = "ProfitStream Advisor"; bool gi_104 = TRUE; int init() { gi_unused_80 = 0; g_magic_76 = StringGetChar(Symbol(), 0) + 77703 + StringGetChar(Symbol(), 1) * 2 + 3 * StringGetChar(Symbol(), 3) + StringGetChar(Symbol(), 4) << 2 + 10000 * Period(); HideTestIndicators(TRUE); return (0); } int start() { string ls_0; double l_lots_8; double l_ord_open_price_16; double l_ord_open_price_24; double l_ord_profit_32; double l_ord_profit_40; if (gi_104) { ls_0 = "ProfitStream Advisor"; Comment(ls_0); } int l_count_48 = 0; int l_count_52 = 0; if (!IsTradeAllowed()) { Comment("Error: This currency pair is not allowed or connection failed"); return (0); } Comment(""); if (Bars < 100) return (0); double l_ord_lots_56 = 0; double l_ord_lots_64 = 0; for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++) { OrderSelect(l_pos_72, SELECT_BY_POS); if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_76) continue; if (OrderType() == OP_BUY) { if (OrderLots() > l_ord_lots_56) { l_ord_lots_56 = OrderLots(); l_ord_open_price_16 = OrderOpenPrice(); l_ord_profit_32 = OrderProfit(); } l_count_48++; } else { if (OrderType() == OP_SELL) { if (OrderLots() > l_ord_lots_64) { l_ord_lots_64 = OrderLots(); l_ord_open_price_24 = OrderOpenPrice(); l_ord_profit_40 = OrderProfit(); } l_count_52++; } } } bool l_bool_76 = FALSE; bool l_bool_80 = FALSE; bool li_84 = FALSE; bool li_88 = FALSE; l_bool_76 = l_count_48 < 1 || l_ord_open_price_16 - Step * Point > Ask && AccountFreeMargin() > AccountBalance() / 2.0; l_bool_80 = l_count_52 < 1 || l_ord_open_price_24 + Step * Point < Bid && AccountFreeMargin() > AccountBalance() / 2.0; if (l_ord_lots_56 > 0.0) li_84 = l_ord_profit_32 / (10.0 * l_ord_lots_56) > TakeProfit; if (l_ord_lots_64 > 0.0) li_88 = l_ord_profit_40 / (10.0 * l_ord_lots_64) > TakeProfit; if (li_84) { for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--) { OrderSelect(l_pos_72, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, White); } } else { if (li_88) { for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--) { OrderSelect(l_pos_72, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, White); } } else { RefreshRates(); if (l_bool_76) { if (l_ord_lots_56 == 0.0) l_lots_8 = 0.1; else l_lots_8 = 2.0 * l_ord_lots_56; OrderSend(Symbol(), OP_BUY, l_lots_8, Ask, Slippage, 0, Ask + (TakeProfit + 25) * Point, Comm, g_magic_76, 0, Yellow); } else { if (l_bool_80) { if (l_ord_lots_64 == 0.0) l_lots_8 = 0.1; else l_lots_8 = 2.0 * l_ord_lots_64; OrderSend(Symbol(), OP_SELL, l_lots_8, Bid, Slippage, 0, Bid - (TakeProfit + 25) * Point, Comm, g_magic_76, 0, Red); } } } } return (0); }