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 Thread Tools Display Modes
  #371 (permalink)  
Old 10-02-2007, 01:34 AM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
Is this possible to code?

I've been at this 4 weeks and still no clue,
it's roughly this,
if OP_BUY EUR/USD minus OP_SELL USD/CHF equals minus 100 ignore other trades and
close both orders together

I've tried everything loops within loops etc and nothing works

I'm working on money management and am pulling my hair out any help or clue very welcomed.

with thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #372 (permalink)  
Old 10-02-2007, 02:43 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,085
omelette is on a distinguished road
Quote:
Originally Posted by mish View Post
I've been at this 4 weeks and still no clue,
it's roughly this,
if OP_BUY EUR/USD minus OP_SELL USD/CHF equals minus 100 ignore other trades and
close both orders together

I've tried everything loops within loops etc and nothing works

I'm working on money management and am pulling my hair out any help or clue very welcomed.

with thanks
I presume this is a hedge and you are referring to the accrued profit of each, above. You need find what these are using OrderSelect and OrderProfit() functions, then:

if (MathMax(EU_Profit,UC_Profit) + MathMin(EU_Profit,UC_Profit) < -100)
{
OrderClose(EU_Ticket...
OrderClose(EC_Ticket...
}

Hmmm... seems too simple to spend 4 weeks on so you are probably trying to do something else.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #373 (permalink)  
Old 10-02-2007, 02:58 AM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
thankyou omelette

I'm not a programmer just put bits and pieces and hope they work using some logic of course!

Thankyou very much!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #374 (permalink)  
Old 10-02-2007, 10:05 AM
Junior Member
 
Join Date: Oct 2007
Posts: 22
NTrader is on a distinguished road
Logs of an Indicator

Trivial question: I'm writing a new Personal Indicator for the first time. I can't view my logs that I make with the command Print("...") in the start{} method. Where I can view them on MetaTrader 4?

Last edited by NTrader; 10-02-2007 at 07:59 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #375 (permalink)  
Old 10-02-2007, 11:43 PM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
Is this possible to code?

After looking at omelettes answer it's not what I need but certainly thankyou!

The problem:

Using one symbol for simplicity lets choose EUR/USD

If I have multiple BUY && SELL positions

I need to choose only one BUY position and only one SELL position

That together equal a variable of lets say of exactly -100

Every other order is untouched

Which BUY or SELL is irrelevant


The logic behind this is to keep BUY && SELL ratios correct for money management, a kind of stoploss that uses OrderClose() for both BUY && SELL

any help warmly appreciated

and thankyou
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #376 (permalink)  
Old 10-03-2007, 12:46 AM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
Is this possible to code?

I have uploaded my feeble attempts to program relating to my last post, theres are many mistakes of course, it doesn't work!

Thankyou
Attached Files
File Type: txt advice.txt (1.0 KB, 6 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #377 (permalink)  
Old 10-03-2007, 02:18 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
mish

I had a moment of spare time, and made an attempt to capture your intention as I understood it.
Attached Files
File Type: txt adviceRR.txt (1.7 KB, 13 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #378 (permalink)  
Old 10-03-2007, 10:55 PM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
Thankyou

Thankyou ralph.ronnquist

these functions are exactly what I need and would be of use to others after a same function

I was caught up otherwise would have thanked you earlier especially because it took effort

Is there a simple way to change the function to work in strategy tester? I know the results of working with just one currency in the tester is next to useless except it mimics very roughly what I need in order to get the math right, any help is appreciated and I never would have worked the code out in short order so once again thankyou!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #379 (permalink)  
Old 10-04-2007, 01:45 AM
Member
 
Join Date: Sep 2007
Posts: 67
Ronald Raygun is on a distinguished road
DT_ZZ.mq4-based EA

I'm having a little bit of trouble with this one.

I have the DT_ZZ.mq4 indicator and from what I see it's very promising. I do know that this indicator redraws and here's how I see it working.

If an arrow and section are equal, then wait for the bar to close, then buy/sell accordingly.

Anybody think they can help with that? (Code is posted below)

Quote:
//+------------------------------------------------------------------+
//| DT_ZZ.mq4 |
//+------------------------------------------------------------------+

// optimized by Rosh

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
//---- indicator parameters
extern int ExtDepth=12;
extern int calculateLevel=2;
//---- indicator buffers
double zzL[];
double zzH[];
double zz[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_SECTION);
SetIndexStyle(1,DRAW_ARROW);
SetIndexStyle(2,DRAW_ARROW);

SetIndexArrow(1,159);
SetIndexArrow(2,159);

//---- indicator buffers mapping
SetIndexBuffer(0,zz);
SetIndexBuffer(1,zzH);
SetIndexBuffer(2,zzL);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);

//---- indicator short name
IndicatorShortName("DT_ZZ("+ExtDepth+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i,shift,pos,lasthighpos,lastlowpos,curhighpos,curl owpos;
double curlow,curhigh,lasthigh,lastlow;
double min, max;
int counted_bars=IndicatorCounted();
if (counted_bars==0)
{
ArrayInitialize(zz,0.0);
ArrayInitialize(zzL,0.0);
ArrayInitialize(zzH,0.0);

lasthighpos=Bars; lastlowpos=Bars;
lastlow=Low[Bars];lasthigh=High[Bars];
Print("limit=",Bars-ExtDepth);
for(shift=Bars-ExtDepth; shift>=0; shift--)
{
curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift);
curlow=Low[curlowpos];
curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift );
curhigh=High[curhighpos];
//------------------------------------------------
if( curlow>=lastlow ) { lastlow=curlow; }
else
{
//???? ????
if( lasthighpos>curlowpos )
{
zzL[curlowpos]=curlow;
///*
min=100000; pos=lasthighpos;
for(i=lasthighpos; i>=curlowpos; i--)
{
if (zzL[i]==0.0) continue;
if (zzL[i]<min) { min=zzL[i]; pos=i; }
zz[i]=0.0;
}
zz[pos]=min;
//*/
}
lastlowpos=curlowpos;
lastlow=curlow;
}
//--- high
if( curhigh<=lasthigh ) { lasthigh=curhigh;}
else
{
// ???? ?????
if( lastlowpos>curhighpos )
{
zzH[curhighpos]=curhigh;
///*
max=-100000; pos=lastlowpos;
for(i=lastlowpos; i>=curhighpos; i--)
{
if (zzH[i]==0.0) continue;
if (zzH[i]>max) { max=zzH[i]; pos=i; }
zz[i]=0.0;
}
zz[pos]=max;
//*/
}
lasthighpos=curhighpos;
lasthigh=curhigh;
}
zz[0]=Close[0];
}
//----------------------------------------------------------------------
}
else
{
int pos2;
i=0;
while (pos2<calculateLevel && i<Bars-1)
{
if (zz[i]!=0 && (zzH[i]!=0||zzL[i]!=0)) pos2++;
i++;
}
pos2=i-1;
for (i=pos2-1;i>=0;i--)
{
zzH[i]=0;
zzL[i]=0;
zz[i]=0;
}
if (zzH[pos2]!=0)
{
lasthighpos=pos2;
lasthigh=High[pos2];
lastlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,pos2);
lastlow=Low[lastlowpos];
}
else
{
lastlowpos=pos2;
lastlow=Low[pos2];
lasthighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,pos2 );
lasthigh=High[lasthighpos];
}
//------------------------- ????????? ??????
Print("limit=",pos2-1);
for(shift=pos2-1; shift>=0; shift--)
{
curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift);
curlow=Low[curlowpos];
curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift );
curhigh=High[curhighpos];
//------------------------------------------------
if( curlow>=lastlow ) { lastlow=curlow; }
else
{
//???? ????
if( lasthighpos>curlowpos )
{
zzL[curlowpos]=curlow;
///*
min=100000; pos=lasthighpos;
for(i=lasthighpos; i>=curlowpos; i--)
{
if (zzL[i]==0.0) continue;
if (zzL[i]<min) { min=zzL[i]; pos=i; }
zz[i]=0.0;
}
zz[pos]=min;
//*/
}
lastlowpos=curlowpos;
lastlow=curlow;
}
//--- high
if( curhigh<=lasthigh ) { lasthigh=curhigh;}
else
{
// ???? ?????
if( lastlowpos>curhighpos )
{
zzH[curhighpos]=curhigh;
///*
max=-100000; pos=lastlowpos;
for(i=lastlowpos; i>=curhighpos; i--)
{
if (zzH[i]==0.0) continue;
if (zzH[i]>max) { max=zzH[i]; pos=i; }
zz[i]=0.0;
}
zz[pos]=max;
//*/
}
lasthighpos=curhighpos;
lasthigh=curhigh;
}

}
//------------------------- ????????? ??????
zz[0]=Close[0];
}
return(0);
}

//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #380 (permalink)  
Old 10-04-2007, 04:10 AM
Junior Member
 
Join Date: Aug 2007
Posts: 8
mish is on a distinguished road
can this be altered 4 strategy tester?

ralph.ronnquist

has provided me generously a great function that many may benefit from that require it's use.

My problem is because I'm so lousy currently at programming I can't seem to alter it enough 4 strategy tester.

For testing purposes only one currency is satisfactory just to work out the math of trades under different circumstances with different currencies.

Is it possible to change ralph's work to suit this need.

Thankyou
Attached Files
File Type: txt ralph.txt (1.8 KB, 7 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 11:04 PM.



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