Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #561 (permalink)  
Old 12-12-2007, 11:45 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
Are you sure? Have you "compressed" the price scale to make sure it doesn't draw outside the current window?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #562 (permalink)  
Old 12-12-2007, 11:56 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by nondisclosure007 View Post
I'm trying to figure out what is wrong here. I wrote this little indicator as to try and find out why I can't seem to draw arrows on every single bar in a chart. No good reason to.

I have another indicator that i'm working on that'll be discreet on choosing which one, i wrote this to try and figure out what the darn problem is.

It only draws an arrow on the bottom of the candle for the last few bars. It should draw arrown on every single bar in the chart on the top and bottom of each candle.

And only 1 candle's data is showing up in the data windows.

I've included a pic and the indicator. any help would be appreciated.
Attachment 49299
You have to declare the two buffers : #property indicator_buffers 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #563 (permalink)  
Old 12-13-2007, 12:15 AM
nondisclosure007's Avatar
Senior Member
 
Join Date: Apr 2007
Posts: 124
nondisclosure007 is on a distinguished road
Quote:
Originally Posted by Michel View Post
You have to declare the two buffers : #property indicator_buffers 2

wow. can't believe i missed that.

now they're showing up on every candle. i've even put in a simple compare to an ima to see if i can dictate which one. that works too. now all i have to do is look at my original indicator that's giving me the problem and compare the 2.

thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #564 (permalink)  
Old 12-13-2007, 12:16 AM
nondisclosure007's Avatar
Senior Member
 
Join Date: Apr 2007
Posts: 124
nondisclosure007 is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
Are you sure? Have you "compressed" the price scale to make sure it doesn't draw outside the current window?
you were right. they were there, just waaaaay off. i changed the formula of where to put the arrow. now they all show up.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #565 (permalink)  
Old 12-13-2007, 07:55 AM
Member
 
Join Date: Oct 2006
Posts: 59
Jovager is on a distinguished road
MACD stoploss

I want to stoploss on MACD.

I have this code :

double Mach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,Tr adeBar);
double vMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,T radeBar+1);
double vvMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN, TradeBar+2);

GlobalVariableSet("mt_Vager1"+Symbol()+Period(),mt r);
GlobalVariableSet("l_Vager1"+Symbol()+Period(),TP_ SL_Inc);



if (TotalOrders(Magic_Number)>0){
bool g=false;
while (!g){
g=true;
for (int kli=OrdersTotal()-1;kli>=0;kli--){
OrderSelect(kli,SELECT_BY_POS);
if

(OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY && Mach<vMach && vMach<vvMach)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Bid,Digits),Slippage,Pink);
g=false;
break;
}
if (OrderMag
icNumber()==Magic_Number && OrderType()==OP_SELL && m1>m2 && m11<=m21)
(OrderMagicNumber()==Magic_Number && OrderType()==OP_SELL && Mach>vMach && vMach>vvMach)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Ask,Digits),Slippage,Pink);
g=false;
break;
}
}
}
}

Open works but not stoploss exit.

Thanks for help.

Jo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #566 (permalink)  
Old 12-13-2007, 08:00 AM
Member
 
Join Date: Oct 2006
Posts: 59
Jovager is on a distinguished road
MACD stoploss

Read TradeBar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #567 (permalink)  
Old 12-13-2007, 09:44 AM
Junior Member
 
Join Date: May 2007
Posts: 21
eastcity is on a distinguished road
I thought I could limit the number of alerts triggered by trigger using this:


if(trigger == 1)
{
int StartWaitingTime = GetTickCount();
if(GetTickCount() - StartWaitingTime > MaxWaiting_sec * 1000)
{

if(ShowAlert == true) {

Alert("Buy...........


But it does not seem to work, please help to modify it so it works, thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #568 (permalink)  
Old 12-13-2007, 10:11 AM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 560
MrPip is on a distinguished road
Quote:
Originally Posted by nondisclosure007 View Post
you were right. they were there, just waaaaay off. i changed the formula of where to put the arrow. now they all show up.
You also need to reset the avgRange to 0 before the loop.

avgRange = 0;
for (counter=i ;counter<=i+9;counter++)
{
avgRange=avgRange+MathAbs(High[counter]-Low[counter]);
}

Robert
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #569 (permalink)  
Old 12-13-2007, 10:14 AM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 560
MrPip is on a distinguished road
You have an extra line in red that might cause a problem.

Robert


Quote:
Originally Posted by Jovager View Post
I want to stoploss on MACD.

I have this code :

double Mach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,Tr adeBar);
double vMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,T radeBar+1);
double vvMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN, TradeBar+2);

GlobalVariableSet("mt_Vager1"+Symbol()+Period(),mt r);
GlobalVariableSet("l_Vager1"+Symbol()+Period(),TP_ SL_Inc);



if (TotalOrders(Magic_Number)>0){
bool g=false;
while (!g){
g=true;
for (int kli=OrdersTotal()-1;kli>=0;kli--){
OrderSelect(kli,SELECT_BY_POS);
if

(OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY && Mach<vMach && vMach<vvMach)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Bid,Digits),Slippage,Pink);
g=false;
break;
}
if (OrderMag
icNumber()==Magic_Number && OrderType()==OP_SELL && m1>m2 && m11<=m21)
(OrderMagicNumber()==Magic_Number && OrderType()==OP_SELL && Mach>vMach && vMach>vvMach)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Ask,Digits),Slippage,Pink);
g=false;
break;
}
}
}
}

Open works but not stoploss exit.

Thanks for help.

Jo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #570 (permalink)  
Old 12-13-2007, 06:26 PM
Junior Member
 
Join Date: Dec 2007
Posts: 6
Slakerz is on a distinguished road
Need help on my EA

Hi guys, i've been trying to figure out how to put a StopLoss.. my EA is as below,

//+------------------------------------------------------------------+
//| CHinGs73MAroon73CLK200_v2.6 |
//| Copyright © Dec_2007, CHinGsMAroonCLK |
//| chingsmaroonclk@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, CHinGsMAroonCLK."
#property link "http://chings73forex.blogspot.com/"

extern int MinGS=17;
extern int TP=19;
extern int StopLoss=15;
extern double lot=0.10;
extern int MaxTrades=9;
extern int RegularSpread=3;
extern double Multiplier=2;
extern double LotInc=0;
extern double MarginLevelAlert=1000;

int magic;
double lot2;
datetime tob,tos,toe; //Time Out Buy & Sell & email


//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----



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

int init()
{
if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") { magic = 211001; }
if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") { magic = 211002; }
if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") { magic = 211003; }
if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") { magic = 211004; }
if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") { magic = 211005; }
if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") { magic = 211006; }
if (Symbol() == "EURCADm" || Symbol() == "EURCAD") { magic = 211007; }
if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") { magic = 211008; }
if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") { magic = 211009; }
if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") { magic = 211010; }
if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") { magic = 211011; }
if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") { magic = 211012; }
if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") { magic = 211013; }
if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") { magic = 211014; }
if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") { magic = 211015; }
if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") { magic = 211016; }
if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") { magic = 211017; }
if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") { magic = 211018; }
if (Symbol() == "USDCADm" || Symbol() == "USDCAD") { magic = 211019; }
if (magic == 0) { magic = 211999; }
return (0);
return(0);
}

void OpenBuy()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,1,0,Ask+TP*Poin t,"Ask-StopLoss*Point,EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}

void OpenSell()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_SELL,lot2,Bid,1,0,Bid-TP*Point,Bid+StopLoss*Point,"EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}


void ManageBuy()
{
int lasttradetime = 0;
double lastopenprice=0;
double maxlots = 0;
double lasttp=0;
int lastordertype=-1;
int lastorderticket=0;
int y=0;

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY)) { continue; }
if (OrderOpenTime() > lasttradetime) {
lasttradetime = OrderOpenTime();
lastopenprice = OrderOpenPrice();
lastordertype=OrderType();
lastorderticket=OrderTicket();
lasttp=OrderTakeProfit();
}
if (OrderLots() > maxlots) { maxlots = OrderLots(); }
}

int lvl=MathRound(MathLog((maxlots-LotInc)/lot)/MathLog(Multiplier)+1);

Print(lvl);

if (lvl<0) lvl=0;

lot2=lot*MathPow(Multiplier,lvl)+LotInc;

if ((lvl==0) && (((Ask-Bid)/Point)<=RegularSpread)) OpenBuy();

if ((lastopenprice-Ask>MinGS*Point) && (lvl<MaxTrades) && (((Ask-Bid)/Point)<=RegularSpread)) {
OpenBuy();
return(0);
}

/////////// TP
/*
double sumlots=0;
double sump=0;
double avgp=0;
for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY)) { continue; }
sumlots=sumlots+OrderLots();
sump=OrderOpenPrice()*OrderLots()+sump;
}

if (sumlots>0) {
avgp=NormalizeDouble(sump/sumlots,Digits);
double tpp=NormalizeDouble(TP/10/sumlots*Point+avgp,Digits);

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (OrderTakeProfit()==tpp)) { continue; }
OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss(),tpp,0,Red);
}


}
*/

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (OrderTakeProfit()==lasttp) || (lasttp==0)) { continue; }
OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss(),lasttp,0,Red);
}


}

void ManageSell()
{
int lasttradetime = 0;
double lastopenprice=0;
double maxlots = 0;
double lasttp=0;
int lastordertype=-1;
int lastorderticket=0;
int y=0;

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL)) { continue; }
if (OrderOpenTime() > lasttradetime) {
lasttradetime = OrderOpenTime();
lastopenprice = OrderOpenPrice();
lastordertype=OrderType();
lastorderticket=OrderTicket();
lasttp=OrderTakeProfit();
}
if (OrderLots() > maxlots) { maxlots = OrderLots(); }
}

int lvl=MathRound(MathLog((maxlots-LotInc)/lot)/MathLog(Multiplier)+1);

if (lvl<0) lvl=0;

lot2=lot*MathPow(Multiplier,lvl)+LotInc;

if ((lvl==0) && (((Ask-Bid)/Point)<=RegularSpread)) OpenSell();

if ((Bid-lastopenprice>MinGS*Point) && (lastopenprice>0) && (lvl<MaxTrades) && (((Ask-Bid)/Point)<=RegularSpread)) {
OpenSell();
return(0);
}

/////////// TP
/* double sumlots=0;
double sump=0;
double avgp=0;
for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL)) { continue; }
sumlots=sumlots+OrderLots();
sump=OrderOpenPrice()*OrderLots()+sump;
}

if (sumlots>0) {
avgp=NormalizeDouble(sump/sumlots,Digits);
double tpp=NormalizeDouble(-TP/10/sumlots*Point+avgp,Digits);

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (OrderTakeProfit()==tpp)) { continue; }
OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss(),tpp,0,Red);
}


}
*/

for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (OrderTakeProfit()==lasttp) || (lasttp==0)) { continue; }
OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss(),lasttp,0,Red);
}


}

void CheckMargin()
{
if (AccountMargin()!=0) {
if (((AccountEquity()/AccountMargin()*100)<MarginLevelAlert) && (TimeCurrent()>toe+3600)) {
SendMail("Account Margin Warning","Account Free Margin is "+AccountFreeMargin());
toe=TimeCurrent();
}
}
}




//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----

ManageBuy();

ManageSell();

CheckMargin();

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

Thanx so much...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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:50 AM.



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