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
  #1621 (permalink)  
Old 02-27-2009, 12:43 PM
Junior Member
 
Join Date: Aug 2006
Posts: 19
jsevero83 is on a distinguished road
Quote:
Originally Posted by djl View Post
Simple request - can anyone tell me how to get the current time frame / period being viewed? I.e. 1 hour, 4 hour, 1 day etc.

Have searched docs etc can't find it.

Thanks.
This function can to help you.

int Period( )
Returns the amount of minutes determining the used period (chart timeframe).
Sample:
Print("Period is ", Period());
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
  #1622 (permalink)  
Old 02-27-2009, 01:01 PM
Junior Member
 
Join Date: Apr 2008
Posts: 4
simonkoen is on a distinguished road
Post Two more questions

Hi Everybody.

Sorry for my bad spelling yesterday.

I would like how to go about it that when I open a buy or sell position and at the same time a stopsell or stopbuy how do i assign the same number to the orders so that if the one is Triggered it will automatically close the other order. I know you must be able to do it with the magic number but also something about the time in the Magic Number? The second question. When i place code into my orders section I force the program to only open one order on that bar but when I do this the Ea don`t Trigger orders when the conditions are met to open orders When I remove the code It does open orders where it meet the conditions. Any thoughts as to why this is so? Here is the code.

if(CurrBar != iTime(NULL,0,0))
{
double HighEnvelope = iEnvelopes(Symbol(),0,EnvelopePeriods,MODE_EMA,0,P RICE_MEDIAN,EnvelopeDev,MODE_UPPER,0);
if (Bid >= HighEnvelope && OrdersTotal() <=MaxAllowable_Trades)
{
OrderSend(Symbol(),OP_SELL,lotMM,(Bid),Slippage,(0 ),0," Sell Order ",MagicNumber,0,White);
OrderSend(Symbol(),OP_BUYSTOP,lotMM,Bid+EmergencyP rofit*Point,0,0,0," Pending Buy Order ",MagicNumber,0,DodgerBlue);
CurrBar = iTime(NULL,0,0);
}
}
return;
}

Thanks in advance for your patience and support.
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
  #1623 (permalink)  
Old 02-27-2009, 01:06 PM
djl djl is offline
Junior Member
 
Join Date: Dec 2008
Posts: 2
djl is on a distinguished road
Thumbs up

Thank you.
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
  #1624 (permalink)  
Old 02-27-2009, 03:20 PM
1Dave7's Avatar
Senior Member
 
Join Date: Aug 2007
Posts: 183
1Dave7 is on a distinguished road
Smile

Let's say Period() =5. How can I read the ticks current trade minute and seconds within that Period?? Example: Minute =3, Seconds=42.

What I want to do is check a condition within my ea every 4 minutes 50 seconds into the 5 minute period - Can you help!

Dave

Last edited by 1Dave7; 02-27-2009 at 03:22 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
  #1625 (permalink)  
Old 02-27-2009, 07:40 PM
Junior Member
 
Join Date: Aug 2006
Posts: 19
jsevero83 is on a distinguished road
Quote:
Originally Posted by 1Dave7 View Post
Let's say Period() =5. How can I read the ticks current trade minute and seconds within that Period?? Example: Minute =3, Seconds=42.

What I want to do is check a condition within my ea every 4 minutes 50 seconds into the 5 minute period - Can you help!

Dave
In a 5min timeframe, i think that only you can check some situation at a determined time is when a new tick arise. You will can to view if the time elapsed from the opened bar is the time that you want.
At each new tick the start function of mql code will run, then you will need to monitor if the time elapsed from the last bar opened is the time that you want with Date & Time Functions of MQL.
If no new tick arise between your time (4min50sec) and a new bar opened period (5min) i don't know how to check because i never need to do that.
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
  #1626 (permalink)  
Old 02-27-2009, 09:39 PM
Junior Member
 
Join Date: Feb 2009
Posts: 1
Orionis is on a distinguished road
iCCI Question

I am new to MQL4 and am trying to get the previous CCI value. I have tried using the iCCI function with a Shift value of 1, but it does not give me the previous value. How would I do that without saving the current value to a variable? I am trying to determine the direction the CCI is going.

Thank you 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
  #1627 (permalink)  
Old 02-27-2009, 10:08 PM
Kenny Rogers's Avatar
Senior Member
 
Join Date: Oct 2008
Posts: 684
Kenny Rogers is on a distinguished road
The code is tick based, so if there is no tick at that time, then the code will miss the time check. I don't think you can get it to the exact second without some kind of loop that is contantly running.
__________________
Life is a Gamble. You win some. You lose some. And life goes on.
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
  #1628 (permalink)  
Old 03-01-2009, 12:02 AM
Junior Member
 
Join Date: Feb 2009
Posts: 3
coach3131 is on a distinguished road
Help With EA Editing

I am trying to figure this out... can you please help?

MB Trading - Stocks Options Futures Forex Online Discount Trading

I changed this:

OrderSend(Symbol(),OP_SELL,mylotsi, SellPrice,slippage,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,Arrow sColor);
return(0);

To:

int ticket = OrderSend(Symbol(),OP_SELL,mylotsi, SellPrice,slippage,0,0,"MyMEFx EA"+MagicNumber,MagicNumber,0,Arrow sColor);
Sleep(1500);
OrderModify(ticket,OrderOpenPrice() ,sl,tp,0,ArrowsColor);

=================================== ======

I am getting these errors:

2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: invalid ticket for OrderModify function
2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: OrderSend error 131
2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: OrderModify error 4051


=====================
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
  #1629 (permalink)  
Old 03-01-2009, 04:42 PM
cockeyedcowboy's Avatar
Senior Member
 
Join Date: Nov 2005
Posts: 480
cockeyedcowboy is on a distinguished road
Quote:
Originally Posted by coach3131 View Post
I am trying to figure this out... can you please help?

MB Trading - Stocks Options Futures Forex Online Discount Trading

I changed this:

OrderSend(Symbol(),OP_SELL,mylotsi, SellPrice,slippage,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,Arrow sColor);
return(0);

To:

int ticket = OrderSend(Symbol(),OP_SELL,mylotsi, SellPrice,slippage,0,0,"MyMEFx EA"+MagicNumber,MagicNumber,0,Arrow sColor);
Sleep(1500);
OrderModify(ticket,OrderOpenPrice() ,sl,tp,0,ArrowsColor);

=================================== ======

I am getting these errors:

2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: invalid ticket for OrderModify function
2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: OrderSend error 131
2009.02.28 17:32:59 2009.01.01 20:42 EATest AUDJPY,H1: OrderModify error 4051


=====================
Your problem is in your lot size (volume) in your order send statment. which returns a -1 because of the error. the ticket veriable doesnot contain a ticket number it contains the errror flag of -1 which triggered the other errors with the ordermodify function. You must correct the lot size variable mylotsi, to contain an acceptable value. second you should check the return value in the ticket variable to see that it dosenot contain an error flag before calling the ordermodify routine.

keit
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
  #1630 (permalink)  
Old 03-05-2009, 10:20 PM
samparkx's Avatar
Junior Member
 
Join Date: Oct 2008
Posts: 10
Blog Entries: 1
samparkx is on a distinguished road
EA Max Position

can any one add max positions for this EA
or let it to run one position only ?
thanks in advance
Attached Files
File Type: mq4 Reversal_EA_MT4 eur jpy works fine.mq4 (5.5 KB, 37 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
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 01:10 PM.



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