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
  #1301 (permalink)  
Old 09-12-2008, 03:34 PM
Junior Member
 
Join Date: Aug 2008
Posts: 5
xerof123 is on a distinguished road
Thanks omelette,

I've tried everything I can, I've been at it now for 6 days non stop and it has beaten me...

Please can you look at the code here and tell me why I'm getting the wretched "OrderModify error 1".

I've tried normalizing, I've tried different logic, heck I even tried offering it a beer.

i really appreciate your help. Thanks

Quote:
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType()<=OP_SELL) ordtotal++;
if(OrderType()==OP_BUY)
{
if(bep==true && Bid-OrderOpenPrice()>=Locked_at*Point)
{
if(OrderModify(OrderTicket(),0,OrderOpenPrice()+7* Point,0,0,0)==true) bep=false;
return(0);
}
if((NormalizeDouble( Bid, Digits)-OrderOpenPrice())>=TS_start*Point)
{
if((NormalizeDouble( Bid, Digits)-NormalizeDouble( OrderStopLoss(), Digits)) > TS_start*Point &&
(NormalizeDouble( Bid, Digits)-NormalizeDouble( OrderStopLoss(), Digits) - TS_start*Point)>=(TrailEvery-1)*Point)
{
if (TS_start > OrderStopLoss()+Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(), Ask - Point*TS_start ,0,0,SkyBlue);
return(0);
}
}
}
}
if(OrderType()==OP_SELL)
{
if(bep==true && OrderOpenPrice()-NormalizeDouble( Ask, Digits) >= Locked_at*Point)
{
if(OrderModify(OrderTicket(),0,OrderOpenPrice()-7*Point,0,0,0)==true) bep=false;
return(0);
}
if((OrderOpenPrice()-NormalizeDouble( Ask, Digits)) >= TS_start*Point)
{
if((NormalizeDouble( OrderStopLoss(), Digits)-NormalizeDouble( Ask, Digits)) > TS_start*Point &&
(NormalizeDouble( OrderStopLoss(), Digits)-NormalizeDouble( Ask, Digits)-TS_start*Point)>=(TrailEvery-1)*Point)
{
if (TS_start > OrderStopLoss() +Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(), Ask + Point*TS_start ,0,0,Orange);
return(0);
}
}
}
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1302 (permalink)  
Old 09-12-2008, 06:28 PM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by Dave137 View Post
SetIndexStyle(0,DRAW_ARROW,0,star_size,color Color1);
SetIndexStyle(1,DRAW_ARROW,0,star_size,color Color2);

I tried inserting color all over the place, one step and trial at a time, and either I get an error for the above two statements - ')' - comma or semicolon expected or no error, but then everything shows black.

This really confuses me - Any more suggestions??

Dave
No you make the wrong changes.

You must change this:

string Color1;
string Color2;

By this:

color Color1;
color Color2;

That's all.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1303 (permalink)  
Old 09-12-2008, 06:33 PM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 690
increase is on a distinguished road
How can I get this indicator to alert when candle touches top or bottom line and slope changes from up to down or vice versa?

#property copyright "ANG3110@latchess.com"
//----------------------------------
#property indicator_chart_window
//----------------------------------
extern int Hours=24;
extern color col=Aqua;
//------------------
double lr,lr0,lrp;
double sx,sy,sxy,sx2,aa,bb;
int p,sName,fs;
int f,f0,f1;
double dh,dl,dh_1,dl_1,dh_2,dl_2;
int ai_1,ai_2,bi_1,bi_2;
double hai,lai,dhi,dli,dhm,dlm,ha0,hap,la0,lap;
double price_p1,price_p0,price_p2,price_01,price_00,price _02;
int p1,p0,p2,fp;
//*****************************************
int init() {
p=Hours*60/Period();
if (fs==0) {sName=CurTime(); fs=1;}
return(0);}
//*******************************
int deinit() {
ObjectDelete("1"+sName);
ObjectDelete("0"+sName);
ObjectDelete("2"+sName); }
//*******************************
int start() {
int i,n;
//------------------------------------------------------------------------------
if (f==1) {
p1=iBarShift(Symbol(),Period(),ObjectGet("1"+sName ,OBJPROP_TIME1));
p0=iBarShift(Symbol(),Period(),ObjectGet("0"+sName ,OBJPROP_TIME1));
p2=iBarShift(Symbol(),Period(),ObjectGet("2"+sName ,OBJPROP_TIME1));
if (fp==0 && p!=p1) {p=p1; fp=1;}
if (fp==0 && p!=p0) {p=p0; fp=1;}
if (fp==0 && p!=p2) {p=p2; fp=1;}
}
//================================================== ==
sx=0; sy=0; sxy=0; sx2=0;
for (n=0; n<=p; n++) {sx+=n; sy+=Close[n]; sxy+=n*Close[n]; sx2+=MathPow(n,2);}
aa=(sx*sy-(p+1)*sxy)/(MathPow(sx,2)-(p+1)*sx2); bb=(sy-aa*sx)/(p+1);
//----------------------------------------------------
for (i=0; i<=p; i++) {
lr=bb+aa*i;
dh=High[i]-lr; dl=Low[i]-lr;
//----------------------------------------------------
if (i<p/2) {if (i==0) {dh_1=0.0; dl_1=0.0; ai_1=i; bi_1=i;}
if (dh>=dh_1) {dh_1=dh; ai_1=i;}
if (dl<=dl_1) {dl_1=dl; bi_1=i;}}
//----------------------------------------------------
if (i>=p/2) {if (i==p/2) {dh_2=0.0; dl_2=0.0; ai_2=i; bi_2=i;}
if (dh>=dh_2) {dh_2=dh; ai_2=i;}
if (dl<=dl_2) {dl_2=dl; bi_2=i;}}}
//-------------------------------------
lr0=bb; lrp=bb+aa*(i+p);
//================================================== =
if (MathAbs(ai_1-ai_2)>MathAbs(bi_1-bi_2)) f=1;
if (MathAbs(ai_1-ai_2)<MathAbs(bi_1-bi_2)) f=2;
if (MathAbs(ai_1-ai_2)==MathAbs(bi_1-bi_2)) {if (MathAbs(dh_1-dh_2)<MathAbs(dl_1-dl_2)) f=1; if (MathAbs(dh_1-dh_2)>=MathAbs(dl_1-dl_2)) f=2;}
//=================================================
if (f==1) {
for (n=0; n<=20; n++) { f1=0;
for (i=0; i<=p; i++) {hai=High[ai_1]*(i-ai_2)/(ai_1-ai_2)+High[ai_2]*(i-ai_1)/(ai_2-ai_1);
if (i==0 || i==p/2) dhm=0.0;
if (High[i]-hai>dhm && i<p/2) {ai_1=i; f1=1;}
if (High[i]-hai>dhm && i>=p/2) {ai_2=i; f1=1;} }
if (f==0) break;}
//----------------------------
for (i=0; i<=p; i++) {hai=High[ai_1]*(i-ai_2)/(ai_1-ai_2)+High[ai_2]*(i-ai_1)/(ai_2-ai_1);
dli=Low[i]-hai;
if (i==0) dlm=0.0; if (dli<dlm) dlm=dli;}
ha0=High[ai_1]*(0-ai_2)/(ai_1-ai_2)+High[ai_2]*(0-ai_1)/(ai_2-ai_1);
hap=High[ai_1]*(p-ai_2)/(ai_1-ai_2)+High[ai_2]*(p-ai_1)/(ai_2-ai_1);
//----------------------------
price_p1=hap;
price_p0=hap+dlm/2;
price_p2=hap+dlm;
price_01=ha0;
price_00=ha0+dlm/2;
price_02=ha0+dlm;
}
//=================================================
if (f==2) {
for (n=0; n<=20; n++) { f1=0;
for (i=0; i<=p; i++) {lai=Low[bi_1]*(i-bi_2)/(bi_1-bi_2)+Low[bi_2]*(i-bi_1)/(bi_2-bi_1);
if (i==0 || i==p/2) dlm=0.0;
if (Low[i]-lai<dlm && i<p/2) {bi_1=i; f1=1;}
if (Low[i]-lai<dlm && i>=p/2) {bi_2=i; f1=1;}}
if (f==0) break;}
//----------------------------
for (i=0; i<=p; i++) {lai=Low[bi_1]*(i-bi_2)/(bi_1-bi_2)+Low[bi_2]*(i-bi_1)/(bi_2-bi_1);
dhi=High[i]-lai;
if (i==0) dhm=0.0; if (dhi>dhm) dhm=dhi;}
la0=Low[bi_1]*(0-bi_2)/(bi_1-bi_2)+Low[bi_2]*(0-bi_1)/(bi_2-bi_1);
lap=Low[bi_1]*(p-bi_2)/(bi_1-bi_2)+Low[bi_2]*(p-bi_1)/(bi_2-bi_1);
//----------------------------------------------------------------
price_p1=lap;
price_p0=lap+dhm/2;
price_p2=lap+dhm;
price_01=la0;
price_00=la0+dhm/2;
price_02=la0+dhm;
}
//================================================== =================================
ObjectCreate("1"+sName,2, 0,Time[p],price_p1,Time[0],price_01);
ObjectCreate("0"+sName,2, 0,Time[p],price_p0,Time[0],price_00);
ObjectCreate("2"+sName,2, 0,Time[p],price_p2,Time[0],price_02);
//-----------------------------------------------------------------
ObjectSet("1"+sName,OBJPROP_COLOR,col);
ObjectSet("1"+sName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("0"+sName,OBJPROP_COLOR,col);
ObjectSet("0"+sName,OBJPROP_STYLE,STYLE_DOT);
ObjectSet("2"+sName,OBJPROP_COLOR,col);
ObjectSet("2"+sName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("0"+sName,OBJPROP_WIDTH,1); // control the width of the line
ObjectSet("1"+sName,OBJPROP_WIDTH,2);
ObjectSet("2"+sName,OBJPROP_WIDTH,2);
//---------------------------------------------
ObjectSet("1"+sName,OBJPROP_TIME1,Time[p]);
ObjectSet("1"+sName,OBJPROP_PRICE1,price_p1);
ObjectSet("1"+sName,OBJPROP_TIME2,Time[0]);
ObjectSet("1"+sName,OBJPROP_PRICE2,price_01);
ObjectSet("0"+sName,OBJPROP_TIME1,Time[p]);
ObjectSet("0"+sName,OBJPROP_PRICE1,price_p0);
ObjectSet("0"+sName,OBJPROP_TIME2,Time[0]);
ObjectSet("0"+sName,OBJPROP_PRICE2,price_00);
ObjectSet("2"+sName,OBJPROP_TIME1,Time[p]);
ObjectSet("2"+sName,OBJPROP_PRICE1,price_p2);
ObjectSet("2"+sName,OBJPROP_TIME2,Time[0]);
ObjectSet("2"+sName,OBJPROP_PRICE2,price_02);
//================================================== ================
f=1; p1=p; p0=p; p2=p; fp=0;
//************************************************** ***********************************
return(0);}
//================================================== ===================================
__________________
Free Forex Signals: Click Here
Get my Hot Forex System: Click Here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1304 (permalink)  
Old 09-12-2008, 07:40 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by xerof123 View Post
Thanks omelette,

I've tried everything I can, I've been at it now for 6 days non stop and it has beaten me...

Please can you look at the code here and tell me why I'm getting the wretched "OrderModify error 1".

I've tried normalizing, I've tried different logic, heck I even tried offering it a beer.

i really appreciate your help. Thanks
Read again what I wrote - you are calling the Modify() function without first checking to see if price(s) need to be modified...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1305 (permalink)  
Old 09-13-2008, 03:04 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
omelette has answered your question very well. I must say the guy has the patience of a saint, I commend him.

Hopefully to better illustrate the point he's making what about this.

What you are basically saying now is if 2 > 1 Then modify (change) X=2 but the problem you're having is that X is already equal to 2 so asking to modify (change) it is incorrect as it's already equal to what you're trying to modify it to.

You just need to check that it's not equal to what you're trying to change it to and only try to modify it if it's not.

Any clearer?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1306 (permalink)  
Old 09-13-2008, 11:09 AM
Junior Member
 
Join Date: Jul 2008
Posts: 1
jzhai1994 is on a distinguished road
first time to use EA, need help.

Dear codersguru,

I copied the .mql4 file to the expert folder and tured the Auto trading allowed on in the Option section, but when I do the back test it generate no trade. I tried a few free EAs on the net, the problem happened every time. I can see back test data was loading in the chart, but no trade, so in the report all figures are 0. I must have been done some thing wrong, hope you can help. Thanks in advance.

Regards,

jzhai1994
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1307 (permalink)  
Old 09-13-2008, 02:01 PM
Junior Member
 
Join Date: Sep 2008
Posts: 4
kk81 is on a distinguished road
can help to write EA for my manual tradinag system...?????????

Thanks...appreciate it....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1308 (permalink)  
Old 09-13-2008, 11:22 PM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
Quote:
Originally Posted by kk81 View Post
can help to write EA for my manual tradinag system...?????????

Thanks...appreciate it....
Your question is a bit vague which will make it difficult for anybody to 'help' you.

If by help you mean you're looking for somebody to code it for you you might be better to look in the commercial section for one of the many talented programmers around here.

If on the other hand you have specific problems in YOUR coding then just ask and somebody will more than likely help you out. If you're looking for a quick intro to programming then check out the link in my signature. It won't make you a coding guru but it'll get you started.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1309 (permalink)  
Old 09-14-2008, 12:19 PM
Junior Member
 
Join Date: Aug 2008
Posts: 5
xerof123 is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
omelette has answered your question very well. I must say the guy has the patience of a saint, I commend him.

Hopefully to better illustrate the point he's making what about this.

What you are basically saying now is if 2 > 1 Then modify (change) X=2 but the problem you're having is that X is already equal to 2 so asking to modify (change) it is incorrect as it's already equal to what you're trying to modify it to.

You just need to check that it's not equal to what you're trying to change it to and only try to modify it if it's not.

Any clearer?

Good luck

Lux
Thanks both of you,

I am just starting to learn MQL4 so any help is really appreciated. And you patience is truely appreciated. Please forgive me if I sound dumb occasionally but as I said I am just starting to learn and I'll try to figure things out as much as I can but sometime a noob needs a hand. So thanks.

Could I say something like: -

Quote:
if (OrderStopLoss())>= TS_start
{
OrderModify(OrderTicket(),OrderOpenPrice(), Ask - Point*TS_start ,0,0,SkyBlue);
return(0);
}
or am I missing the point, Please explain if you don't mind.

Last edited by xerof123; 09-14-2008 at 12:27 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1310 (permalink)  
Old 09-15-2008, 11:34 PM
Sadly's Avatar
Senior Member
 
Join Date: Nov 2006
Posts: 260
Sadly is on a distinguished road
What does the TSD in Forex-TSD stand for?
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:20 AM.



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