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
  #991 (permalink)  
Old 02-24-2008, 07:08 PM
Junior Member
 
Join Date: Jan 2008
Posts: 24
SimonF is on a distinguished road
Quote:
Originally Posted by Big Be View Post
WHEN do you want to use a STATIC variable - what problems can it solve?

WHEN do you want to put something in the INIT() section - what problems does it solve?

Big Be
A static variable will remain the same with every function call that that variable is in, unless it's changed in the function of course. You may want an integer in that function only that you want to increase by 1 for example every function call.

But, you could aswell use global variables for this.

Example of init:

int init() {
TakeProfit=TakeProfit*Point;
StopLoss=StopLoss*Point;
TrailingStop=TrailingStop*Point;
breakEven=breakEven*Point;

return(0);
}

These are extern variables and you set takeprofit to 50 for example if you want 50 pips. But for this to work in the EA it must be multiplicated with the pip value of the currency 0.001 for example.
__________________
boo

Last edited by SimonF; 02-24-2008 at 07:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #992 (permalink)  
Old 02-24-2008, 08:15 PM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
re: Coding Knowledge Questions

Quote:
Originally Posted by SimonF View Post
A static variable will remain the same with every function call that that variable is in, unless it's changed in the function of course. You may want an integer in that function only that you want to increase by 1 for example every function call.

But, you could aswell use global variables for this.
...
Simon-
Thanks. Please help make it clear:

Does this mean a static variable holds the last value assigned to it even though it is not global?

Regarding init(), it looks like it is used as a setup function.
- Can you tell me other good examples for it?

- Do you have to follow it with deinit()?

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #993 (permalink)  
Old 02-26-2008, 12:06 PM
Junior Member
 
Join Date: Dec 2006
Posts: 2
sodipo200 is on a distinguished road
Ask

Quote:
Originally Posted by codersguru View Post
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.
Hello,
I want to learn mql directly from you i have read your tutorial and i have been coding couple of EA.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #994 (permalink)  
Old 02-28-2008, 07:22 AM
Junior Member
 
Join Date: Oct 2007
Posts: 14
yappe is on a distinguished road
ma color based on closing

HI,

is there any ma indicator that color change according to the close of the candle.For example if the candle close above SMA then the line color is blue but if below MA then the color will change to red.
I know there is a indicator that has called "ma_in_color.mq4" sorry but i don't know how to post it, my question is, of there is anybody out there, who could program an sound alert in this indicator.

thx a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #995 (permalink)  
Old 02-29-2008, 05:02 AM
Senior Member
 
Join Date: Oct 2007
Posts: 224
Dave137 is on a distinguished road
Question

What is the easiest way to get the buffer values of an indicator to either display as a comment or print out in the experts folder so I can see the values change?? I have 8 buffers in this indicator.

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #996 (permalink)  
Old 02-29-2008, 05:04 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
ctrl-D .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #997 (permalink)  
Old 02-29-2008, 05:32 AM
Senior Member
 
Join Date: Oct 2007
Posts: 224
Dave137 is on a distinguished road
Smile

Thanks!

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #998 (permalink)  
Old 03-01-2008, 04:57 PM
Junior Member
 
Join Date: Jan 2008
Posts: 24
SimonF is on a distinguished road
Quote:
Originally Posted by Big Be View Post
Does this mean a static variable holds the last value assigned to it even though it is not global?
Yes, but it can be used inside of that function only. You can have global variables with the same name as the static variable (I'm 99% sure), but it's good use not too, so you don't mix things up.

The other questions someone else might want to answer as I'm not sure.
__________________
boo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #999 (permalink)  
Old 03-02-2008, 09:46 PM
Junior Member
 
Join Date: Aug 2007
Posts: 8
dan5767 is on a distinguished road
Limit orders per bar

Hi I have a quick question. Im trying to code an EA where I will only be able to open one trade per bar. So when I use the 1H timeframe I can only open one order. I tried to add this line to limit the amount of orders, but it does not work.

TimeCurrent()-OrderCloseTime()>60*60

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1000 (permalink)  
Old 03-04-2008, 12:04 PM
Junior Member
 
Join Date: Feb 2008
Posts: 4
danielp is on a distinguished road
How to change alert into trading EA

Hi Guys,
How do you change an alert indicator into a trading EA?
I've tried changing the command Alert(Symbol()+" "+Period()+" XO Long ",Bid); into OrderSend(Symbol(),OP_BUY,0.01,Ask,3,20,20,"XO-CCI",1,0,Blue); at the start I chose menu to make EA, then content of my alert indicator, i copied to this EA, then I changed the command alert to trading command as above, then i compiled. But the compiled EA is not making any trade after i tried it on 1M chart for a day.

Please help.
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:19 AM.



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