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
  #601 (permalink)  
Old 05-31-2007, 08:44 PM
Senior Member
 
Join Date: Feb 2006
Posts: 524
Michel is on a distinguished road
When you scan the orders collection by the "for" loop, you have to check if the selected order is on the current symbol, otherwize you will quickly do some greek salad...

PHP Code:
  for (int i=0i<OrdersTotal(); i++) {
    if (
OrderSelect(iSELECT_BY_POSMODE_TRADES)) {
      if(
OrderSymbol()==Symbol()) TrailingPositions();
    } 

Last edited by Michel; 05-31-2007 at 08:46 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #602 (permalink)  
Old 05-31-2007, 09:18 PM
basza's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 146
basza is on a distinguished road
Percentage code ?

Hello

Could someone please show me what code I need to show a percentage value of the account balance within an EA.

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #603 (permalink)  
Old 06-04-2007, 01:02 AM
Senior Member
 
Join Date: Nov 2006
Posts: 231
teldon is on a distinguished road
multiple entries

hi, how to code multiple entires eg.....

// check for long position (BUY) possibility
if ( Macd3 > Macd2 && Macd2 < Macd1 && Macd2 < -0.0045 )
if ( Macd3 > Macd2 && Macd2 < Macd1 && Macd2 < -0.0030 )
if ( Macd3 > Macd2 && Macd2 < Macd1 && Macd2 < -0.0015 )


I ran through the strategy tester and no trades opened but i deleted the 2 lines below and it was fine , please advise..
thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #604 (permalink)  
Old 06-04-2007, 01:15 AM
ryanklefas's Avatar
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 439
ryanklefas is on a distinguished road
Quote:
Originally Posted by basza
Hello

Could someone please show me what code I need to show a percentage value of the account balance within an EA.

Thanks in advance
This code is taken directly from one of my EAs:

PHP Code:
double balanceDeviation()
{

   
double equit AccountEquity();
   
double bal AccountBalance();
   
   
double val = ((equit/bal) -1) * 100;
   
   return (
val);

__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #605 (permalink)  
Old 06-04-2007, 04:49 AM
elitecamper's Avatar
Senior Member
 
Join Date: May 2007
Posts: 132
elitecamper is on a distinguished road
hey guys hows it going
i have a quick question, is there any why of converting an mq4 file into a .DLL file? i need an mq4 indicator in converted into a .DLL indicator in C+ or C. would it be hard for a programmer to write a converter? if not then ill look into hiring a coder.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #606 (permalink)  
Old 06-05-2007, 05:54 PM
Junior Member
 
Join Date: Jan 2007
Posts: 4
scardi is on a distinguished road
A question from a newbie

Hi guys,
Often, when I try to modify a mq4 file with MetaEditor, I get the message “Access is denied” and I cannot modify the file. How do you guys deal with such a problem? Thanks! scardi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #607 (permalink)  
Old 06-06-2007, 10:39 PM
proverbs's Avatar
Member
 
Join Date: Jan 2007
Posts: 71
proverbs is on a distinguished road
Code Question

Please disregard post. This setting did what I needed it to do. Thanks for begin there to help us.

I have modified an EA to work with several methods. I have done some research but can not figure out how to add the name of the EA to the comments field when opening an order. Can someone please point me in the right direction.

I am hoping there is a simple string command that I can integrate into any EA I modify so that the orders are better organized when running more than one EA during a test.

Thanks for your time and insight.

OrderComment.JPG

Here is one of the non-modified sections I will need to change to input the EA comment.

Code:
   if(ObjectFind(BuyStop_TrendName) == 0)
     {
       SetObject("Active" + BuyStop_TrendName,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) + BuyStop_StepActive*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) + BuyStop_StepActive*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));
       SetObject("Prepare" + BuyStop_TrendName,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) - BuyStop_StepPrepare*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) - BuyStop_StepPrepare*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));
       vA = NormalizeDouble(ObjectGetValueByShift("Active"+BuyStop_TrendName,0),Digits);
       vM = NormalizeDouble(ObjectGetValueByShift(BuyStop_TrendName,0),Digits);
       vP = NormalizeDouble(ObjectGetValueByShift("Prepare"+BuyStop_TrendName,0),Digits);
       sl = vA - BuyStop_StopLoss*Point;
       tp = vA + BuyStop_TakeProfit*Point;
       if(Ask <= vM && Ask >= vP && OrderFind(MagicBuyStop) == false)
           if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"", MagicBuyStop, 0, Green) < 0)
               Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);

       if(Ask <= vM && Ask >= vP && OrderFind(MagicBuyStop) == true && 
          glbOrderType == OP_BUYSTOP)
         {
           OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
           if(vA != OrderOpenPrice())
               if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Green) == false)
                   Print("Err (", GetLastError(), ") Modify BuyStop Price= ", vA, 
                         " SL= ", sl, " TP= ", tp);
         }

       if(Ask < vP && OrderFind(MagicBuyStop) == true && 
          glbOrderType == OP_BUYSTOP && AutoClose==true)
         {
           OrderDelete(glbOrderTicket);
         }
     }
I am not sure of the logic but can I just input the CommentName in the following location? I have not tested this but it compiles fine.

Code:
if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"CommentName", MagicBuyStop, 0, Green) < 0)
 Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);
__________________
Proverbs [James]
Faith in Jesus helps me to see the invisible, believe the incredible and receive the impossible!
He makes all things new in my life.

Last edited by proverbs; 06-07-2007 at 04:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #608 (permalink)  
Old 06-07-2007, 05:56 PM
Junior Member
 
Join Date: Nov 2006
Posts: 19
Drivefast is on a distinguished road
Thank you Coderguru for being here for us!

I have a question about Alerts.

I want to change the alert type in this code so it will play a wav file that I choose and not have the popup window buy sell thing. Just play wav file when fractal apears.

How should the code be. I have attached the sFractals alert indicator.

if(PrevSignal <= 0 )
{
if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0)
{
PrevSignal = 1;
Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");
}
}
if(PrevSignal >= 0)
{
if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0)
{
PrevSignal = -1;
Alert("sFractals (", Symbol(), ", ", Period(), ") - SELL!!!");
}
}
Attached Files
File Type: mq4 sFractals.mq4 (7.4 KB, 9 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #609 (permalink)  
Old 06-07-2007, 06:02 PM
ryanklefas's Avatar
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 439
ryanklefas is on a distinguished road
Quote:
Originally Posted by proverbs
I am not sure of the logic but can I just input the CommentName in the following location? I have not tested this but it compiles fine.

Code:
if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"CommentName", MagicBuyStop, 0, Green) < 0)
 Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);
That will work fine. You can also put a string variable in that place.
__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #610 (permalink)  
Old 06-07-2007, 06:05 PM
ryanklefas's Avatar
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 439
ryanklefas is on a distinguished road
Quote:
Originally Posted by Drivefast
Thank you Coderguru for being here for us!

I have a question about Alerts.

I want to change the alert type in this code so it will play a wav file that I choose and not have the popup window buy sell thing. Just play wav file when fractal apears.

How should the code be. I have attached the sFractals alert indicator.

if(PrevSignal <= 0 )
{
if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0)
{
PrevSignal = 1;
Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");
}
}
if(PrevSignal >= 0)
{
if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0)
{
PrevSignal = -1;
Alert("sFractals (", Symbol(), ", ", Period(), ") - SELL!!!");
}
}
I think CodersGuru died or something. He hasn't been around in a while.

Anyway.... add this statement:

PlaySound("alert.wav");

.... where "alert.wav" is the name of the file that you want to play.
__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex

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 09:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 11:46 AM


All times are GMT. The time now is 08:54 PM.



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