Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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 (2) Thread Tools Display Modes
  #421 (permalink)  
Old 11-02-2006, 07:27 PM
Mr.Marketz's Avatar
Senior Member
 
Join Date: Feb 2006
Posts: 312
Mr.Marketz is on a distinguished road
Trouble Shooting

My apologies - I had placed this in the wrong section...but here goes.

So I’m trying to piece together my first EA… obviously I’m at a dead end. The concept is to combine two functions which are:

Run (close profitable trades) executed every designated (time cycle)
I have two user input options – 1 (designate profitable) and 2 designate (time cycle). I believe most of the code is in order. I am left with one last error “end program”.

Can someone with a bit more experience at coding please correct what I’m doing wrong? It’s driving me CRAZY!!!

Thanks in advance
MM
Attached Files
File Type: mq4 Close all profitable positions on time.mq4 (1.4 KB, 21 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #422 (permalink)  
Old 11-09-2006, 05:39 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
ok I'm asking...

how do I use file functions so that it appends data to the end of the file rather than overwriting it.
http://www.forex-tsd.com/62009-post1150.html
please reply on the thread that this link goes to where I normally read.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #423 (permalink)  
Old 11-09-2006, 07:51 PM
skyline's Avatar
Member
 
Join Date: Apr 2006
Location: Pisa
Posts: 62
skyline is on a distinguished road
How to retrieve a specified closed order using HistoryTotal() ?

Hi All
is there a way using HistoryTotal function to be able to find a particular order (buy or sell) closed ?
I tried with this code but it seems not working :

Code:
   int hstTotal=HistoryTotal();
   for(i=0;i<hstTotal;i++)
   {
     //---- check selection result
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
       {
        if (Debug==true) Print("Access to history failed with error (",GetLastError(),")");
        break;
       }
      if (OrderType()==OP_BUY && OrderComment()=="LONG") 
      {
       ..take some action...
      }
      if (OrderType()==OP_SELL && OrderComment()=="SHORT") 
      {
       ..take some action...
      }
   }
And when a buy order was in place using OrderSelect I identified this using "LONG" as comment (and "SHORT" if a sell order) :

Code:
 Sell:
  ..
  ..
  OrderSend(Symbol(),OP_SELL,Lots,Entry,Slippage,StopLoss,TakeProfit,"SHORT",0,0);
  ..
  ..

Buy:
 ..
 ..
  OrderSend(Symbol(),OP_BUY,Lots,Entry,Slippage,StopLoss,TakeProfit,"LONG",0,0);
 ..
 ..
Maybe is not supported OrderComment using MODE_HISTORY mode? And if so how can I solve this issue?

thx a lot
Skyline

Last edited by skyline; 11-09-2006 at 08:14 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #424 (permalink)  
Old 11-09-2006, 10:14 PM
Nicholishen's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 531
Nicholishen is on a distinguished road
Quote:
Originally Posted by skyline
Hi All
is there a way using HistoryTotal function to be able to find a particular order (buy or sell) closed ?
I tried with this code but it seems not working :

Code:
   int hstTotal=HistoryTotal();
   for(i=0;i<hstTotal;i++)
   {
     //---- check selection result
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
       {
        if (Debug==true) Print("Access to history failed with error (",GetLastError(),")");
        break;
       }
      if (OrderType()==OP_BUY && OrderComment()=="LONG") 
      {
       ..take some action...
      }
      if (OrderType()==OP_SELL && OrderComment()=="SHORT") 
      {
       ..take some action...
      }
   }
And when a buy order was in place using OrderSelect I identified this using "LONG" as comment (and "SHORT" if a sell order) :

Code:
 Sell:
  ..
  ..
  OrderSend(Symbol(),OP_SELL,Lots,Entry,Slippage,StopLoss,TakeProfit,"SHORT",0,0);
  ..
  ..

Buy:
 ..
 ..
  OrderSend(Symbol(),OP_BUY,Lots,Entry,Slippage,StopLoss,TakeProfit,"LONG",0,0);
 ..
 ..
Maybe is not supported OrderComment using MODE_HISTORY mode? And if so how can I solve this issue?

thx a lot
Skyline
Skyline,

Be aware that the broker will append the comment with their own comments on the order for different reasons, and always when then the order is closed by SL or TP. What are the criteria for looking up the trades? Once you defone that then you'll have you solution.
__________________
"Anyone who has never made a mistake has never tried anything new." -Albert Einstein
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #425 (permalink)  
Old 11-09-2006, 10:55 PM
skyline's Avatar
Member
 
Join Date: Apr 2006
Location: Pisa
Posts: 62
skyline is on a distinguished road
Quote:
Originally Posted by Nicholishen
Skyline,

Be aware that the broker will append the comment with their own comments on the order for different reasons, and always when then the order is closed by SL or TP. What are the criteria for looking up the trades? Once you defone that then you'll have you solution.
Oh that's no a good news :|
Anyway i'm trying to explain my problem : in my EA I have different kind of buy (or sell), I have a kind that have to be opened whenever a condition is met also a lot of time in a day (something like that when price penetrate an EMA then an order is placed), and another type that have to be triggered only once per day depending on different conditions based on different EMA. So what I have to do is to let the first kind of buy/sell to open/close orders a lot of time in a day while the second kind of buy/sell orders have to be opened only once a day, so I thought that if I could localize in some way any kind of buy/sell order in history i could solve my problem , but it seems not possible
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #426 (permalink)  
Old 11-12-2006, 11:45 PM
Junior Member
 
Join Date: Jun 2006
Posts: 11
payal is on a distinguished road
daily chart values

Quote:
Originally Posted by codersguru
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.
Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:
High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #427 (permalink)  
Old 11-13-2006, 02:48 AM
Eaglehawk's Avatar
Senior Member
 
Join Date: Jun 2006
Posts: 141
Eaglehawk is on a distinguished road
Quote:
Originally Posted by payal
Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:
High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!
from your description, i'm assuming you are using this on the daily chart???

to answer your question, here's how i would solve the problem.

PHP Code:
if (DayOfWeek() == 0)
   {
   
High[2], Low[2], Close[2], //etc
   
}
   
else
   {
   
High[1], Low[1], Close[1],//etc
   

of course, you would arrange the high low and close to however you are using them
__________________
"One's ability to accomplish his or her goals is limited only by the ingenuity of how one uses what he or she already knows."- Eaglehawk
REMEMBER,
"Genius is nothing but a greater aptitude for patience." –Benjamin Franklin

____________________________________

Have a simple ea you just can't figure out how to code??? Odds are you can make it here. Just remember to push complete when you're done, NOT SAVE!!!

http://sufx.core.t3-ism.net/ExpertAdvisorBuilder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #428 (permalink)  
Old 11-13-2006, 06:21 AM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 696
Kalenzo is on a distinguished road
Quote:
Originally Posted by payal
Hi,

I am trying to get the high, low, open, close for the previous day @ 0 GMT for my EA. It works fine for all days except sunday in MIG & IBFX where it gets values for sunday from saturday and not friday. FXDD gets it crrectly from friday close since it doen't have a new bar for saturday.

Its coded as:
High[1], Low[1], Close[1] etc. How do I fix the code for sunday so that it gets values only from friday close and not saturday. Please help!
Check this file http://www.forex-tsd.com/attachments...4?d=1140111936
U will find the answer for your question there.

Regards
Kale
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #429 (permalink)  
Old 11-13-2006, 03:53 PM
Junior Member
 
Join Date: Jun 2006
Posts: 11
payal is on a distinguished road
Thank u

Quote:
Originally Posted by Eaglehawk
from your description, i'm assuming you are using this on the daily chart???

to answer your question, here's how i would solve the problem.

PHP Code:
if (DayOfWeek() == 0)
   {
   
High[2], Low[2], Close[2], //etc
   
}
   
else
   {
   
High[1], Low[1], Close[1],//etc
   

of course, you would arrange the high low and close to however you are using them

Thank u so much. Have a Great day!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #430 (permalink)  
Old 11-13-2006, 03:56 PM
Junior Member
 
Join Date: Jun 2006
Posts: 11
payal is on a distinguished road
Thank u

Quote:
Originally Posted by Kalenzo
Check this file http://www.forex-tsd.com/attachments...4?d=1140111936
U will find the answer for your question there.

Regards
Kale

Thank u, have a great day!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


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



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