Page 1 of 1

Scripts that enter multiple trades off hot keys

Posted: Fri Sep 04, 2009 2:16 am
by MarketSlayer
I have attached two simple Scripts I use often that will allow you to Set Hot keys, The code will Blast in Three Market orders with Stop Loss and Take Profits/Limits.
Simply edit the Script and run in Practice account to see how it works.
They work great.

Posted: Sun Sep 27, 2009 10:31 pm
by MarketSlayer
I am getting slippage or when I hit this script, often times I am only getting 1 or 2 of the 3 orders filled.
Does anyone know how to add error checking to retry if all orders are not filled?
Thanks

Possible solution to Script Orders not filling

Posted: Mon Oct 05, 2009 1:55 am
by MarketSlayer
//+------------------------------------------------------------------+
I added the order code after the error and that is not fixing it either.
Anyone have any ideas on how to get this to retry until filled when market is busy..What am I missing here??

//| Scalp LONG.mq4 |
//| Copyright ? 2009, |
//| 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()
{
int ticket_1;
while(true) // Cycle that opens an order
{

Alert("The request was sent to the server. Waiting for reply..");
//---- StopLoss = Ask-20*Point Take Profit = Ask + 20*Point
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);

//--------------------------------------------------------------------7 --
if (ticket_1>0) // Got it!:)
{
Alert ("Opened Scalp Order Long ",ticket_1);
break; // Exit cycle
}
//--------------------------------------------------------------------8 --
int Error=GetLastError(); // Failed :(
switch(Error) // Overcomable errors
{
case 135:Alert("The price has changed. Retrying..");
RefreshRates(); // Update data
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
case 136:Alert("No prices. Waiting for a new tick..");
while(RefreshRates()==false) // Up to a new tick
Sleep(1); // Cycle delay
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
case 146:Alert("Trading subsystem is busy. Retrying..");
Sleep(500); // Simple solution
RefreshRates(); // Update data
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
}
switch(Error) // Critical errors
{
case 2 : Alert("Common error.");
break; // Exit 'switch'
case 5 : Alert("Outdated version of the client terminal.");
break; // Exit 'switch'
case 64: Alert("The account is blocked.");
break; // Exit 'switch'
case 133:Alert("Trading forbidden");
break; // Exit 'switch'
default: Alert("Occurred error ",Error);// Other alternatives
}
break; // Exit cycle
}

return; // Exit start()
}


//+------------------------------------------------------------------+

Posted: Sun Feb 07, 2010 1:37 am
by tmanbone

Posted: Mon Feb 08, 2010 6:30 pm
by tmanbone
MarketSlayer are you still around? Do these scripts work in demo? I could use some help figuring out what I'm doing wrong. Thank you,

EDIT: Figured it out. Thanks,

Posted: Sat May 01, 2010 6:05 pm
by MarketSlayer
I updated the original Scripts above, to loop until order is filled, works great.

http://themarketslayer.blogspot.com/201 ... -blog.html