Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent 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
  #2141 (permalink)  
Old 11-01-2009, 07:19 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Fixed lot to determine SL

Hello

I have been attempting to make a SL that it derived from the % risked and Lot Size.

Example

Balance 2000
Risk 2%
Cash At risk $40.00 = Balance * Risk
Lot Size 0.02
TickValue 10.00 or as determined by each pair.
TickSize 0.2 = TickValue * LotSize


SL 200 = Cash at Risk / TickSize.

So the SL would be placed 200 pips from the open.

the Lot Size should increase by 0.01 every 1000 Dollars.

This is what I have so far
Code:
double Lots;
if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)) {
  if(OrderType()==0 && OrderProfit()>0) {
  if(AccountBalance()>1000*2) Lots=MathAbs(MathCeil(-AccountBalance()/OrderProfit()))*0.01;
else Lots=0.01;

Any Help would be great

Cheers

Beno
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
  #2142 (permalink)  
Old 11-03-2009, 08:26 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Gidday

How do you use the bar open as the pivot point. example

If the Bid moves above the open buy and hits TP (with any luck) and reverses then the Ask moves below the open so open a sell.
I do realize the if the TP is not hit and the could be another position opened.


any help would be great.

Regards

Beno
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
  #2143 (permalink)  
Old 11-04-2009, 02:39 PM
Junior Member
 
Join Date: Sep 2009
Posts: 8
sunshineh is on a distinguished road
LimitOrders, which is open?

Hi,
I want to write my own EA.
First I send a SellLimit and a BuyLimit.

Then I want to see, which Orders of them are reached. How can I see which order is still open??

When I look at OrdersTotal() is get my OPEN and PENDING Orders.

Lot's of thanks,

sunshineh
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
  #2144 (permalink)  
Old 11-04-2009, 03:05 PM
Senior Member
 
Join Date: Dec 2007
Posts: 494
Enforcer is on a distinguished road
by OrderType( )

OP_BUY - buying position,
OP_SELL - selling position,
OP_BUYLIMIT - buy limit pending position,
OP_BUYSTOP - buy stop pending position,
OP_SELLLIMIT - sell limit pending position,
OP_SELLSTOP - sell stop pending position.

PHP Code:
for (int i 0OrdersTotal(); i++) 
   {
      
OrderSelect(iSELECT_BY_POSMODE_TRADES);
      if(
OrderType() == OP_BUY) {...do some thing....}
      if(
OrderType() == OP_SELL) {...do other thing....}
   } 
__________________
www.signalcopy.com - Most advanced tools for copy Metatrader signals.
Free MT4 account statistics - advanced stats and graphs for MT4 accounts
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
  #2145 (permalink)  
Old 11-04-2009, 09:25 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
Cgage2491 is on a distinguished road
A Little Bit of Programming Help

Hi Everyone,

This is my first post!!

I have been trying for about 3 months to program an EA to recognise a particular candlestick pattern and open either a Buy or Sell order after that pattern but, have been failing miserably!

I don't know how to post pictures here so I'll have to describe it.

For a Buy signal / trade I have been trying program:

Close[3] < Close[4],
Close[2] < Close[3],
High[2] < Open[3],
Low[1] > Low[2] and
Close[1] >= Open[3]

For the Sell signal / trade it is the opposite of the Buy.

It is probably very simple but I just can't do it.

Is there a kind and generous person out there who would be willing to program this for me???


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
  #2146 (permalink)  
Old 11-04-2009, 11:13 PM
Junior Member
 
Join Date: Jun 2009
Posts: 14
cosmiclifeform is on a distinguished road
Quote:
Originally Posted by Cgage2491 View Post
Hi Everyone,

For a Buy signal / trade I have been trying program:

Close[3] < Close[4],
Close[2] < Close[3],
High[2] < Open[3],
Low[1] > Low[2] and
Close[1] >= Open[3]

For the Sell signal / trade it is the opposite of the Buy.

Thanks
Hi Cgage....

Without your code I don't know what your variables are but you can try and modify this...it may work for you.

bool BuyCondition = false ;
bool SellCondition = false ;


//--------- BuyCondition ----------
if (Close[3] < Close[4] && Close[2] < Close[3] && High[2] < Open[3] && Low[1] > Low[2] && Close[1] >= Open[3]) BuyCondition = true ; else BuyCondition = false;

For the Sell signal / trade it is the opposite of the Buy.

//--------- SellCondition ----------
if (Close[3] > Close[4] && Close[2] > Close[3] && High[2] > Open[3] && Low[1]< Low[2] && Close[1] <= Open[3]) SellCondition = true ; else SellCondition = false;

Good luck.
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
  #2147 (permalink)  
Old 11-05-2009, 06:48 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
Cgage2491 is on a distinguished road
Quote:
Originally Posted by cosmiclifeform View Post
Hi Cgage....

Without your code I don't know what your variables are but you can try and modify this...it may work for you.

bool BuyCondition = false ;
bool SellCondition = false ;


//--------- BuyCondition ----------
if (Close[3] < Close[4] && Close[2] < Close[3] && High[2] < Open[3] && Low[1] > Low[2] && Close[1] >= Open[3]) BuyCondition = true ; else BuyCondition = false;

For the Sell signal / trade it is the opposite of the Buy.

//--------- SellCondition ----------
if (Close[3] > Close[4] && Close[2] > Close[3] && High[2] > Open[3] && Low[1]< Low[2] && Close[1] <= Open[3]) SellCondition = true ; else SellCondition = false;

Good luck.
Robert
Thanks for the reply.

I tried something like this, I've tried lots of things.

The problems I've had have been multiple trades per bar, trades on every bar, not recognising the pattern at all, etc.

I understand the logic side of things but I don't know how to program it.

I tried doing cut and paste from other indicators / EAs but I can't get it to do what I want!

Basically, if the buy condition logic = true then open a buy trade and if sell condition logic = true then open a sell trade.

Any help appreciated.
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
  #2148 (permalink)  
Old 11-05-2009, 07:43 PM
jpsdyb's Avatar
Member
 
Join Date: Dec 2005
Posts: 74
jpsdyb is on a distinguished road
Quote:
Originally Posted by Enforcer View Post
by OrderType( )

OP_BUY - buying position,
OP_SELL - selling position,
OP_BUYLIMIT - buy limit pending position,
OP_BUYSTOP - buy stop pending position,
OP_SELLLIMIT - sell limit pending position,
OP_SELLSTOP - sell stop pending position.

PHP Code:
for (int i 0OrdersTotal(); i++) 
   {
      
OrderSelect(iSELECT_BY_POSMODE_TRADES);
      if(
OrderType() == OP_BUY) {...do some thing....}
      if(
OrderType() == OP_SELL) {...do other thing....}
   } 
This above is your solution. You need to count existing orders so EA knwos they exist and not continue creating more
Quote:
Originally Posted by Cgage2491 View Post

The problems I've had have been multiple trades per bar, trades on every bar, not recognising the pattern at all, etc.
See what I said above. Can also try similar to this:
PHP Code:
int iticket;

int total OrdersTotal();

double totallongs=0totalshorts =0

          
 for( 
i=0;i<total;i++)       
   {
     
OrderSelect(iSELECT_BY_POS );
      if ( 
OrderComment() == ExpertName )  
         {
           
int type OrderType();

if (( 
OrderSymbol() == Symbol() && (type == OP_BUY ))) {totallongs=totallongs+1;}
if (( 
OrderSymbol() == Symbol() && (type == OP_SELL ))) {totalshorts=totalshorts+1;}
if (( 
OrderSymbol() == Symbol() && (type == OP_BUYLIMIT || OP_BUYSTOP ))) {totallongs=totallongs+1;}
if (( 
OrderSymbol() == Symbol() && (type == OP_SELLLIMIT || OP_SELLSTOP ))) {totalshorts=totalshorts+1;}

                }
              } 
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
  #2149 (permalink)  
Old 11-06-2009, 10:31 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
Cgage2491 is on a distinguished road
Thanks Guys,

Much better, it's not trading every bar now.

I have managed to get close to what I wanted but at the moment it's not finding the pattern I was after.

Just a few logic tweaks I think.
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
  #2150 (permalink)  
Old 11-07-2009, 01:06 AM
Junior Member
 
Join Date: Oct 2009
Posts: 2
fxCaptain is on a distinguished road
Exclamation Percent of Resistance Indicator

Does anybody have or can code the percent of resistance indicator?
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 10:29 AM.



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