Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum FAQ Members List Calendar Mark Forums Read


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

 
 
LinkBack Thread Tools
 
Old 11-08-2005, 05:51 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Unhappy Static variable problem - Please help

Hi

I am trying trouble with the following piece of code.

..
static double firstbuysl, firstsellsl, firstbuyprice, firstsellprice;
static double mylasttradeprice = 0;
double sarCurrent, sarPrevious, momCurrent, momPrevious,x,y,t;
...
x = mylasttradeprice - (Bid + Ask)/2;
y = MathAbs(x);
t= (trailingStop/2)*Point;
if(y>t) { ....
/* determine how to trade */
..

if trailingstop = 30 then when the EA starts, I thought y would be greater then t and I would enter the section to 'determine how to trade' - but its not working.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 11-08-2005, 06:15 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow mylasttradeprice ??

Quote:
Originally Posted by cardio
Hi

I am trying trouble with the following piece of code.

..
static double firstbuysl, firstsellsl, firstbuyprice, firstsellprice;
static double mylasttradeprice = 0;
double sarCurrent, sarPrevious, momCurrent, momPrevious,x,y,t;
...
x = mylasttradeprice - (Bid + Ask)/2;
y = MathAbs(x);
t= (trailingStop/2)*Point;
if(y>t) { ....
/* determine how to trade */
..

if trailingstop = 30 then when the EA starts, I thought y would be greater then t and I would enter the section to 'determine how to trade' - but its not working.
Hi cardio,

I've tested your code and found (y>t) evaluated to true (y is greater than t). So, you have to enter the section of 'determine how to trade'.

I used this code which will Alert 1 (true) if y>t and 0 (false) otherwise:

Code:
static double firstbuysl, firstsellsl, firstbuyprice, firstsellprice;
static double mylasttradeprice = 0;
double sarCurrent, sarPrevious, momCurrent, momPrevious,x,y,t;

dobule trailingStop = 30; //I declared it here for testing

x = mylasttradeprice - (Bid + Ask)/2;
y = MathAbs(x);
t= (trailingStop/2)*Point;
 
Alert(y>t); //true
I just want to know how do you set the mylasttradeprice ?
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 11-09-2005, 11:45 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
thanks Coders' Guru

Thanks

I put the EA that uses this up at

http://www.forex-tsd.com/showthread.php?p=1698#post1698

it is serously not working - I don't quite know what is wrong - I will keep working on it.


Thanks

Last edited by cardio : 11-09-2005 at 06:05 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB 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
Bollinger Static MA thesource Indicators - Metatrader 4 12 03-08-2007 06:01 AM
how to define a static var in MT3.86 lamanosky Indicators - Metatrader 3 0 11-18-2006 12:43 PM
Variable Stoploss gkozlyk Expert Advisors - Metatrader 4 2 06-06-2006 12:34 PM


All times are GMT. The time now is 05:19 PM.