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
  #531 (permalink)  
Old 12-07-2007, 06:11 AM
Junior Member
 
Join Date: Oct 2007
Posts: 6
nakata79087 is on a distinguished road
Thank you

thank you for your kind,Michel!!

I was troubled for a long time,why it start a different signature though two these are slight differences.
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
  #532 (permalink)  
Old 12-07-2007, 07:13 AM
Junior Member
 
Join Date: Oct 2007
Posts: 6
nakata79087 is on a distinguished road
Other question

now my EA like this

if(FastMA2 <= SlowMA2 && FastMA1 > SlowMA1)
{
ClosePositions();
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-SLpips*Point,Ask+(45*Point),"",MAGIC,0,Blue);
return(0);


i want to change like this

1. 15minutus timeflame happen buy sign

2. if then 5minutes timeflame MA cross buy sign already ,too
ClosePosition. and get new position

if then 5minutes timeflame MA change sell sign already
wait 5minutes timeflame change buy sign ,
then ClosePosition. and get new position


Please tell me how to write this program.
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
  #533 (permalink)  
Old 12-07-2007, 04:58 PM
EliteJ's Avatar
Junior Member
 
Join Date: Nov 2006
Posts: 24
EliteJ is on a distinguished road
Need help with coding ease of movement indicator

I tried to code it myself but the indicator line doesn't show in the indicator window when I run it. If you go here MANUAL - TECHNICAL INDICATORS it has a definition of the indicator with the formula for calculating it.

Here's the code I have written:

//+------------------------------------------------------------------+
//| Ease of Movement.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum -50
#property indicator_maximum 50
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
string short_name = "Ease of Movement";
IndicatorShortName(short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----check for errors
if (counted_bars<0) return(-1);

//----last counted bar will be recounted
if (counted_bars>0) counted_bars--;
int k = Bars - counted_bars;
double midptT, midptY, boxR, midptM, EMV;
while (k>0)
{
midptT = (High[k] + Low[k])/2;
midptY = (High[k+1] + Low[k+1])/2;
midptM = midptT - midptY;
boxR = Volume[k]/(High[k] - Low[k]);
EMV = midptM / boxR;
ExtMapBuffer1[k] = EMV;
k--;
}

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


can anyone tell me what I'm doing wrong? I attached the indicator too if you want to try to run it for yourself.
Attached Files
File Type: mq4 Ease of Movement.mq4 (2.2 KB, 36 views)
__________________
"Duct tape is like the force: it has a dark side and a light side, and it holds the universe together."
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
  #534 (permalink)  
Old 12-07-2007, 05:55 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Hello

I am looking for some help I have an EA that I'm using on demo and also learning to code with. I am trying to figure out how to add a comment to the system to show me which of the 4 entry criteria was used to open the position. eg if long2 was used then show long2 signal

any help would be great


cheers

Beno
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
  #535 (permalink)  
Old 12-07-2007, 10:39 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by Beno View Post
Hello

I am looking for some help I have an EA that I'm using on demo and also learning to code with. I am trying to figure out how to add a comment to the system to show me which of the 4 entry criteria was used to open the position. eg if long2 was used then show long2 signal

any help would be great


cheers

Beno
After your condition is met and you use Ordersend() command, just insert a Comment(), Alert(), or Print() statement. Whichever you want to use.

Something like this:

if ( long2 == true)
{
Ordersend();
{
Print(" long2 signal taken ");
}
}


Hope that helps.
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
  #536 (permalink)  
Old 12-08-2007, 03:30 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Thanks Wolfe

I had to laugh I put in what you suggested and it worked sort of but now I only have the comment and no positions opening. any hints

bool Long = MAofRSI11>MAofRSI21 && MAofRSI12<=MAofRSI22 && VolCH>VolHL && RSIndex1<HLM && RSIndex1>HL2 && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift];

bool Short = MAofRSI11<MAofRSI21 && MAofRSI12>=MAofRSI22 && VolCH>VolHL && RSIndex1<HL1 && RSIndex1>HLM && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift];

bool Long2 = MAofRSI11>HLM && MAofRSI12<=HLM && MAofRSI21>HLM && MAofRSI22<=HLM && VolCH>VolHL && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift];

bool Short2 = MAofRSI11<HLM && MAofRSI12>=HLM && MAofRSI21<HLM && MAofRSI22>=HLM && VolCH>VolHL && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift];

bool Long3 = RSIndex1-RSIndex2>20<HL2 && TrStop<Close[shift] && MOM>0.0 && SDLL && ma<Close[shift];

bool Short3 = RSIndex2-RSIndex1>20>HL1 && TrStop>Close[shift] && MOM<0.0 && SDLS && ma>Close[shift];

bool Long4 = zscore>0.0 && ma<Close[shift];

bool Short4 = zscore<0.0 && ma>Close[shift];


buysig = Long || Long2 || Long3 || Long4;
sellsig = Short || Short2 || Short3 || Short4;



closebuy=sellsig;
closesell=buysig;

if (curprof>=AccountBalance()*ProfitExit/100.0) {
exit=true;

}
if (last>0 && (Time[0]-last)/(Period()*60)>=CancelOrderBars) {
remorder=true;
}

}

void CheckForOpen() {
int res,tr;
//---- sell conditions
co=CalculateCurrentOrders(Symbol());
if(sellsig && lastsig!=-1) {
co=CalculateCurrentOrders(Symbol());
if (co==0) {
if ( Short == true)
if ( Short2 == true)
if ( Short3 == true)

res = OpenStop(OP_SELLSTOP,LotsRisk(StopLoss), Low[shift]-OrderPipsDiff*Point, StopLoss, TakeProfit1);
Print(" Short signal taken ");
Print(" Short2 signal taken ");
Print(" Short3 signal taken ");
Print(" Short4 signal taken ");


}
lastsig=-1;
last=Time[0];
return;
}
//---- buy conditions
if(buysig && lastsig!=1) {
co=CalculateCurrentOrders(Symbol());
if (co==0) {
if ( Long == true)
if ( Long2 == true)
if ( Long3 == true)
if ( Long4 == true)
res = OpenStop(OP_BUYSTOP,LotsRisk(StopLoss), High[shift]+OrderPipsDiff*Point, StopLoss, TakeProfit1);
Print(" Long signal taken ");
Print(" Long2 signal taken ");
Print(" Long3 signal taken ");
Print(" Long4 signal taken ");

}
last=Time[0];
lastsig=1;
return;
}
}

Fixed it Thanks

Last edited by Beno; 12-08-2007 at 04:37 PM.
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
  #537 (permalink)  
Old 12-08-2007, 04:40 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Debugging code

How and where would you use a bit of code like this. I have a Zero divide error that I can't find how the fix.

extern bool DEBUGGING = true

...

if(DEBUGGING && variableName == 0) Print("CodePoint 1 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 2 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 3 -- This variable is now ", variableName);

...
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
  #538 (permalink)  
Old 12-09-2007, 07:21 AM
Junior Member
 
Join Date: Sep 2007
Posts: 15
deuxmille is on a distinguished road
can you help me?why there are many mistakes in the code?

this is to calculate SMMA:
for(j=0;j<Bars;j++)
{
for(i=0,sum=0;i<ma_period;i++)
{
sum=sum+Close[j+i];
// buffer[j]=(sum-sum/ma_period+Close[j+i])/ma_period;
}
buffer[j]=(sum-sum/ma_period+Close[j])/ma_period;
}




this is to calculate LWMA

for(j=0;j<Bars;j++)
{
for(i=0,sum=0,sum1=0;i<ma_period;i++)
{
sum=sum+Close[j+i];
sum1=sum1+Close[j+i]*(j+i);
// buffer[j]=sum/ma_period;
}
buffer[j]=sum1/sum;
}


and how to calculate EMA?
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
  #539 (permalink)  
Old 12-10-2007, 02:31 AM
ajk's Avatar
ajk ajk is offline
Senior Member
 
Join Date: Dec 2005
Posts: 261
ajk is on a distinguished road
question on indicators

Hi everyone.
I am stuck on a programming issue. Does anyone know how to use 1 indicator result to change another setting? For example, if the daily stockasti was above 20, I would want a moving average of (x). I tried to get the code working below but to know avail. I don't seem to be able to get the switch or if else command to work eithor.


double fourhrUP;
double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,1);
double daystoch20 = 20;
if (daystoch1 > daystoch20) four_hrUP = 5 ;
double iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift)
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
  #540 (permalink)  
Old 12-10-2007, 04:18 AM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 348
Devil2000 is on a distinguished road
Quote:
Originally Posted by ajk View Post
Hi everyone.
I am stuck on a programming issue. Does anyone know how to use 1 indicator result to change another setting? For example, if the daily stockasti was above 20, I would want a moving average of (x). I tried to get the code working below but to know avail. I don't seem to be able to get the switch or if else command to work eithor.


double fourhrUP;
double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,1);
double daystoch20 = 20;
if (daystoch1 > daystoch20) four_hrUP = 5 ;
double iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift)
Where's your MA's variable?
Maybe this could help

double ma4hr=iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift);

if the stoch calculation is in the same loop, let say "for(int shift=limit-1; shift>=0; shift--)", the stoch code should be

double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,shift+1);

CMIIW
__________________
Need a professional MQL4 programmer? PM me

Last edited by Devil2000; 12-10-2007 at 04:25 AM.
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: 3 (1 members and 2 guests)
luxinterior
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 04:33 AM.



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