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.
Scripts that enter multiple trades off hot keys
Moderator: moderators
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
Scripts that enter multiple trades off hot keys
- Attachments
-
- SELL 3 Market v1.mq4
- Script Enters 3 Sell/Short Orders at Market Price
- (2.67 KiB) Downloaded 230 times
-
- BUY 3 Market v1.mq4
- Script Enters 3 Buy/Long Orders at Market
- (2.74 KiB) Downloaded 219 times
Last edited by MarketSlayer on Sat May 01, 2010 6:03 pm, edited 1 time in total.
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
Possible solution to Script Orders not filling
//+------------------------------------------------------------------+
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()
}
//+------------------------------------------------------------------+
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()
}
//+------------------------------------------------------------------+
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
I updated the original Scripts above, to loop until order is filled, works great.
http://themarketslayer.blogspot.com/201 ... -blog.html
http://themarketslayer.blogspot.com/201 ... -blog.html
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.