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
  #1181 (permalink)  
Old 08-22-2008, 02:16 AM
Member
 
Join Date: Jan 2006
Posts: 59
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
What does i++ or i-- mean in coding?
Eg: for (int i=5; i>0; i--)
It is short hand in C based langauges for incrementing or decrementing a number based variable.

For example in Visual Basic you would have to write.
i = i + 1 to increment the i variable.
however, in C you can simply write i++.

Hope this helps.

Hiachiever
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
  #1182 (permalink)  
Old 08-22-2008, 02:53 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,218
matrixebiz is on a distinguished road
Quote:
Originally Posted by hiachiever View Post
It is short hand in C based langauges for incrementing or decrementing a number based variable.

For example in Visual Basic you would have to write.
i = i + 1 to increment the i variable.
however, in C you can simply write i++.

Hope this helps.

Hiachiever
Thanks,
so if I put if (int i=6; i>0; i++)

it will 'loop' or keep checking value until 6 max? not sure if that is right. What if I use i--? Please clarify
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
  #1183 (permalink)  
Old 08-22-2008, 03:00 AM
Member
 
Join Date: Jan 2006
Posts: 59
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
Thanks,
so if I put if (int i=6; i>0; i++)

it will 'loop' or keep checking value until 6 max? not sure if that is right. What if I use i--? Please clarify
Matrixebiz,

if you want to start at 6 and go back to 0 then use i--

(int i=6; i>0; i--)

This will start at 6, decrement by 1 on each loop for as long as I > 0.
If you want to include 0 then use i>=0.

Cheers,
Hiachiever
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
  #1184 (permalink)  
Old 08-22-2008, 05:23 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,218
matrixebiz is on a distinguished road
Quote:
Originally Posted by hiachiever View Post
Matrixebiz,

if you want to start at 6 and go back to 0 then use i--

(int i=6; i>0; i--)

This will start at 6, decrement by 1 on each loop for as long as I > 0.
If you want to include 0 then use i>=0.

Cheers,
Hiachiever
Ok, so if I put if (int i=6; i>0; i++)
then it will start at 6 then , start over incrementing 1, 2, 3 ... 6, correct?
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
  #1185 (permalink)  
Old 08-22-2008, 05:37 AM
Member
 
Join Date: Jan 2006
Posts: 59
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
Ok, so if I put if (int i=6; i>0; i++)
then it will start at 6 then , start over incrementing 1, 2, 3 ... 6, correct?
No quite if what you are wanting to do there is finish at 6.

The the code in this case would be
For (int i=1; i<=6; i++)

This will start at 1 and finish at 6 incrementing by 1 on each loop.

Cheers,
Hiachiever

Last edited by hiachiever; 08-22-2008 at 05:55 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
  #1186 (permalink)  
Old 08-22-2008, 06:06 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,218
matrixebiz is on a distinguished road
I'm trying to figure out if this is wrong;
for (int i=qqea_alert_x_candles_ago; i>0; i--) {
// int i = 1;
qqea_up = iCustom(NULL,0,"QQE Alert v3",0,i);
qqea_down = iCustom(NULL,0,"QQE Alert v3",1,i);

if (qqea_up < qqea_down) {
if (i == 1) qqeacross = True;
qqea_long = True;
qqea_short = False;
} else if (qqea_up > qqea_down) {
if (i == 1) qqeacross = True;
qqea_long = False;
qqea_short = True;
}
}
}

it should check for valid signal upto "qqea_alert_x_candles_ago" bars back, but then it has (i == 1) which i==1 only happens once ??
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
  #1187 (permalink)  
Old 08-22-2008, 10:24 AM
Member
 
Join Date: Jan 2006
Posts: 59
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
I'm trying to figure out if this is wrong;

for (int i=qqea_alert_x_candles_ago; i>0; i--) {
// int i = 1;
qqea_up = iCustom(NULL,0,"QQE Alert v3",0,i);
qqea_down = iCustom(NULL,0,"QQE Alert v3",1,i);
Print("qqea_up: ", qqea_up, "qqea_down: ", qqea_down);

if (qqea_up < qqea_down) {
if (i == 1) qqeacross = True;
qqea_long = True;
qqea_short = False;
} else if (qqea_up > qqea_down) {
if (i == 1) qqeacross = True;
qqea_long = False;
qqea_short = True;
}
}
}

it should check for valid signal upto "qqea_alert_x_candles_ago" bars back, but then it has (i == 1) which i==1 only happens once ??
At face value your code looks alright, that is assuming "qqea_alert_x_candles_ago" > 0.
Your problem if this is not working is more than likley in relation to iCustom.
For this function to work correctly you need to pass an input element for every input element in the actual indicator. If you don't do this, or pass the wrong data types then icustom will return nothing.

I have added a Print statement into the code above. Use this to determine if the values returned from iCustom actually contain anything.

Cheers,
Hiachiever
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
  #1188 (permalink)  
Old 08-22-2008, 11:30 AM
Member
 
Join Date: Jan 2008
Posts: 47
Pussy Galore is on a distinguished road
Help needed with code to count bars

My EA has a number of options to calculate the stoploss of an open position. One of those options is to use the low of last "x" number of price bars.

The line of code currently used within the EA to calculate the stoploss (SL) of this option for a long position is:

SL=iLow(Symbol(),Period(),iLowest(Symbol(),Period( ),MODE_LOW,StopLossBars,0));

StopLossBars is an externally input variable.

The problem I have is that I want the value of StopLossBars to increase with every bar counted since the position was opened until one of my other conditions for stoploss over rides this condition. I guess a line of code such as:

StopLossBars = StopLossBars + BarsCountedSincePositionOpened

would do the trick. Unfortunately my coding is pretty limited to cut'n'paste and I don't know how to calculate or code BarsCountedSincePositionOpened.

Could somebody tell me how to do it please?
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
  #1189 (permalink)  
Old 08-22-2008, 01:21 PM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,218
matrixebiz is on a distinguished road
Quote:
Originally Posted by hiachiever View Post
At face value your code looks alright, that is assuming "qqea_alert_x_candles_ago" > 0.
Your problem if this is not working is more than likley in relation to iCustom.
For this function to work correctly you need to pass an input element for every input element in the actual indicator. If you don't do this, or pass the wrong data types then icustom will return nothing.

I have added a Print statement into the code above. Use this to determine if the values returned from iCustom actually contain anything.

Cheers,
Hiachiever
The code is from another EA but I was thinking that when the loop goes to "qqea_alert_x_candles_ago" > 1 then this statement "if (i == 1) qqeacross = True;" would be False now, correct? When it should stay True until i>qqea_alert_x_candles_ago.
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
  #1190 (permalink)  
Old 08-22-2008, 05:55 PM
Junior Member
 
Join Date: Nov 2007
Posts: 2
RogerioMolinario is on a distinguished road
Helping

Dear all,

I got this coding from a colleague. He told me, that should be a very good Indicator signaling SMA up or down entries. Can somebody help me to create an indicator with this coding below.

/*[[
Name := SMA Up and Down
Separate Window := no
First Color := Blue
First Draw Type := Line
Use Second Data := Yes
Second Color := Red
Second Draw Type := Line
]]*/
Inputs : MAPeriod(10), Bandwide_UP(20),Bandwide_DOWN(20);
Variables : shift(0), cnt(0), sum(0), loopbegin1(0), loopbegin2(0), first(True), prevbars(0);
Variables : MA(0);

SetLoopCount(0);
// initial checkings
If MAPeriod < 1 Then Exit;
// check for additional bars loading or total reloading
If Bars < prevbars Or Bars-prevbars>1 Then first = True;
prevbars = Bars;
// loopbegin1 and loopbegin2 prevent couning of counted bars exclude current
If first Then Begin
loopbegin1 = Bars-MAPeriod-1;
If loopbegin1 < 0 Then Exit; // not enough bars for counting
loopbegin2 = Bars-MAPeriod-1;
If loopbegin2 < 0 Then Exit; // not enough bars for counting
first = False; // this block is to be evaluated once only
End;

// convergence-divergence
loopbegin1 = loopbegin1+1; // current bar is to be recounted too
For shift = loopbegin1 Downto 0 Begin
MA = iMA(MAPeriod,MODE_SMA,shift);
SetIndexValue(shift,(MA+Bandwide_UP*point));
SetIndexValue2(shift,(MA-Bandwide_DOWN*point));
loopbegin1 = loopbegin1-1; // prevent to previous bars recounting
End;

Best regards,
Rogerio
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: 2 (0 members and 2 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 09:18 AM.



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