Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #841 (permalink)  
Old 11-05-2009, 02:59 PM
Junior Member
 
Join Date: Oct 2009
Posts: 2
mercswish is on a distinguished road
Thank you Maji, that was the code I needed and it worked, just couldn't wrap my head around the algo. I appreciate your help..

-Merc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #842 (permalink)  
Old 11-09-2009, 06:33 AM
Junior Member
 
Join Date: Nov 2009
Posts: 1
kockleong is on a distinguished road
Multi Order at the same time~Need your help

Hi Expert,

i was trying to create a script.

Feature of the script:-
1. Open multi oder ( Buy and Sell ) at the same time for 9 Pair
2. Set takeprofit as i like
3. Put Stoploss as 0

Problem facing:-
1. It was not active for all pair


Script:-

--------------------------------------------------------------------------------
#include <stdlib.mqh>
#include <WinUser32.mqh>


extern double Lots = 0.10; // change this number to change the lotsize
extern double stoploss = 100; // change this number to change the stoploss
extern double takeprofit = 100; // change this number to change the takeprofit


//OrderSend("EURUSD",OP_BUY,0.1,MarketInfo("EURUSD", MODE_ASK),3,MarketInfo("EURUSD",MODE_ASK)-stoploss*Point,MarketInfo("EURUSD",MODE_ASK)+takep rofit*Point,"",1234567,0,Blue);
//OrderSend("EURUSD",OP_SELL,0.1,MarketInfo("EURUSD" ,MODE_BID),3,MarketInfo("EURUSD",MODE_BID)+50*Poin t,MarketInfo("EURUSD",MODE_BID)-50*Point,"",MAGICMAeu,0,Red)
//OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+stoploss *Point,Ask-takeprofit*Point,"JMSELLER",0,0,CLR_NONE);
int start()
{

OrderSend("EURUSD",OP_BUY,Lots,MarketInfo("EURUSD" ,MODE_ASK),3,MarketInfo("EURUSD",MODE_ASK)-50*Point,MarketInfo("EURUSD",MODE_ASK)+12*Point,"" ,0,0,Blue);
OrderSend("EURUSD",OP_SELL,Lots,MarketInfo("EURUSD ",MODE_BID),3,MarketInfo("EURUSD",MODE_BID)+50*Poi nt,MarketInfo("EURUSD",MODE_BID)-12*Point,"",0,0,Red);

OrderSend("USDCHF",OP_BUY,Lots,MarketInfo("USDCHF" ,MODE_ASK),3,MarketInfo("USDCHF",MODE_ASK)-50*Point,MarketInfo("USDCHF",MODE_ASK)+13*Point,"" ,0,0,Blue);
OrderSend("USDCHF",OP_SELL,Lots,MarketInfo("USDCHF ",MODE_BID),3,MarketInfo("USDCHF",MODE_BID)+50*Poi nt,MarketInfo("USDCHF",MODE_BID)-13*Point,"",0,0,Red);

OrderSend("USDJPY",OP_BUY,Lots,MarketInfo("USDJPY" ,MODE_ASK),3,MarketInfo("USDJPY",MODE_ASK)-50*Point,MarketInfo("USDJPY",MODE_ASK)+12*Point,"" ,0,0,Blue);
OrderSend("USDJPY",OP_SELL,Lots,MarketInfo("USDJPY ",MODE_BID),3,MarketInfo("USDJPY",MODE_BID)+50*Poi nt,MarketInfo("USDJPY",MODE_BID)-12*Point,"",0,0,Red);

OrderSend("AUDUSD",OP_BUY,Lots,MarketInfo("AUDUSD" ,MODE_ASK),3,MarketInfo("AUDUSD",MODE_ASK)-50*Point,MarketInfo("AUDUSD",MODE_ASK)+13*Point,"" ,0,0,Blue);
OrderSend("AUDUSD",OP_SELL,Lots,MarketInfo("AUDUSD ",MODE_BID),3,MarketInfo("AUDUSD",MODE_BID)+50*Poi nt,MarketInfo("AUDUSD",MODE_BID)-13*Point,"",0,0,Red);

OrderSend("GBPUSD",OP_BUY,Lots,MarketInfo("GBPUSD" ,MODE_ASK),3,MarketInfo("GBPUSD",MODE_ASK)-50*Point,MarketInfo("GBPUSD",MODE_ASK)+13*Point,"" ,0,0,Blue);
OrderSend("GBPUSD",OP_SELL,Lots,MarketInfo("GBPUSD ",MODE_BID),3,MarketInfo("GBPUSD",MODE_BID)+50*Poi nt,MarketInfo("GBPUSD",MODE_BID)-13*Point,"",0,0,Red);

OrderSend("EURJPY",OP_BUY,Lots,MarketInfo("EURJPY" ,MODE_ASK),3,MarketInfo("EURJPY",MODE_ASK)-50*Point,MarketInfo("EURJPY",MODE_ASK)+13*Point,"" ,0,0,Blue);
OrderSend("EURJPY",OP_SELL,Lots,MarketInfo("EURJPY ",MODE_BID),3,MarketInfo("EURJPY",MODE_BID)+50*Poi nt,MarketInfo("EURJPY",MODE_BID)-13*Point,"",0,0,Red);

OrderSend("CHFJPY",OP_BUY,Lots,MarketInfo("CHFJPY" ,MODE_ASK),3,MarketInfo("CHFJPY",MODE_ASK)-50*Point,MarketInfo("CHFJPY",MODE_ASK)+14*Point,"" ,0,0,Blue);
OrderSend("CHFJPY",OP_SELL,Lots,MarketInfo("CHFJPY ",MODE_BID),3,MarketInfo("CHFJPY",MODE_BID)+50*Poi nt,MarketInfo("CHFJPY",MODE_BID)-14*Point,"",0,0,Red);

OrderSend("AUDJPY",OP_BUY,Lots,MarketInfo("AUDJPY" ,MODE_ASK),3,MarketInfo("AUDJPY",MODE_ASK)-50*Point,MarketInfo("AUDJPY",MODE_ASK)+16*Point,"" ,0,0,Blue);
OrderSend("AUDJPY",OP_SELL,Lots,MarketInfo("AUDJPY ",MODE_BID),3,MarketInfo("AUDJPY",MODE_BID)+50*Poi nt,MarketInfo("AUDJPY",MODE_BID)-16*Point,"",0,0,Red);

OrderSend("GBPJPY",OP_BUY,Lots,MarketInfo("GBPJPY" ,MODE_ASK),3,MarketInfo("GBPJPY",MODE_ASK)-50*Point,MarketInfo("GBPJPY",MODE_ASK)+17*Point,"" ,0,0,Blue);
OrderSend("GBPJPY",OP_SELL,Lots,MarketInfo("GBPJPY ",MODE_BID),3,MarketInfo("GBPJPY",MODE_BID)+50*Poi nt,MarketInfo("GBPJPY",MODE_BID)-17*Point,"",0,0,Red);

}
-----------------------------------------------------------------------------------

Expert need your help~ Please help me to modify it~
Attached Files
File Type: mq4 JMBUYERv2.mq4 (5.2 KB, 2 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #843 (permalink)  
Old 11-10-2009, 01:16 PM
Junior Member
 
Join Date: Apr 2008
Location: SPAIN
Posts: 13
pacapanes is on a distinguished road
Thumbs up One EA, two signals, two pairs..

Hello friends...

It´s possible to test and work with an ea that needs the confirmation of a signal in two pairs at the same time?

I have an interesting idea based on price action valid for a lot of markets and I want to start with forex ( EURUSD - USDCHF ) but I have this problem...

Really thanks for your help!!!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #844 (permalink)  
Old 11-10-2009, 03:54 PM
Junior Member
 
Join Date: Oct 2009
Posts: 3
feelexit is on a distinguished road
Newbie question: why Alert function not working?

I only add follow two lines to the "Start()" function.

Alert("hsdfsdfsdlfsdfsd");
Print("hsdfsdfsdlfsdfsd");

This is simple enough, alert didnt show up and I checked "expert" tab, log not there.

Do I need to set some options to enable alert and print function?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #845 (permalink)  
Old 11-10-2009, 09:05 PM
Junior Member
 
Join Date: Sep 2006
Posts: 5
apres is on a distinguished road
Library file problem

I have a strange problem with a library file.

I have an EA which uses the LibOrderReliable_V1_1_4
library file by Matthew Kennel.

This file and the stdlib file are in the folder
"C:\Program Files\MT4\experts\libraries".

I can open both files from this location in MetaEditor.

The first lines of the EA are -

#include <stdlib.mqh>
#include <stderror.mqh>
#include <LibOrderReliable_v1_1_4.mqh>

When I compile the EA, I get the error message -

'LibOrderReliable_v1_1_4.mqh' - cannot open the program file

Does anyone know why this is so, when there is no problem opening stdlib.mqh?

Last edited by apres; 11-10-2009 at 09:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #846 (permalink)  
Old 11-10-2009, 10:30 PM
Junior Member
 
Join Date: Jun 2009
Posts: 13
cosmiclifeform is on a distinguished road
Quote:
Originally Posted by apres View Post
I have a strange problem with a library file.

I have an EA which uses the LibOrderReliable_V1_1_4
library file by Matthew Kennel.

This file and the stdlib file are in the folder
"C:\Program Files\MT4\experts\libraries".

I can open both files from this location in MetaEditor.

The first lines of the EA are -

#include <stdlib.mqh>
#include <stderror.mqh>
#include <LibOrderReliable_v1_1_4.mqh>

When I compile the EA, I get the error message -

'LibOrderReliable_v1_1_4.mqh' - cannot open the program file

Does anyone know why this is so, when there is no problem opening stdlib.mqh?
Hi Apres,

I needed that file for my EA also and I ended up finding out that I actually needed two files:

1) 'LibOrderReliable_v1_1_4.mqh' - I put the "mqh" file in the "expert\includes" folder

2) Then I needed a "mq4" file also
'LibOrderReliable_v1_1_4.mq4'
I put this file in the "experts\library" folder:
'LibOrderReliable_v1_1_4.mq4 --> compile to "exe" file

Now run your EA and it should work.

Search this TSD site or the web if you need to find the files (I only have an earlier version).

Hope this helps,
Robert
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #847 (permalink)  
Old 11-11-2009, 06:36 AM
Junior Member
 
Join Date: Sep 2008
Posts: 8
jimmynz is on a distinguished road
How to stop "not enough money"

i understand there's lack of margin to allow the ticket to be accepted.

How do i end the cycle and wait for the current trades to close and stop the "Not enough money"? break; somewhere? im using martingale to a trade limit

My order send sell then buy:

void OpenMarketOrders()
{
int cnt=0;
int err=0;

if (myOrderType==1 && ContinueOpening)
{
if ((Bid-LastPrice)>=Pips*Point || OpenOrders<1)
{
SellPrice=Bid;
LastPrice=0;
if (TakeProfit==0) { tp=0; }
else { tp=SellPrice-TakeProfit*Point; }
if (StopLoss==0) { sl=0; }
else { sl=SellPrice+StopLoss*Point; }
if (OpenOrders!=0)
{
mylotsi=lotsi;
for(cnt=0;cnt<OpenOrders;cnt++)
{
if (Lots<0.1) { mylotsi=NormalizeDouble(mylotsi*multiply,2); }
else { mylotsi=NormalizeDouble(mylotsi*multiply,1); }
}
} else { mylotsi=lotsi; }
if (mylotsi>100) { mylotsi=100; }

RefreshRates();
ticket=OrderSend(Symbol(),OP_SELL,mylotsi,SellPric e,slippage,0,0,Comments,MagicNumber,0,ArrowsColor) ;

if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0 ,ArrowsColor);
err=GetLastError();

if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
}
else
{
Print("OrderSend failed with error #",GetLastError());

}
}
return(0);
}
}

if (myOrderType==2 && ContinueOpening)
{
if ((LastPrice-Ask)>=Pips*Point || OpenOrders<1)
{
BuyPrice=Ask;
LastPrice=0;
if (TakeProfit==0) { tp=0; }
else { tp=BuyPrice+TakeProfit*Point; }
if (StopLoss==0) { sl=0; }
else { sl=BuyPrice-StopLoss*Point; }
if (OpenOrders!=0) {
mylotsi=lotsi;
for(cnt=0;cnt<OpenOrders;cnt++)
{
if (Lots<0.1) { mylotsi=NormalizeDouble(mylotsi*multiply,2); }
else { mylotsi=NormalizeDouble(mylotsi*multiply,1); }
}
} else { mylotsi=lotsi; }
if (mylotsi>100) { mylotsi=100; }
RefreshRates();
ticket=OrderSend(Symbol(),OP_BUY,mylotsi,SellPrice ,slippage,0,0,Comments,MagicNumber,0,ArrowsColor);

if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0 ,ArrowsColor);
err=GetLastError();

if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
}
else
{
Print("OrderSend failed with error #",GetLastError());
}
}
return(0);
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #848 (permalink)  
Old 11-11-2009, 08:02 PM
Senior Member
 
Join Date: Nov 2006
Posts: 307
luxinterior is on a distinguished road
Why not just check the margin at the beginning of the fucntion and if it's less than the required amount return.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #849 (permalink)  
Old 11-11-2009, 11:04 PM
Junior Member
 
Join Date: Sep 2008
Posts: 8
jimmynz is on a distinguished road
isnt that a harder way to go about it being theres multi trades open?
or whats the code for testing FreeMargin to place (noob)

what about...

if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
}
else
{
Break; //--where do i put the While loop()?
}
}
return(0);
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #850 (permalink)  
Old 11-12-2009, 12:58 AM
Senior Member
 
Join Date: Nov 2006
Posts: 307
luxinterior is on a distinguished road
There's a few functions regarding free margin such as AccountMargin( ) . Take a look in the help file and see which one best fits your needs.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
automated close order, close, eas, forex, learn mql4, learn mql4 video, learning mql4, mini std lotsize risk, mql4 ima, mql4 learning, mql4 video, OrderCloseBy, profit, reach, secure profit function, T101_v1.11_orest_IBFXm.mq4


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 07:04 PM
Learning to code for autotrading GoatT MetaTrader 8 01-10-2007 09:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 06:29 PM


All times are GMT. The time now is 02:10 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.