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
  #131 (permalink)  
Old 07-13-2006, 06:11 PM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
Quote:
Originally Posted by fxd01
I'm trying to write a piece of code that will modify the TP of allexisting trades. When I attach the code to a chart, it works only for the currency where the expert is attached. It does not modify other trades from other currency pairs. Please note that I'm not checking the OrderSymbol()==Symbol() in my code. Where is the mistake? Do I have to add a "return(0)" after each OrderModify()? Can you help me?

Does the expert allow me to open/close/modify trades of a different currency pair while the expert is attached only to a single chart? I'm trying to write a universal code that will process (ie, either modify or close) all existing trades regardless of the chart where the EA is attached to. Can someone please confirm if this is possible at all? If yes, then what is wrong with the following code?



int mTrades=OrdersTotal();
if (mTrades>0)
{
for (i=0;i<mTrades;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), Ask+100*Point, White);
}
if (OrderType() == OP_SELL)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), Bid-100*Point, White);
}
}
}
the problem is that u are using Ask and Bid for the price.
Try to use : MarketInfo(OrderSymbol(),MODE_BID) and MarketInfo(OrderSymbol(),MODE_ASK) instead
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
  #132 (permalink)  
Old 07-13-2006, 06:42 PM
Senior Member
 
Join Date: Nov 2005
Posts: 105
fxd01 is on a distinguished road
elihayun,

It makes sense & thanks a lot. I'll try to use MarketInfo() function.
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
  #133 (permalink)  
Old 07-20-2006, 02:07 PM
Junior Member
 
Join Date: Jul 2006
Posts: 15
RJames5541 is on a distinguished road
Question About Unusual But Effective Indicator: Wich Lines Of Code Are Causing This?

I AM WRITING AND INDICATOR IN MQL4 THAT MEASURES THE BANDWIDTH BETWEEN UPPER AND LOWER BOLLINGER BANDS... FOR SOME REASON WHEN INSTALLED IN THE TRADING TERMINAL NO LINE IS PLOTTED IN THE INDICATOR WINDOW!... I KNOW THE MATH IS WORKING AS THE CORRECT VALUE OF BANDWIDTH IS DISPLAYED IN THE UPPER LEFT-HAND CORNER OF THE INDICATOR WINDOW AS THE PRICE CHANGES. WHY MIGHT THIS BE HAPPENING? I SUSPECT THERE IS SOME SIMPLE THING WRONG WITH MY CODE AS I ONLY BEGAN LEARNING TO PROGRAM 3 DAYS AGO. ANY HELP WOULD BE GREAT!... WHAT LINES OF CODE NEED TO BE ALTERED?

THANKS,
RYAN




//+------------------------------------------------------------------+
//| Band Width of Bollinger Bands .mq4 |
//| Copyright © 2006, Ghostrider Capital LLC. |
//| ryanjmcgregor@tds.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Ghostrider Capital LLC."
#property link "ryanjmcgregor@tds.net"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_maximum 1.5
#property indicator_minimum -0.5


//---- indicator parameters
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
//---- buffers
//---- Moving, Upper, and Lower are for counting to draw Band Width 20
double BandWidth20Buffer[];
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,DodgerBlue );
SetIndexBuffer(0,BandWidth20Buffer);
SetIndexLabel(0,"Band Width 20");

SetIndexBuffer(1,MovingBuffer);
SetIndexBuffer(2,UpperBuffer);
SetIndexBuffer(3,LowerBuffer);

//----
//---- 4 Indicators Buffers Mapping
SetIndexDrawBegin(0,0);
// SetIndexDrawBegin(1,BandsPeriod+BandsShift);
// SetIndexDrawBegin(2,BandsPeriod+BandsShift);
// SetIndexDrawBegin(3,BandsPeriod+BandsShift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2 );
IndicatorShortName("Band Width of 20 2.0 BB");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
int start()
{
int i,k,counted_bars=IndicatorCounted();
double deviation;
double sum,oldval,newres,upper,lower,middle;

//----
if(Bars<=BandsPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=BandsPeriod;i++)
{
MovingBuffer[Bars-i]=EMPTY_VALUE;
UpperBuffer[Bars-i]=EMPTY_VALUE;
LowerBuffer[Bars-i]=EMPTY_VALUE;
BandWidth20Buffer[Bars-i]=EMPTY_VALUE;
}
//----
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
for(i=0; i<limit; i++)
MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_ CLOSE,i);
middle=MovingBuffer[i];
//----
i=Bars-BandsPeriod+1;
if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
while(i>=0)
{
sum=0.0;
k=i+BandsPeriod-1;
oldval=MovingBuffer[i];
while(k>=i)
{
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
UpperBuffer[i]=oldval+deviation;
LowerBuffer[i]=oldval-deviation;
upper=UpperBuffer[i];
lower=LowerBuffer[i];
//---- Formula Band Width = (Upper - Lower) / Middle Band moving sma
BandWidth20 Buffer[i]=(upper-lower)/middle;

i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
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
  #134 (permalink)  
Old 07-20-2006, 11:01 PM
Junior Member
 
Join Date: Jul 2006
Posts: 15
RJames5541 is on a distinguished road
Can someone please explain to me what these lines of code mean/do:

Can someone please explain what these lines of code mean/do? :

SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
SetIndexDrawBegin(2,BandsPeriod+BandsShift);
SetIndexDrawBegin(3,BandsPeriod+BandsShift);
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
  #135 (permalink)  
Old 07-21-2006, 12:37 AM
Member
 
Join Date: Jun 2006
Location: Buenos Aires
Posts: 55
ignacio is on a distinguished road
they do...

Quote:
Originally Posted by RJames5541
Can someone please explain what these lines of code mean/do? :

SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
SetIndexDrawBegin(2,BandsPeriod+BandsShift);
SetIndexDrawBegin(3,BandsPeriod+BandsShift);

hi,

Suposse that you have an indicator with 4 lines. This code, says to the 4 lines where they have to start.

THe 1st parameter is the line index or id (usually: from 0 to 9 . is´t correct?).
The 2nd one is how many bars ago from current one must to start the line.

Correct me if I wrong

Good luck!
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
  #136 (permalink)  
Old 07-21-2006, 07:28 PM
Junior Member
 
Join Date: Jun 2006
Posts: 23
DaytrSuccess is on a distinguished road
very simple code (trailing stop) - need correction

suppressed - to basic - without interest - sorry

Last edited by DaytrSuccess; 08-12-2006 at 03:12 AM. Reason: resolved
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
  #137 (permalink)  
Old 07-25-2006, 11:12 PM
Senior Member
 
Join Date: Jun 2006
Posts: 320
mpower is on a distinguished road
help with reading mql4 code for an indicator

I am trying to come up with a profitable strategy using this indicator--4 period ma. I used to trade live successfully using a similar indicator that I don't have access to anymore. I can't seem to find the optimal settings on 4pma i.e. ma length, method, etc.
Would anybody who can read MQL4 code be able to tell me how this indicator is constructed--how do you determine the hi and lo levels(they are the dynamic fibo levels), how do you determine the lcf and hcf levels? I understand the ma1, ma2, ma3 are moving averages, which lenght and method of calculation can be set by the user--ex. simple moving average, 13 period. It doesn't look like the default settings are optimal. That is why I am trying to understand how it works so that I can fix it.
The indicator is attached below.
Any help is appreciated.
Attached Files
File Type: mq4 4_Period_MA.mq4 (46.6 KB, 54 views)
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
  #138 (permalink)  
Old 07-26-2006, 12:18 AM
Junior Member
 
Join Date: Jun 2006
Posts: 20
efextrader is on a distinguished road
Code Error?

Ive got an EA that doesnt seem to open Buy orders. Perhaps there is an error in the code????
//+------------------------------------------------------------------+
//| Open buy | |
//+------------------------------------------------------------------+
if (!ExistPositions()){
if ((Ask < Op && Tenkan >= Kijun&&PrClose<Kijun/* &&BandUp4>BandUp12 */ ))
/*Hi-Lo > LongBar*Point ex PRG
/* PrClose>BandUp4&& PrClose>LWMA &&LWMA>LWMA20 /*&&BandUp4>BandUp12 */
{
OpenBuy();
return(0);
}


Thanks in advance,
Efextrader
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
  #139 (permalink)  
Old 07-31-2006, 06:15 PM
Member
 
Join Date: Apr 2006
Posts: 52
hidethereal is on a distinguished road
code to not paint the past...

Can someone fix this indicator so that it doesn't paint the past?


Thanks in advance!
Attached Files
File Type: mq4 #00_ZZ_Window.mq4 (7.1 KB, 46 views)
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
  #140 (permalink)  
Old 08-05-2006, 05:58 PM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 398
iscuba11 is on a distinguished road
Smile

You need to have a professional programmer handle this EA. I recommend Yaroslav at Forex-Experts.com.

Dave
<><<
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 (2 members and 1 guests)
malyjan, snooptym
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 08:02 PM.



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