I wrote an EA that simply blasts in 3 orders at the market. It sets a 15 pip stop and order 1 has a Take Profit of 10, Order 2 has Take Profit of 20 and order 3 has Take Profit of 30 for example.
Many times when I apply the EA to a chart it won't fill, I think it is slippage etc. Any ideas how to loop through an error condition until all three orders are placed?
Market Order EA Slippage
Moderator: moderators
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
Market Order EA Slippage
- Attachments
-
- EA Market Orders LONG.mq4
- (5.16 KiB) Downloaded 266 times
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
- bredin
- rank: 1000+ posts
- Posts: 1033
- Joined: Mon Feb 16, 2009 10:41 pm
- Reputation: 7
- Gender:
- Contact:
Error control 101:
1. Whats the journal tab telling you the error is?
2. look up that error at docs.mql4.com
3. find a workaround
personally Id use a different magic number for each trade and process accordingly.
Cheers
G.
1. Whats the journal tab telling you the error is?
2. look up that error at docs.mql4.com
3. find a workaround
personally Id use a different magic number for each trade and process accordingly.
Cheers
G.
Welcome to the era of "Guns and Maskies" Trading!
The previous message contains discretion. Viewer nudity is advised.
Insanity Industries Indicators Here
Insanity Industries on YouTube!
The previous message contains discretion. Viewer nudity is advised.
Insanity Industries Indicators Here
Insanity Industries on YouTube!
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
I did check both logs and saw Reason 3 and Reason 5....
Here is what I tried with a similar script:
//--------------------------------------------------------------------7 --
if (ticket_1 >0 && ticket_2 >0 && ticket_3 >0 ) // Got it!:)
{
Alert ("Opened All 3 orders ");
break; // Exit cycle
}
//--------------------------------------------------------------------8 --
int Error=GetLastError(); // Failed
switch(Error) // Overcomable errors
{
case 135:Alert("The price has changed. Retrying..");
RefreshRates(); // Update data
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
continue; // At the next iteration
case 146:Alert("Trading subsystem is busy. Retrying..");
Sleep(500); // Simple solution
RefreshRates(); // Update data
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
}
How do you suggest I use the Magic Number?
Here is what I tried with a similar script:
//--------------------------------------------------------------------7 --
if (ticket_1 >0 && ticket_2 >0 && ticket_3 >0 ) // Got it!:)
{
Alert ("Opened All 3 orders ");
break; // Exit cycle
}
//--------------------------------------------------------------------8 --
int Error=GetLastError(); // Failed
switch(Error) // Overcomable errors
{
case 135:Alert("The price has changed. Retrying..");
RefreshRates(); // Update data
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
continue; // At the next iteration
case 146:Alert("Trading subsystem is busy. Retrying..");
Sleep(500); // Simple solution
RefreshRates(); // Update data
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
}
How do you suggest I use the Magic Number?
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:
The EA Log shows two errors. I would load the EA on the chart....then when I wanted it to run, I would change the property "Trade Live" by selecting the check box, then hit ok... So the two errors I am seeing are:
"uninit reason 5" and "uninit reason 3"
When it worked it shows this...
05:17:21 EA Market Orders Short GBPUSDFXF,M15: loaded successfully
05:17:26 EA Market Orders Short GBPUSDFXF,M15: initialized
05:17:26 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:17:26 EA Market Orders Short GBPUSDFXF,M15: 1 FUNCTION - f_Place_Orders - STARTING
05:17:29 EA Market Orders Short GBPUSDFXF,M15: open #8824069 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6502 ok
05:17:31 EA Market Orders Short GBPUSDFXF,M15: open #8824071 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6482 ok
05:17:32 EA Market Orders Short GBPUSDFXF,M15: open #8824073 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6422 ok
When it doesn't work it shows this:
05:20:00 EA Market Orders Short GBPUSDFXF,M15: initialized
05:20:00 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - TP1 SHORT IS HIT
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - ENDING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - TP1 SHORT IS HIT
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - ENDING
"uninit reason 5" and "uninit reason 3"
When it worked it shows this...
05:17:21 EA Market Orders Short GBPUSDFXF,M15: loaded successfully
05:17:26 EA Market Orders Short GBPUSDFXF,M15: initialized
05:17:26 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:17:26 EA Market Orders Short GBPUSDFXF,M15: 1 FUNCTION - f_Place_Orders - STARTING
05:17:29 EA Market Orders Short GBPUSDFXF,M15: open #8824069 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6502 ok
05:17:31 EA Market Orders Short GBPUSDFXF,M15: open #8824071 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6482 ok
05:17:32 EA Market Orders Short GBPUSDFXF,M15: open #8824073 sell 0.03 GBPUSDFXF at 1.6522 sl: 1.6537 tp: 1.6422 ok
When it doesn't work it shows this:
05:20:00 EA Market Orders Short GBPUSDFXF,M15: initialized
05:20:00 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - TP1 SHORT IS HIT
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - ENDING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: SHORT EA STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - STARTING
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - TP1 SHORT IS HIT
05:20:00 EA Market Orders Short GBPUSDFXF,M15: 4 FUNCTION - f_Check_if_TP1_filled - ENDING
Last edited by MarketSlayer on Wed Nov 18, 2009 1:35 pm, edited 2 times in total.
- bredin
- rank: 1000+ posts
- Posts: 1033
- Joined: Mon Feb 16, 2009 10:41 pm
- Reputation: 7
- Gender:
- Contact:
"uninit reason 5" and "uninit reason 3"
these arent trade condition errors.
Cheers
G
these arent trade condition errors.
Cheers
G
Welcome to the era of "Guns and Maskies" Trading!
The previous message contains discretion. Viewer nudity is advised.
Insanity Industries Indicators Here
Insanity Industries on YouTube!
The previous message contains discretion. Viewer nudity is advised.
Insanity Industries Indicators Here
Insanity Industries on YouTube!
- MarketSlayer
- rank: <50 posts
- Posts: 23
- Joined: Mon Aug 31, 2009 10:57 pm
- Reputation: 0
- Gender:
- Contact:
I checked and it seems good... the only thing I can see is that you "clog" the buy function.
Eitherways, I think you are wasting your time trying to code an EA, while you can a perfect blueprint here : http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/
Just enter some basic triggers then modify the rest directly on the code on your PC, since it generate MQ4 files you can download.
Eitherways, I think you are wasting your time trying to code an EA, while you can a perfect blueprint here : http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/
Just enter some basic triggers then modify the rest directly on the code on your PC, since it generate MQ4 files you can download.
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.