//+------------------------------------------------------------------+ //| VisualOpenOrderWithMM.mq4 | //| Itso | //| itso@dir.bg | //+------------------------------------------------------------------+ #property copyright "Itso" #property link "itso@dir.bg" #property show_inputs #include extern double Risk = 0.001; extern double TP = 0.200; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- double MinLot = MarketInfo(Symbol(), MODE_MINLOT); double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT); double Step = MarketInfo(Symbol(), MODE_LOTSTEP); double StopLoss = WindowPriceOnDropped(); double MoneyRisk = AccountFreeMargin() * Risk; double TickValue = MarketInfo(Symbol(), MODE_TICKVALUE); double PointLoss; double TProfit; int cmd; double price; if(Ask>StopLoss) { //Open Long PointLoss = (Ask - StopLoss) / Point; TProfit = (Ask + TP); cmd = OP_BUY; price = Ask; } else { //Open Short PointLoss = (StopLoss - Bid) / Point; TProfit = (Bid - TP); cmd = OP_SELL; price = Bid; } double LotsRough = MoneyRisk / (TickValue * PointLoss); if(LotsRoughLotsRough) { Lots = CheckedLot - Step; break; } } Print("Lots=",Lots); int ticket = OrderSend(Symbol(), cmd, Lots, price, 3, StopLoss, TProfit, 0); if (ticket<0) { Print("Error: ", ErrorDescription(GetLastError())); } //---- return(0); } //+------------------------------------------------------------------+