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
  #521 (permalink)  
Old 11-30-2007, 07:50 AM
Member
 
Join Date: Oct 2006
Posts: 59
Jovager is on a distinguished road
StopLoss on MAs crossing

In an EA, I have a SL=50.

How code if I want SL=50 OR crossing of 2 Ma ?

Thanks for 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
  #522 (permalink)  
Old 11-30-2007, 08:08 AM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 348
Devil2000 is on a distinguished road
Try this..

Put
Code:
double ma_cross;
as a global variable.

In the start function :

Code:
double ma1=NormalizeDouble(first_ma,Digits);
double ma2=NormalizeDouble(second_ma,Digits);

if(ma1=ma2)
 {
    ma_cross=ma1;
 }

int spread=MarketInfo(Symbol(), MODE_SPREAD);

SLbuy=ma1+spread-SL*Point;
SLsell=ma1+SL*Point;
Hope this helps
__________________
Need a professional MQL4 programmer? PM me

Last edited by Devil2000; 11-30-2007 at 08:12 AM.
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
  #523 (permalink)  
Old 11-30-2007, 08:52 AM
dxtrade's Avatar
Senior Member
 
Join Date: Jul 2007
Location: Maldives
Posts: 194
dxtrade is on a distinguished road
Close/Open trades at inversed signal

I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:
if(OneEntryPerBar==true)
{
if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);
}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks
__________________
Happy Trading...

"Failure is only a temporary change in direction to set you straight for your next success."
"Winning is a habit. Unfortunately, so is losing."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

"Say what you mean, but don't say it mean!"
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
  #524 (permalink)  
Old 12-05-2007, 02:54 AM
Junior Member
 
Join Date: Jun 2007
Posts: 3
Hisashi is on a distinguished road
Question Close and cancel at a certain time?

Can anyone help me with setting up EA that closes all open orders and cancels all pending order at a certain time, i.e., 5:15 a.m. UTC+1 ?
Is it also possible to specify not only the time but the date?
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
  #525 (permalink)  
Old 12-05-2007, 05:05 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Quote:
Originally Posted by dxtrade View Post
I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:
if(OneEntryPerBar==true)
{
if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);
}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks
it won't open cause of the code you use above.. until the next hour..

you can try this..

Quote:
if (OrderOpenTime() >= iTime(NULL, PERIOD_H1, 0)) order++;

if (order < 1)
{
order conditions
}
hope that helps.. not an expert.. but this code won't stop from doing it more than once..

Last edited by antone; 12-05-2007 at 05:15 AM.
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
  #526 (permalink)  
Old 12-06-2007, 12:20 AM
Junior Member
 
Join Date: Nov 2007
Posts: 2
wasanmyza is on a distinguished road
Help Me Ea

I Don't Speak English,I want to add Maxtrade And Risk Do you help me
Thankyou
Attached Files
File Type: mq4 Zero.mq4 (9.2 KB, 41 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
  #527 (permalink)  
Old 12-06-2007, 01:16 AM
Junior Member
 
Join Date: Aug 2007
Posts: 3
Strangguy is on a distinguished road
Quote:
Originally Posted by wasanmyza View Post
I Don't Speak English,I want to add Maxtrade And Risk Do you help me
Thankyou
Hi,
You have other issues with this EA. You are stating that you would like to make a buy or sell when VAR1, VAR2 or VAR3 has reached or exceeded certain values.
You must first define what is VAR1, 2 and 3? Some indicator with specific settings?

Thanks,
StrangeGuy
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
  #528 (permalink)  
Old 12-06-2007, 08:10 AM
Junior Member
 
Join Date: Apr 2007
Posts: 3
Mango Boy is on a distinguished road
Take Profit, cancel all other orders

Does anyone know how to code once the open order hit profit target, the rest of the pending orders will be deleted? It is different from oco. I have checked the elite section, but nothing there.
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
  #529 (permalink)  
Old 12-06-2007, 06:47 PM
Junior Member
 
Join Date: Oct 2007
Posts: 6
nakata79087 is on a distinguished road
question

I do not understand the difference of two programs, but would teach it?


int limit = Bars-IndicatorCounted();
int i ;
for( i=limit-1; i>=0; i--)




int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)
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
  #530 (permalink)  
Old 12-06-2007, 08:28 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by nakata79087 View Post
I do not understand the difference of two programs, but would teach it?


int limit = Bars-IndicatorCounted();
int i ;
for( i=limit-1; i>=0; i--)




int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)
The most important difference is the direction of the "for" loop:
The first one scan the bars following the natural time, ie from the oldest to the newest bar.
The second one scan the bars in the opposite direction: it can work if the calcul of a bar doesn't involve the result of the previous bar;
In general it's better to use the same direction as the time: it always works and there are no possibilties of mistaken.
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 12:59 AM.



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