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
  #1111 (permalink)  
Old 07-31-2008, 10:41 PM
Junior Member
 
Join Date: Feb 2008
Posts: 3
mifiglo is on a distinguished road
Yeah thanks for offering to help

Quote:
Originally Posted by FerruFx View Post
Please post also the code lines with your iCustom() function

FerruFx
Yeah thanks for offering to help, i have fixed the problem already, it was a problem with my indicator.
However i noticed that my EA doesn't trade according to the Buy or Sell Arrows, here's my EA code.
Thanks in advance for your prompt reply,
//+------------------------------------------------------------------+
//| Anubis.mq4 |
//| Copyright © 2008, Sola Ajayi, NerdyMonk |
//| shollylabor@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Sola Ajayi, NerdyMonk"
#property link "shollylabor@gmail.com"

extern double TakeProfit = 500;
extern double Lots = 1;
extern double TrailingStop = 200;

double SS_SELL_0=0, SS_BUY_0=0;
bool SSIsBuy=false, SSIsSell=false;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt,ticket,total;

SS_SELL_0 = iCustom(Symbol(),Period(),"zeus",4,0,0);
SS_BUY_0 = iCustom(Symbol(),Period(),"zeus",4,1,0);

if (SS_SELL_0 > 0) {SSIsSell=true;SSIsBuy=false;}
if (SS_BUY_0 > 0) {SSIsSell=false;SSIsBuy=true;}

if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if(SSIsBuy == true)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,"zeus",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(SSIsSell == true)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"zeus",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(SSIsSell == true)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{
// should it be closed?
if(SSIsBuy == true)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
}
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
  #1112 (permalink)  
Old 07-31-2008, 11:53 PM
willmalou's Avatar
Member
 
Join Date: Apr 2006
Posts: 44
willmalou is on a distinguished road
Rsi Ea

This is my firs EA. It uses 2 rsi's crossing in 3 time frames. I have a problem with the ea taking trades against the crosses. Buying when it is supposed to sell, sell when suppose to buy. Could someone please look at the code and tell me where I went wrong. I haven't been able to see anything wrong.


I have attached the ea and a pic of the problem.
Attached Images
File Type: gif rsi wrong entry.gif (59.3 KB, 120 views)
Attached Files
File Type: mq4 RSI_Test.mq4 (10.9 KB, 18 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
  #1113 (permalink)  
Old 08-01-2008, 01:51 AM
Junior Member
 
Join Date: Jul 2008
Posts: 2
BigA is on a distinguished road
Need help for EA code!

Hi all,


As you know the fx market is 24 hours, I am not comfortable to trade overnight without sitting in front of PC. So I am thinking the best way is program to protect the trade if the price moves towards my favorite direction. For example, if I opened 5 lots in total, when the profit is above 50 pips, it automatically move stop loss to break even. When the profit is above 100 pips, it moves to protect 30 pips.When the profit is above 200 pips, it moves to protect 50 pips. and so on.

I tried to code my self. But it doesn't work when I drag it into my chart and set it trading live. Any body could help me to have a look of my code and fix it? Many thanks.


#property copyright "x li"
#property link ""
#property show_confirm

//---- input parameters
extern int target1 =50;
extern int target2 =100;
extern int target3 =150;
extern int target4 =200;
extern int target5 =300;

extern int protect1 =0;
extern int protect2 =5;
extern int protect3 =50;
extern int protect4 =100;



//+-----------------------------------------------------------------------------+
//| script "move stoploss to protect(50->0;100->5;150->50;200->50;300->100)" |
//+-----------------------------------------------------------------------------+

int start()
{
bool result;
double stop_loss,point,EntryPrice,profit;
int cmd,total,error,i;
//----
total=OrdersTotal();
point=MarketInfo(Symbol(),MODE_POINT);
//----
for(i=0; i<total; i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
cmd=OrderType();
EntryPrice=OrderOpenPrice();

//---- buy orders are considered
if(cmd==OP_BUY)
{
profit=Bid-EntryPrice;

if(profit>target1*point && profit<target2*point)
{
stop_loss=EntryPrice+protect1*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target2*point && profit<target3*point)
{
stop_loss=EntryPrice+protect2*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target3*point && profit<target4*point)
{
stop_loss=EntryPrice+protect3*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target4*point && profit<target5*point)
{
stop_loss=EntryPrice+protect3*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target5*point)
{
stop_loss=EntryPrice+protect4*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
}
//---- sell orders are considered
if(cmd==OP_SELL)
{
profit=EntryPrice-Ask;

if(profit>target1*point && profit<target2*point)
{
stop_loss=EntryPrice-protect1*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target2*point && profit<target3*point)
{
stop_loss=EntryPrice-protect2*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target3*point && profit<target4*point)
{
stop_loss=EntryPrice-protect3*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target4*point && profit<target5*point)
{
stop_loss=EntryPrice-protect3*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
if(profit>target5*point)
{
stop_loss=EntryPrice-protect4*point;
result=OrderModify(OrderTicket(),0,stop_loss,0,0,C LR_NONE);
}
}
}
else { Print( "Error when order select ", GetLastError()); break; }
}
//----
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
  #1114 (permalink)  
Old 08-01-2008, 03:41 AM
Member
 
Join Date: Oct 2006
Posts: 80
Big Be is on a distinguished road
Rsi Ea

I do not see why you use the same variable to open and to close trades, but it may work.

This may be the problem:
"Order" is a global variable. So at the end of each run through the Start function it will be set to the last value it was assigned, and use that value for the beginning of the next run through. It you make it local (move it inside Start) it may fix it. Else you will have to reset it after last use of it.

Good Hunting,

Big Be
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
  #1115 (permalink)  
Old 08-01-2008, 05:06 AM
Senior Member
 
Join Date: Feb 2007
Posts: 986
FerruFx is on a distinguished road
Quote:
Originally Posted by mifiglo View Post
Yeah thanks for offering to help, i have fixed the problem already, it was a problem with my indicator.
However i noticed that my EA doesn't trade according to the Buy or Sell Arrows, here's my EA code.
Thanks in advance for your prompt reply,
I am quite sure that your indicator repaints at least the current bar.

In your EA, in the iCustom() function you use the current bar (the last 0). Try to check the signal only at bar close (set the last number to 1). Then at the first tick of the new candle, if the arrow is still there (and not repaint), the trade won't be a false signal.

Note that I didn't checked it it repaints more than the current bar. But you get the idea.

FerruFx
__________________
FerruFx / www.ervent.net - Professional Coding Services (EAs/Indicators/Alerts)

BBVPS.com - Reliable Windows VPS For MT4 Hosting
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
  #1116 (permalink)  
Old 08-01-2008, 01:03 PM
Member
 
Join Date: Oct 2006
Posts: 33
Kaper is on a distinguished road
Problem with Modifying Orders

I have a problem with an EA modifying orders from other EA's and Manual Trades. I use multiple EA's - some that modify the orders but the EA's that modify the orders take into account orders not associated with the EA. How can I have it only modify orders pretaining to a particular EA and not every order that is open for that currency. Thanks.

Kevin
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
  #1117 (permalink)  
Old 08-01-2008, 01:32 PM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 722
Kalenzo is on a distinguished road
Quote:
Originally Posted by Kaper View Post
I have a problem with an EA modifying orders from other EA's and Manual Trades. I use multiple EA's - some that modify the orders but the EA's that modify the orders take into account orders not associated with the EA. How can I have it only modify orders pretaining to a particular EA and not every order that is open for that currency. Thanks.

Kevin
Hello!
Each ea can mark his orders by magic number. Use it to search in order pool for orders that you wish to be modified. In this case you can have other orders separated.
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
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
  #1118 (permalink)  
Old 08-01-2008, 02:09 PM
fungraphic's Avatar
Member
 
Join Date: Dec 2007
Posts: 50
fungraphic is on a distinguished road
I find coder

Hello,
I find coder for this.
Is there somebody who can develop a EA to calculate the pips month.
Look at the example below.



if i give you EA source code to count pip can you change it in order it can works for all brokers because from now on it only works for FXDD.
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
  #1119 (permalink)  
Old 08-01-2008, 02:49 PM
Linuxser's Avatar
User Root
 
Join Date: May 2006
Location: Helliconia (Winter)
Posts: 4,410
Blog Entries: 56
Linuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond repute
Hi fungraphic. I moved your post.

I know you must have some hurry bue there is not need to post same twice. If somebody is interest in help it would reply.
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
  #1120 (permalink)  
Old 08-02-2008, 10:02 PM
Junior Member
 
Join Date: Dec 2007
Posts: 3
free is on a distinguished road
Smile Need Moving average stoploss code

I need code for using the moving average as a stoploss. The stoploss would change as the moving average changed so it would effectively be an adaptive stoploss based upon the moving average. Thanks
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
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 04:11 PM.



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