Go Back   Forex-TSD > Programming > MetaTrader Programming
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
  #701 (permalink)  
Old 02-18-2008, 01:15 PM
kat kat is offline
Member
 
Join Date: Apr 2006
Posts: 46
kat is on a distinguished road
Coding "Trend Condition" with StepMA

Buy condition:

StepMA (with Colour Mode: 2) is "long"
Stochastic crosses 20 from below to above

Sell condition:

StepMA (with Colour Mode: 2) is "short"
Stochastic crosses 80 from above to below


double StochCurrent = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 0);
double StochPrevious = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 1);
double TrendLong = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 1, Bar + 0);
double TrendShort = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 2, Bar + 0);


Buy if:

TrendLong && StochCurrent > 20 && StochPrevious < 20


Sell if:

TrendShort && StochCurrent < 80 && StochPrevious > 80



Can someone help me with the code of the "Trend Condition" in the above example, it does not work. I tried to call the buffer 1 and buffer 2 for long and short mode but I don't understand the code of this indicator. Thank you in advance!
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
  #702 (permalink)  
Old 02-18-2008, 01:22 PM
kat kat is offline
Member
 
Join Date: Apr 2006
Posts: 46
kat is on a distinguished road
Coding "Trend Condition" with StepMA

forgotten: for my previous posting the indicator and a screenshot
Attached Images
File Type: jpg example.jpg (54.3 KB, 122 views)
Attached Files
File Type: mq4 stepma_v7ea.mq4 (5.8 KB, 39 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
  #703 (permalink)  
Old 02-18-2008, 05:04 PM
fxgrm's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 114
fxgrm is on a distinguished road
Question Thanks Much Devil2000!

Quote:
Originally Posted by Devil2000 View Post
From the metaeditor:
Code:
bool IsDemo()
Returns TRUE if the expert runs on a demo account, otherwise returns FALSE.
Now can you tell me where to place this code?

I'm a real rookie at this stuff.

This is what shows up in Meta Editor:



extern double lot=0.01;
extern int MinGS=10;
extern double TP=10;
extern double MarginLevelAlert=1000;
extern double RepeatMinutes=60;
double MaxDrawDown = 0.0;
int magic;
int Account = 1857842;
double lot2;
double MarginPer;
datetime tob,tos,toe; //Time Out Buy, Sell, Expire



Appreciate the help.

Cheers

Last edited by fxgrm; 02-18-2008 at 05:13 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
  #704 (permalink)  
Old 02-18-2008, 07:00 PM
Junior Member
 
Join Date: Dec 2007
Posts: 8
janekpietrzyk is on a distinguished road
MaOnArray

Hi,
it would like to go long if the CCI goes above it's 14 sma, and go short when it goes below it's 14 sma. The CCI's sma is generated by the MaOnArray of the CCI of course.
This is my piece of code:

double a,b;

bla, bla, bla...

int start()
{


a= iCCI(NULL, 0, 14,PRICE_WEIGHTED,0);

b=iMAOnArray(a,0,14,0,MODE_SMA,0);



// check for long position (BUY) possibility

if(NewBar1()==true && a>b)
{

bla, bla, bla...


// check for short position (SELL) possibility

if(NewBar2()==true && a<b)
{


bla, bla, bla...

There is a problem however (it's pictured below) - so is there something that's missing in the code? and how can this problem be solved?
Problem is below:
Attached Images
File Type: jpg 1.JPG (128.2 KB, 118 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
  #705 (permalink)  
Old 02-19-2008, 02:41 AM
Member
 
Join Date: Oct 2006
Posts: 89
Big Be is on a distinguished road
Two Stops Question

See later post.

Last edited by Big Be; 02-19-2008 at 03:04 AM. Reason: To change sequence
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
  #706 (permalink)  
Old 02-19-2008, 03:00 AM
Member
 
Join Date: Oct 2006
Posts: 89
Big Be is on a distinguished road
MaOnArray

Jane,
First, you need to control how many trades open.
I suggest adding
if (OrdersTotal()==0) {
before entry filters, or maybe <= 1, for 2 orders allowed.

Or if you want more than two trades at a time:
for (int i = OrdersTotal() - 1; i >= 0;i--)
(Study most EAs for this one.)

I don't think you have given enough data for one to solve it, but I have a couple more suggestions.

It is not clear what NewBar1() does and how.

Make sure your global variables are re-set as needed after an order is opened (or closed, if applicable).
I write a line for each necessary variable after the open order line.

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
  #707 (permalink)  
Old 02-19-2008, 03:04 AM
Member
 
Join Date: Oct 2006
Posts: 89
Big Be is on a distinguished road
Two Stops Question

I need to know how to change the Stop for HALF of my open order. My understanding is that this means opening two orders, for example .2 lots and .2 lots.

My EA bases the number of lots on a Money Management calculation.

After the stop for one order is changed (based on a price level being reached) then I would let my exit code close both orders, unless their (now different) stops are hit.

The other order retains its original stop or possibly moves it up to Break Even.

If the initial quantity of lots (from the MM function) Is odd, instead of rounding down for an odd number of lots or tenth lots, I would like to split them unevenly between the two orders.

I believe this involves Magic Numbers, and a couple lines of code here and there. Maybe there is an EA with all this that I could copy from.

Thanks for any help.

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
  #708 (permalink)  
Old 02-19-2008, 06:11 AM
Junior Member
 
Join Date: Dec 2007
Posts: 8
janekpietrzyk is on a distinguished road
OK, thanks Big Me,

I'll post the whole EA tommorow. So U can be able to take a look at it.

regards,
J
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
  #709 (permalink)  
Old 02-19-2008, 08:00 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,117
omelette is on a distinguished road
Quote:
Originally Posted by Big Be View Post
I need to know how to change the Stop for HALF of my open order. My understanding is that this means opening two orders, for example .2 lots and .2 lots.

My EA bases the number of lots on a Money Management calculation.

After the stop for one order is changed (based on a price level being reached) then I would let my exit code close both orders, unless their (now different) stops are hit.

The other order retains its original stop or possibly moves it up to Break Even.

If the initial quantity of lots (from the MM function) Is odd, instead of rounding down for an odd number of lots or tenth lots, I would like to split them unevenly between the two orders.

I believe this involves Magic Numbers, and a couple lines of code here and there. Maybe there is an EA with all this that I could copy from.

Thanks for any help.

Big Be
Wouldn't it be a whole lot simpler to just open 1 order and scale out of that, adjusting a 'soft' SL on the remainder. You could place a Doomsday hard-stop just in case. Not only is it far easier, you are also not giving the bucketshops something to 'aim' at.
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
  #710 (permalink)  
Old 02-19-2008, 12:28 PM
Member
 
Join Date: Jan 2006
Posts: 34
DooMGuarD is on a distinguished road
Symbol in broker

hi all

i need to obtain all symbols in MetaTrade... How to code?

regards

charles
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, crossover, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, Gann Hilo, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mql4, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, strings, time range high low, 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 04:22 PM


All times are GMT. The time now is 06:29 AM.



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