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
  #431 (permalink)  
Old 10-21-2007, 11:28 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
The statement:
PHP Code:
double SDL=iCustom(NULL,0,"Slope Direction Line",period,method,price,1,shift); 
makes SDL hold the value of the second buffer (Uptrend) at the given "shift" bar.

(Note that you had a repeated ",1", which looked like a typo. In any case it should't be there)

So, yes, if you want to read off both Uptrend and Dntrend, then you'll need two variables to hold the values. As you say, Uptrend is 1 and Dntrend is 2.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #432 (permalink)  
Old 10-22-2007, 12:06 AM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 362
Beno is on a distinguished road
Gidday ralph

Thanks for the help It's working I can go to sleep now.



Cheers

Beno
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #433 (permalink)  
Old 10-22-2007, 03:20 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
Quote:
Originally Posted by wolfe View Post
Hope this is what you were looking for.
It sent me in the right direction- thanks man, really appreciated.

My new issue is that when my if statement is called....

It goes off the previous indicator bar's value in relation to the current bar, and sends an Alert(); that I created... about 20 times.

How would I go about having it only send the once?

I tried created and on/off switch using variables-- doesn't work in MQL4 unfortunately.

Then I thought about Timers... if there was a timer I could create that only Alerted once over a 20 sec period that would work too....

But I'm a loss as to an idea that would actually be possible in MQL4.

Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #434 (permalink)  
Old 10-22-2007, 04:45 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
In other words... I need some way to stop it from Alerting after the first one, because at the moment it's Alerting multiple times (annoying and unnecessary as you might guess)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #435 (permalink)  
Old 10-22-2007, 05:12 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 723
wolfe is on a distinguished road
Quote:
Originally Posted by dharsant View Post
In other words... I need some way to stop it from Alerting after the first one, because at the moment it's Alerting multiple times (annoying and unnecessary as you might guess)
Could you provide some code to look at?

Maybe you could set up a boolean true/false to be tripped after the alert is sent the first time.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #436 (permalink)  
Old 10-22-2007, 05:31 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
I'm not sure which code would make any sense. Here's my if statement for the alert.

Quote:
Originally Posted by Code
latestlatestmain = 2 bars back in my indicator.
latestmain = previous bar on my indicator

if(MainCCI[i] > ErgoCCI[i]){
{signal = "SHORT";
if ((latestlatestmain >= 0) && (latestmain < 0)) {
PlaySound("alert2.wav");
}
}
if(lastsignal != signal && alertTag!=Time[0]){
alertTag = Time[0];
lastsignal=signal;
}
}
if (MainCCI[i] < ErgoCCI[i]){
{signal = "LONG";
if ((latestlatestmain <= 0) && (latestmain > 0)) {
PlaySound("alert2.wav");
}
This is the FX Sniper indicator, and when it fits my parameters it sends the Alert.

How would I go about setting up a boolean true/false thing?

I tried doing this.....

Quote:
Originally Posted by Code with on/off switch

if(MainCCI[i] > ErgoCCI[i]){
{signal = "SHORT";
if ((latestlatestmain >= 0) && (latestmain < 0)) {
if (onealert == 1) {
PlaySound("alert2.wav");
onealert = 0;
} }
}
if(lastsignal != signal && alertTag!=Time[0]){
alertTag = Time[0];
lastsignal=signal;
}
}
if (MainCCI[i] < ErgoCCI[i]){
{signal = "LONG";
if ((latestlatestmain <= 0) && (latestmain > 0)) {
if (onealert == 0) {
PlaySound("alert2.wav");
onealert = 1;
} }
or some variant of that, to create the on/off with variables.

There's something else I could do using boolean is there? Any ideas on how I can go about doing that?

At the moment it works fine as far as alerting me goes, it just alerts me about 5-6 times.

Appreciate the time and help mate.

-dharsant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #437 (permalink)  
Old 10-22-2007, 06:20 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
Just thought I'd worked it out, and that Sleep(); would work.... darn

Last edited by dharsant; 10-22-2007 at 06:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #438 (permalink)  
Old 10-22-2007, 07:12 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
I found this by Codersguru;

PHP Code:
void AlertOnce(string alert_msgint ref)
{
    if (
ref 10)
        return;
 
  
ref--;
  static 
int LastAlert[10];
 
  if( 
LastAlert[ref] == || LastAlert[ref] < Bars)
  {
       
Alert(alert_msg); 
       
LastAlert[ref] = Bars;
  }

Looks like what I'm after!!

In using this with my indicator...

Would I just place the function in my script, and then use

AlertOnce("Sniper going LONG",10);

in place of my Alert(); ?

I feel like a pesty little inexperienced programmer
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #439 (permalink)  
Old 10-22-2007, 07:34 AM
Junior Member
 
Join Date: Apr 2007
Posts: 13
dharsant is on a distinguished road
Got it, thanks for the help!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #440 (permalink)  
Old 10-22-2007, 05:51 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 362
Beno is on a distinguished road
I can't quite get this right I am trying to get my ea to buy when all blue and sell when all red. The ea open and closes but not in the right place what do I need to look at.


double TML=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shi ft,0,shift);
double TMS=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shi ft,1,shift);
double hasOpen = iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPe riod,MaPeriod2,1,shift) ;
double hasClose = iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPe riod,MaPeriod2,0,shift) ;
double HeikenAshiOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothe d",MaMetod,MaPeriod,MaPeriod2,2,shift);
double HeikenAshiClose=iCustom(NULL,0,"Heiken_Ashi_Smooth ed",MaMetod,MaPeriod,MaPeriod2,3,shift);
double SDLL=iCustom(NULL,0,"Slope Direction Line",period,method,price,1,shift);
double SDLS=iCustom(NULL,0,"Slope Direction Line",period,method,price,2,shift);




buysig=false;
sellsig=false;
closebuy=false;
closesell=false;


bool Long = TML && SDLL && HeikenAshiOpen < HeikenAshiClose && hasOpen < hasClose;
bool Short = TMS && SDLS && HeikenAshiOpen > HeikenAshiClose && hasOpen > hasClose;

buysig = Long;
sellsig = Short;

closebuy=sellsig;
closesell=buysig;
Attached Images
File Type: gif current demo positions.gif (41.7 KB, 162 views)
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 12:17 PM.



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