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
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-26-2007, 08:28 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
Use GlobalVariableGet() in an indicator

Hi

I try to use the function GlobalVariableSet() in the indicator ,for remove my data type "ok_trade" an use it in an EA with GlobalVariableGet()

But is not working .Where my error ? and How can I use GlobalVariableGet() in the EA


Help please





this is the code of my indicator:

******************INDICATOR 3MACROSS****************************************** *****

// This is Not Tested , Use At Your Own Risk !

//+--------------------------------------------------------------------------+
//| 3 MA Cross w_Alert v2.mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| 3 ma conversion and Alert , David Honeywell , transport.david@gmail.com |
//| MetaTrader_Experts_and_Indicators : MetaTrader_Experts_and_Indicators |
//+--------------------------------------------------------------------------+

/*
+-------------------------------------------------------------------------------+
| Allows you to enter 3 ma periods and it will then show you and alert you at |
| which point the 2 faster ma's "OPEN" are both above or below the Slowest ma . |
+-------------------------------------------------------------------------------+
*/

#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Coral

double CrossUp[];
double CrossDown[];
double prevtime;
double Range, AvgRange;
double fasterMAnow, fasterMAprevious, fasterMAafter;
double mediumMAnow, mediumMAprevious, mediumMAafter;
double slowerMAnow, slowerMAprevious, slowerMAafter;

extern int FasterMA = 5;
extern int FasterShift = -5;
extern int FasterMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int MediumMA = 20;
extern int MediumShift = -5;
extern int MediumMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int SlowerMA = 34;
extern int SlowerShift = 0;
extern int SlowerMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int SoundAlert = 1; // 0 = disabled

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

string ok_trade ="no_trade";


int limit, i, counter;

int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)
{

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

fasterMAnow = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+1);
fasterMAprevious = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+2);
fasterMAafter = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i-1);

mediumMAnow = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+1);
mediumMAprevious = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+2);
mediumMAafter = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i-1);

slowerMAnow = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+1);
slowerMAprevious = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+2);
slowerMAafter = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i-1);

if ((fasterMAnow > slowerMAnow &&
fasterMAprevious <= slowerMAprevious &&
fasterMAafter > slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious <= slowerMAprevious &&
mediumMAafter > slowerMAafter ))
{
CrossUp[i] = Low[i] - Range*0.5;
ok_trade="Long";


}

if ((fasterMAnow < slowerMAnow &&
fasterMAprevious >= slowerMAprevious &&
fasterMAafter < slowerMAafter &&
mediumMAnow < slowerMAnow )
||
(fasterMAnow < slowerMAnow &&
mediumMAnow < slowerMAnow &&
mediumMAprevious >= slowerMAprevious &&
mediumMAafter < slowerMAafter ))
{
CrossDown[i] = High[i] + Range*0.5;
ok_trade="Short";
}

}

if ((CrossUp[0] > 2000) && (CrossDown[0] > 2000)) { prevtime = 0; }

if ((CrossUp[0] == Low[0] - Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Up @ Hour ",Hour()," Minute ",Minute());
}

if ((CrossDown[0] == High[0] + Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Down @ Hour ",Hour()," Minute ",Minute());
}

// Alert(ok_trade);
GlobalVariableSet("ok_trade",0);
return(0);
}


************************************************** ***************



best regards
Attached Files
File Type: mq4 3 MA Cross.mq4 (6.1 KB, 14 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-26-2007, 11:32 PM
project1972's Avatar
Senior Member
 
Join Date: May 2006
Location: Fl, Usa
Posts: 277
project1972 is on a distinguished road
Quote:
Originally Posted by natsirte View Post
Hi

I try to use the function GlobalVariableSet() in the indicator ,for remove my data type "ok_trade" an use it in an EA with GlobalVariableGet()

But is not working .Where my error ? and How can I use GlobalVariableGet() in the EA


Help please
I don't know if your indicator will work but this is the correct way of using global variables.

You will get 1 for longs, 2 for short or 0 not cross


Code:
******************INDICATOR 3MACROSS****************************************** *****

// This is Not Tested , Use At Your Own Risk !

//+--------------------------------------------------------------------------+
//| 3 MA Cross w_Alert v2.mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| 3 ma conversion and Alert , David Honeywell , transport.david@gmail.com |
//| MetaTrader_Experts_and_Indicators : MetaTrader_Experts_and_Indicators |
//+--------------------------------------------------------------------------+

/*
+-------------------------------------------------------------------------------+
| Allows you to enter 3 ma periods and it will then show you and alert you at |
| which point the 2 faster ma's "OPEN" are both above or below the Slowest ma . |
+-------------------------------------------------------------------------------+
*/ 

#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Coral

double CrossUp[];
double CrossDown[];
double prevtime;
double Range, AvgRange;
double fasterMAnow, fasterMAprevious, fasterMAafter;
double mediumMAnow, mediumMAprevious, mediumMAafter;
double slowerMAnow, slowerMAprevious, slowerMAafter;

extern int FasterMA = 5;
extern int FasterShift = -5;
extern int FasterMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int MediumMA = 20;
extern int MediumShift = -5;
extern int MediumMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int SlowerMA = 34;
extern int SlowerShift = 0;
extern int SlowerMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma

extern int SoundAlert = 1; // 0 = disabled

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- 

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

string ok_trade;
int Direction=0;


int limit, i, counter;

int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)
{

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

fasterMAnow = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+1);
fasterMAprevious = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+2);
fasterMAafter = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i-1);

mediumMAnow = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+1);
mediumMAprevious = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+2);
mediumMAafter = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i-1);

slowerMAnow = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+1);
slowerMAprevious = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+2);
slowerMAafter = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i-1);

if ((fasterMAnow > slowerMAnow &&
fasterMAprevious <= slowerMAprevious &&
fasterMAafter > slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious <= slowerMAprevious &&
mediumMAafter > slowerMAafter ))
{
CrossUp[i] = Low[i] - Range*0.5;
Direction=1;


}

if ((fasterMAnow < slowerMAnow &&
fasterMAprevious >= slowerMAprevious &&
fasterMAafter < slowerMAafter &&
mediumMAnow < slowerMAnow )
||
(fasterMAnow < slowerMAnow &&
mediumMAnow < slowerMAnow &&
mediumMAprevious >= slowerMAprevious &&
mediumMAafter < slowerMAafter ))
{
CrossDown[i] = High[i] + Range*0.5;
Direction=2;
}

}

if ((CrossUp[0] > 2000) && (CrossDown[0] > 2000)) { prevtime = 0; }

if ((CrossUp[0] == Low[0] - Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Up @ Hour ",Hour()," Minute ",Minute());
}

if ((CrossDown[0] == High[0] + Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Down @ Hour ",Hour()," Minute ",Minute());
}

// Alert(ok_trade);
GlobalVariableSet(ok_trade,Direction);
return(0);
}
__________________
I have not failed. I've just found 10,000 ways that won't work.
Thomas Alva Edison
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-26-2007, 11:53 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
Great thank to you

I'm gonna try it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-27-2007, 01:07 AM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
Hi

in my EA I try to put

double var_global = GlobalVariableGet(ok_trade,Direction) ; // or
GlobalVariableGet(ok_trade) but I have the message that the variable not defined.

Why?

best regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-27-2007, 01:15 AM
project1972's Avatar
Senior Member
 
Join Date: May 2006
Location: Fl, Usa
Posts: 277
project1972 is on a distinguished road
Quote:
Originally Posted by natsirte View Post
Hi

in my EA I try to put

double var_global = GlobalVariableGet(ok_trade,Direction) ; // or
GlobalVariableGet(ok_trade) but I have the message that the variable not defined.

Why?

best regards
Use something like this.

string ok_trade;
int direction;

direction=GlobalVariableGet(ok_trade);
__________________
I have not failed. I've just found 10,000 ways that won't work.
Thomas Alva Edison
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-27-2007, 01:25 AM
project1972's Avatar
Senior Member
 
Join Date: May 2006
Location: Fl, Usa
Posts: 277
project1972 is on a distinguished road
Quote:
Originally Posted by project1972 View Post
Use something like this.

string ok_trade;
int direction;

direction=GlobalVariableGet(ok_trade);

Also in the init section you shold set the global variable if it was not set by the indicator before the EA try to read it.

void init()
{
if (!GlobalVariableCheck(ok_trade)) GlobalVariableSet(ok_trade,0);
return(0);
}

and in the start function you can read it without errors

direction=GlobalVariableGet(ok_trade);
__________________
I have not failed. I've just found 10,000 ways that won't work.
Thomas Alva Edison
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-27-2007, 01:56 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
Hi evrybody and thanks for your help


When I try to put

************
void init()
{
if (!GlobalVariableCheck(ok_trade)) GlobalVariableSet(ok_trade,0);
return(0);
}
************

in my EA it returns me :
init already definted and as a different type ; so I put only the condition "if (!GlobalVariableCheck(ok_trade)) GlobalVariableSet(ok_trade,0);
return(0);" in the init{...} ; and it returns me "ok_trade" is not defined;

So I set ok_trade and direction in my EA like this :

string ok_trade;
int direction;

But when I look into to my Alert ; Alert(direction);the result is always O

Help Please!!
This is my indicator and my EA

Thanks


*************MY EA EA_GLOBAL**********************

#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool UseStopLoss = True;
extern int StopLoss = 30;
extern bool UseTakeProfit = True;
extern int TakeProfit = 60;
extern bool UseTrailingStop = True;
extern int TrailingStop = 30;

int BarCount;
int Current;
bool TickCheck = False;
string ok_trade;
int direction;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {

BarCount = Bars;

if (!GlobalVariableCheck(ok_trade)) GlobalVariableSet(ok_trade,0);
return(0);

if (EachTickMode) Current = 0; else Current = 1;

return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;

direction=GlobalVariableGet(ok_trade);
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;

//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+

double Buy1_1 = iMA(NULL, 0, 14, 0, MODE_SMA, PRICE_CLOSE, Current + 0);
double Buy1_2 = iMA(NULL, 0, 14, 0, MODE_SMA, PRICE_CLOSE, Current + 1);
double Sell1_1 = iMA(NULL, 0, 14, 0, MODE_SMA, PRICE_CLOSE, Current + 0);
double Sell1_2 = iMA(NULL, 0, 14, 0, MODE_SMA, PRICE_CLOSE, Current + 1);


//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+

//Check position
bool IsTrade = False;

for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+



//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+



//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+

if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}


Alert(direction);

//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+

if (Buy1_1 > Buy1_2 && Buy1_2>150) Order = SIGNAL_BUY;

if (Sell1_1 < Sell1_2 && Sell1_2<-150) Order = SIGNAL_SELL;


//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+

//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

//Sell
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

if (!EachTickMode) BarCount = Bars;

return(0);
}
//+------------------------------------------------------------------+


*************************************
Attached Files
File Type: mq4 3 MA Cross_GLOBAL.mq4 (5.0 KB, 9 views)
File Type: mq4 EA_GLOBAL.mq4 (9.5 KB, 7 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-29-2007, 10:34 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
Hi everybody



This is the correction. (Thanks to Jerome M !)

Take the indicator 3MACROSS and add in the EA this :


//*******
int start()

{



int recovering_direction = GlobalVariableGet("ok_trade");
}

//***************



// But now I saw that the Indicator is wrong because Order=SiGNAL_BUY never work!!

if (recovering_direction == 1 ) { Order = SIGNAL_BUY; }
if (recovering_direction == 2) { Order = SIGNAL_SELL; }



and if I do that :

if (recovering_direction == 2 ) { Order = SIGNAL_BUY; }
if (recovering_direction == 1) { Order = SIGNAL_SELL; }



Order = SIGNAL_SELL never work!!

Why?????



best regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-29-2007, 10:35 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
natsirte is on a distinguished road
The indicator
Attached Files
File Type: mq4 3MACross.mq4 (5.0 KB, 6 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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/10919-use-globalvariableget-indicator.html
Posted By For Type Date
Use GlobalVariableGet() in an indicator - Forex Trading This thread Refback 11-28-2007 01:11 AM


All times are GMT. The time now is 06:27 AM.



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