Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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 (1) Thread Tools Display Modes
  #321 (permalink)  
Old 08-26-2007, 07:48 PM
Junior Member
 
Join Date: Nov 2006
Posts: 4
beconan is on a distinguished road
not plot in real time

I downloaded an indicator called modtrade, it plot fine when you first place it on a chart, but it will not update correctly in real time, could someone help me to correct this?

//modtrade
#property copyright "Copyright © 2007, modulatum"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_level1 0
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Crimson
extern double sensitivity = 1;
extern int l_resolution = 50;
extern int v_resolution = 1;
extern int minutes = 0;
//extern int start = 0;
double drawBuffer[], drawBuffer2[], drawBuffer3[];
int init()
{
SetIndexStyle(0, 12);
SetIndexBuffer(0, drawBuffer);
SetIndexStyle(1, 12);
SetIndexBuffer(1, drawBuffer2);
SetIndexStyle(2, DRAW_HISTOGRAM, 1,3);
SetIndexBuffer(2, drawBuffer3);

return(0);
}
int deinit()
{
return(0);
}
int start()
{
l_resolution = MathAbs(l_resolution);
int i,x,counted_bars=IndicatorCounted();
i=Bars-counted_bars-1;
while(i>=0){
double allCloses = iClose(NULL,minutes,i-(10*v_resolution)) + iClose(NULL,minutes,i-(1*v_resolution)) + iClose(NULL,minutes,i-(2*v_resolution)) + iClose(NULL,minutes,i-(3*v_resolution)) + iClose(NULL,minutes,i-(4*v_resolution)) + iClose(NULL,minutes,i-(5*v_resolution)) + iClose(NULL,minutes,i-(6*v_resolution)) + iClose(NULL,minutes,i-(7*v_resolution)) + iClose(NULL,minutes,i-(8*v_resolution))+ iClose(NULL,minutes,i-(9*v_resolution));
double allOpens = iOpen(NULL,minutes,i-(10*v_resolution)) + iOpen(NULL,minutes,i-(1*v_resolution)) + iOpen(NULL,minutes,i-(2*v_resolution)) + iOpen(NULL,minutes,i-(3*v_resolution)) + iOpen(NULL,minutes,i-(4*v_resolution)) + iOpen(NULL,minutes,i-(5*v_resolution)) + iOpen(NULL,minutes,i-(6*v_resolution)) + iOpen(NULL,minutes,i-(7*v_resolution)) + iOpen(NULL,minutes,i-(8*v_resolution))+ iOpen(NULL,minutes,i-(9*v_resolution));
double allrange = allCloses - allOpens;
double v1 = allrange;
drawBuffer[i] = v1;
double v1a = drawBuffer[i+(1*l_resolution)]+drawBuffer[i+(2*l_resolution)]+drawBuffer[i+(3*l_resolution)]+drawBuffer[i+(4*l_resolution)]+drawBuffer[i+(5*l_resolution)] + drawBuffer[i+(6*l_resolution)]+drawBuffer[i+(7*l_resolution)]+drawBuffer[i+(8*l_resolution)]+drawBuffer[i+(9*l_resolution)]+drawBuffer[i+(10*l_resolution)];
double v1b = (v1a)/10;
drawBuffer2[i] = v1b;
double bDiff = (v1 - v1b);
drawBuffer3[i]=bDiff*5;
i--;

}

return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #322 (permalink)  
Old 08-26-2007, 10:07 PM
Member
 
Join Date: Mar 2006
Posts: 49
master001 is on a distinguished road
Check order closed by TP or SL

hello

How to check if the order was closed by TP OR SL ?


master001
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #323 (permalink)  
Old 08-27-2007, 03:48 AM
1Dave7's Avatar
Member
 
Join Date: Aug 2007
Posts: 82
1Dave7 is on a distinguished road
Smile Help in Coding!

PHP Code:
int kvOrders;

vOrders OrdersTotal();
//{
double Profit  0
double PipsProfit  0;

  for (
k=vOrders-1;k>=0;k--) 
{
  if (
OrderSelect(kSELECT_BY_POSMODE_TRADES)) 
{
  if (
OrderSymbol()==Symbol() && ((OrderMagicNumber () == Reference) || MagicNumber==0)) 
{
  if (
OrderType() == OP_BUYPipsProfit+ == ((Bid OrderOpenPrice())/Point);

    
Profit+= OrderProfit();
 

  else if (
OrderType() == OP_SELLPipsProfit+ = ((OrderOpenPrice() - Ask)/Point);
{
   
    
//Profit += OrderProfit(); 
   
}
   }
   }
   } 

Someone gave me this coding in the past and I tried to work with it. It gives me errors dealing with the ' + ' after PipsProfit. Can someone debug this for me please! With sincere appreciation in advance for your assistance.

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #324 (permalink)  
Old 08-27-2007, 04:06 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
PHP Code:
if (OrderType() == OP_BUYPipsProfit+ == ((Bid OrderOpenPrice())/Point); 
The + after PipsProfit shouldn't be there at all. It is being used in a comparison NOT an incremental function. You're ASKING does PipsProfit equal Bid - etc etc ?

Try this...

PHP Code:
if ((OrderType() == OP_BUY)  && (PipsProfit == (Bid OrderOpenPrice())/Point)){
  
// do something IF the above two conditions are TRUE...

Good Luck

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This

Last edited by luxinterior; 08-27-2007 at 04:12 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #325 (permalink)  
Old 08-27-2007, 05:04 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
The problem is that there is no space between PipsProfit and '+' and a space between '=' and '+' ...... - in other words it should be like this ->

Code:
else if (OrderType() == OP_SELL) PipsProfit += ((OrderOpenPrice() - Ask)/Point); 
{
You also should include the second 'Profit += OrderProfit();' in the code (remove those '//')
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #326 (permalink)  
Old 08-27-2007, 07:54 AM
Senior Member
 
Join Date: Dec 2005
Posts: 157
confusedxx is on a distinguished road
Coding Question

I know an EA can be coded to only trade Demo accounts. Can I also code an EA NOT to trade on PAMM accounts? This would allow the EA to trade on live accounts, but not be used for money managers to trade PAMM accounts - unless there was a separate license agreement.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #327 (permalink)  
Old 08-27-2007, 10:01 AM
Junior Member
 
Join Date: Oct 2006
Posts: 23
Jagg is on a distinguished road
comma separated extern variable(s)

Hi,

for an indicator I use I have to set the digits for each symbol. I do this in the code with e.g.
PHP Code:
if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" ....and so onnDigits 2
Now I like to spin these symbols off to an extern variable so that the user can set his symbols for himself. I thought to add sth. like
PHP Code:
extern string Symbols_nDigits2 "GBPJPY,EURJPY,USDJPY"
How can I use this comma separated list of symbols and split it out so I can use it again in the indicator code like shown above (if(Symbol()=="GBPJPY"....)?

(Or is there a better solution for this "digits problem" out there?)

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #328 (permalink)  
Old 08-27-2007, 10:30 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
PHP Code:
MarketInfoSymbol(), MODE_DIGITS 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #329 (permalink)  
Old 08-27-2007, 11:21 AM
Junior Member
 
Join Date: Oct 2006
Posts: 23
Jagg is on a distinguished road
perfect, thx!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #330 (permalink)  
Old 08-27-2007, 05:20 PM
1Dave7's Avatar
Member
 
Join Date: Aug 2007
Posts: 82
1Dave7 is on a distinguished road
Smile

Got it working thanks to both of you. Really appreciate it!

Dave
<><<<
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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 08:52 AM.



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