Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #101 (permalink)  
Old 07-20-2007, 03:13 AM
diskus diskus is offline
Junior Member
 
Join Date: Nov 2005
Posts: 14
diskus is on a distinguished road
Opend Order - Splitting

Hallo,
gives a way or code for closing smaller Lots - from opend position?

example: open 1 - close 0.5 ... or close 0.3 - from this position?

Thanks
diskus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #102 (permalink)  
Old 07-22-2007, 06:18 AM
MQL4 MQL4 is offline
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Exclamation MQL4 Learning

subtracting the counted_bars from the total count of the bars on chart.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #103 (permalink)  
Old 07-22-2007, 02:03 PM
MQL4 MQL4 is offline
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Does anybody know what this means? I need help with it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #104 (permalink)  
Old 07-22-2007, 02:10 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by MQL4 View Post
subtracting the counted_bars from the total count of the bars on chart.

Thanks.
Take a look to the mql4 help file:
Quote:
int IndicatorCounted( )
The function returns the amount of bars not changed after the indicator had been launched last. The most calculated bars do not need any recalculation. In most cases, same count of index values do not need for recalculation. The function is used to optimize calculating.

Note: The latest bar is not considered to be calculated and, in the most cases, it is necessary to recalculate only this bar. However, there occur some boundary cases where custom indicator is called from the expert at the first tick of the new bar. It is possible that the last tick of the previous bar had not been processed (because the last-but-one tick was being processed when this last tick came), the custom indicator was not called and it was not calculated because of this. To avoid indicator calculation errors in such situations, the IndicatorCounted() function returns the count of bars minus one.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #105 (permalink)  
Old 07-22-2007, 02:39 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,174
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
I think it is the number of the bars which was not changed after the last indicator's call.
For example we had 300 bars. Then EA may call indicator for the signal or to open the order. For example: H1 timeframe. So we still have 300 unchanged bars. Because 301th bar is open bar and this bar will not be counted.
Because many indicators and EAs are calculated using i bars so using this function we may be sure that this i number of bars was unchanged and indicator will not re-paint and everything will be on close bar.

It is example in help file:

Code:
int start()
    {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- 
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
  //---- 
     for(int i=0; i<limit; i++)
       {
        //---- 
        ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
        ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
        ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
       }
  //----
     return(0);
    }
But, sorry, I am not a coder so may be wrong.

Last edited by newdigital : 07-22-2007 at 02:42 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #106 (permalink)  
Old 07-23-2007, 03:58 AM
MQL4 MQL4 is offline
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Thank You guys, I have one more question please:
I spent many hours, and I cannot solve the problem to this code:


if (MODE_ASK==121.10)
{
ticket=OrderSend(Symbol()..............

I want the USD\JPY to trigger a buy at this point. What's wrong with this code?

Can somebody tell me a code syntax that will trigger a buy at a certain time?

Thank You. God bless You.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #107 (permalink)  
Old 07-23-2007, 05:15 PM
MQL4 MQL4 is offline
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
MQL4 Learning

I spent many hours, and I cannot solve the problem to this code:


if (MODE_ASK==121.10)
{
ticket=OrderSend(Symbol()..............


I want the USD\JPY to trigger a buy at this point. What's wrong with this code?

Also, can someone tell me a code syntax that will trigger a buy at a certain time?

Thank You. God bless You.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #108 (permalink)  
Old 07-23-2007, 05:45 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink

MODE_ASK?? who told you that the constant MODE_ASK means more than the number 10.

Well, MODE_ASK is used with the function MarketInfo to get the ask price of a currency not the one hosting the EA.

double ask =MarketInfo("EURUSD",MODE_ASK);

so, your code should be:

PHP Code:
double ask   =MarketInfo("EURUSD",MODE_ASK); 
if(
ask == 121.10)
{
    
//do whatever you want.

And about setting time to buy you can use:

PHP Code:
if (TimeHour(TimeCurrent()) == 12 &&  TimeMinute(TimeCurrent()) >= 30)
{
   
//place a buy order

The code above place an order at 12:30 PM


Quote:
Originally Posted by MQL4 View Post
I spent many hours, and I cannot solve the problem to this code:

if (MODE_ASK==121.10)
{
ticket=OrderSend(Symbol()..............


I want the USD\JPY to trigger a buy at this point. What's wrong with this code?

Also, can someone tell me a code syntax that will trigger a buy at a certain time?

Thank You. God bless You.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #109 (permalink)  
Old 07-23-2007, 06:16 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,174
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Please not that I am not a coder so my opinion about how to code may be totally mistaken.

I just opened help in MetaEditor:

Code:
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
where
- cmd - OP_BUY (buy), or OP_SELL (sell), and so on;

And also use MarketInfo.

Besices you may use some templates to create EAs:

Templates to create EAs and Indicators:
- some good templates are here;
- templates with some new codes are here.
- Programming Modules with many programming functions are here.


As to open the order at a certain time so you may use something like that:

Code:
datetime OpenOrder = StrToTime(TimeTrade)
and

Code:
if(CurTime() >= OpenTime && TimeCurrent() <= OpenOrder+60)
where,

extern string TimeTrade = "11:31";
datetime, StrToTime and TimeCurrent - see help in MetaEditor;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #110 (permalink)  
Old 07-23-2007, 06:19 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,174
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
MQL4,
I see that Codersguru replied already so forget about my post.

Just want to say that we are having this thread http://www.forex-tsd.com/general-dis...ing-forum.html as well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 06:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 08:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 05:29 PM


All times are GMT. The time now is 09:50 PM.