"Everybody needs money. That's why they call it money" - Danny De Vito
Looking for a script to execute positive Swap Trading Only 1 reply
Hotkey script MT4 open-close orders 17 replies
Execute script using a keystroke 2 replies
close script without confirmation ? 6 replies
Can anyone share Buy-Sell-Close scripts to use as a hotkey without using F9 option? 5 replies
//+------------------------------------------------------------------+ double Share = 0.1; // Выделить часть FreeMargin на позу: // = 0 открыть минимальным лотом // = 1 открыть со всей дури int DistSL = 50; // Расстояние до SL int DistTP = 100; // Расстояние до TP int Slippage = 5; // Проскальзывание bool StopLoss = true; // Ставить или нет bool TakeProfit = true; // Ставить или нет //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void start() { int ticket; double SL = 50, TP = 100, Stake, StepDgts; double Step = MarketInfo(Symbol(), MODE_MINLOT); int Dgts = MarketInfo(Symbol(), MODE_DIGITS); //---- if(AccountFreeMargin() < Step*1000*Ask) { Alert("Open_SELL: No money..."); return; } //---- if(Share > 1.0) Share = 1.0; // Часть не бывает больше целого //---- if(Share < 0) Share = 0; //---- if(Step < 0.1) StepDgts = 2; else { if(Step < 1.0) StepDgts = 1; else StepDgts = 0; } //---- Stake = NormalizeDouble(AccountFreeMargin()*Share / 1000 / Ask, StepDgts); if(AccountFreeMargin() < Stake*1000*Bid) // Округление бывает и вверх Stake = NormalizeDouble(Stake - Step, StepDgts); // Теперь лишку не будет //Если выделенная часть депо будет меньше минимально допустимого лота, //поза будет открыта на минимальный лот if(Stake < Step) Stake = Step; if(StopLoss == true) SL = Ask + DistSL*Point; if(TakeProfit == true) TP = Bid - 2*DistTP*Point; ticket = OrderSend(Symbol(), OP_SELL, Stake, Bid, Slippage, NormalizeDouble(SL,Dgts), NormalizeDouble(TP,Dgts), "", 0, 0, CLR_NONE); if(ticket <= 0) Alert("Error Open_SELL: ", GetLastError()); return(0); } //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| trade.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #include <stdlib.mqh> #include <WinUser32.mqh> //+------------------------------------------------------------------+ //| script "trading for all money" | //+------------------------------------------------------------------+ int start() { //Script Parameters int OrderTypes = OP_BUY; double Lots = 0.1; int MagicNumber = 10; bool MoneyManagement = true; int Risk = 2; bool UseBlockTrade = true; double MaxLotSize = 9999; int MaxTrades = 10; int Slippage = 5; double Price; int Ticket1; int Ticket2; //----Starting Variables if (MoneyManagement) { if (Risk<1 || Risk>100) { Comment("Invalid Risk Value."); return(0); } else { Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT); } } if (Lots == 0 && MoneyManagement == true) Lots = MarketInfo(Symbol(), MODE_MINLOT); if (!UseBlockTrade && Lots > MarketInfo(Symbol(), MODE_MAXLOT)) Lots = MODE_MAXLOT; int OpenTradeCount = 0; double Lots1 = 0; double Lots2 = 0; Lots2 = Lots; if (UseBlockTrade) { if (Lots2 > MaxLotSize) { Lots1 = MaxLotSize; OpenTradeCount = MathFloor(Lots / MaxLotSize); Lots2 = Lots - (OpenTradeCount * MaxLotSize); if(OpenTradeCount > MaxTrades) { Lots2 = 0; OpenTradeCount = MaxTrades; } } } if (OrderTypes == OP_BUY) Price = Ask; else { if (OrderTypes == OP_SELL) Price = Bid; } if (Lots2 > 0) Ticket2=OrderSend(Symbol(), OrderTypes, Lots2, Price, Slippage, 0, 0, "Buy(#" + MagicNumber + ") " + Symbol() + " " + Period() + "", 255, 0, CLR_NONE); if (Lots1 > 0) {for (int i = 0; i < OpenTradeCount; i ++) Ticket1=OrderSend(Symbol(), OrderTypes, Lots1, Price, Slippage, 0, 0, "Buy(#" + MagicNumber + ") " + Symbol() + " " + Period() + "", 255, 0, CLR_NONE);} } //---- OrderPrint(); return(0); //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| trade.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #include <stdlib.mqh> #include <WinUser32.mqh> //+------------------------------------------------------------------+ //| script "trading for all money" | //+------------------------------------------------------------------+ int start() { //Script Parameters int OrderTypes = OP_SELL; double Lots = 0.1; int MagicNumber = 10; bool MoneyManagement = true; int Risk = 2; bool UseBlockTrade = true; double MaxLotSize = 9999; int MaxTrades = 99999999; int Slippage = 5; double Price; int Ticket1; int Ticket2; //----Starting Variables if (MoneyManagement) { if (Risk<1 || Risk>100) { Comment("Invalid Risk Value."); return(0); } else { Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT); } } if (Lots == 0 && MoneyManagement == true) Lots = MarketInfo(Symbol(), MODE_MINLOT); if (!UseBlockTrade && Lots > MarketInfo(Symbol(), MODE_MAXLOT)) Lots = MODE_MAXLOT; int OpenTradeCount = 0; double Lots1 = 0; double Lots2 = 0; Lots2 = Lots; if (UseBlockTrade) { if (Lots2 > MaxLotSize) { Lots1 = MaxLotSize; OpenTradeCount = MathFloor(Lots / MaxLotSize); Lots2 = Lots - (OpenTradeCount * MaxLotSize); if(OpenTradeCount > MaxTrades) { Lots2 = 0; OpenTradeCount = MaxTrades; } } } if (OrderTypes == OP_BUY) Price = Ask; else { if (OrderTypes == OP_SELL) Price = Bid; } if (Lots2 > 0) Ticket2=OrderSend(Symbol(), OrderTypes, Lots2, Price, Slippage, 0, 0, "Buy(#" + MagicNumber + ") " + Symbol() + " " + Period() + "", 255, 0, CLR_NONE); if (Lots1 > 0) {for (int i = 0; i < OpenTradeCount; i ++) Ticket1=OrderSend(Symbol(), OrderTypes, Lots1, Price, Slippage, 0, 0, "Buy(#" + MagicNumber + ") " + Symbol() + " " + Period() + "", 255, 0, CLR_NONE);} } //---- OrderPrint(); return(0); //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| close-all-orders.mq4 | //| Copyright © 2005, Matias Romeo. | //| Custom Metatrader Systems. | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Matias Romeo." #property link "mailto:matiasDOTromeoATgmail.com" int start() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); break; //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } return(0); }
Dislikedyour already missing the command
by adding this to the top, itl show inputs
#property show_inputs
by deleting this, or just comment it out, theyl be no window, resulting in instant execution
//#property show_inputsIgnored
DislikedI don't see them in there...odd:
Here are my scripts. These are the ones I personally trade with.
Buy:
[code]//+------------------------------------------------------------------+
//|...Ignored