Coding help - page 96

 

Hello Mladen ,

I want to keep track of few things in my code , and one of them is the number of open trades with different magic number and different comments from the same pair so I am using this code , some where inside the code I am making a mistake as the CPU is 100% so I am trying to improve my functions . the following is one of them , can you please suggest a better alternative for my method

x=OrdersTotal(); xx=x; //-- Count How magic number && comment are open for the same pair for( i=0;i<x;i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if( OrderSymbol() == Sym /*&& OrderCloseTime()==0 */){

TemMagic= OrderMagicNumber(); TemOrdComment= OrderComment(); OrdOpenPrice= OrderOpenPrice(); OrdType= OrderType(); iSameSymTotal++; // count all oopen trades from the same Symbol for( i=0;i<xx;i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if( OrderSymbol() == Sym ){ if ( TemMagic!= OrderMagicNumber())CounTMagic++; if (TemOrdComment!= OrderComment())CounTComment++; }} }}
 
MiniMe:
Hello Mladen ,

I want to keep track of few things in my code , and one of them is the number of open trades with different magic number and different comments from the same pair so I am using this code , some where inside the code I am making a mistake as the CPU is 100% so I am trying to improve my functions . the following is one of them , can you please suggest a better alternative for my method

x=OrdersTotal(); xx=x; //-- Count How magic number && comment are open for the same pair for( i=0;i<x;i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if( OrderSymbol() == Sym /*&& OrderCloseTime()==0 */){

TemMagic= OrderMagicNumber(); TemOrdComment= OrderComment(); OrdOpenPrice= OrderOpenPrice(); OrdType= OrderType(); iSameSymTotal++; // count all oopen trades from the same Symbol for( i=0;i<xx;i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if( OrderSymbol() == Sym ){ if ( TemMagic!= OrderMagicNumber())CounTMagic++; if (TemOrdComment!= OrderComment())CounTComment++; }} }}[/PHP]

Us a code like this (added some comment in order to clarify what is stored where) :

[PHP] string uniques[][4]; ArrayResize(uniques,0);

//

//

// uniques[][0] -> Symbol

// uniques[][1] -> Magic number

// uniques[][2] -> Comment

// uniques[][3] -> Number of occurences

// needs to be transformed to int using StrToInt()

//

//

for( int i=OrdersTotal()-1; i>=0; i--)

{

OrderSelect(i,SELECT_BY_POS, MODE_TRADES);

bool found=false;

for (int k=ArrayRange(uniques,0)-1; k>=0 && !found; k--)

if (OrderSymbol() == uniques[k][0] && OrderMagicNumber() == StrToInteger(uniques[k][1]) && OrderComment() == uniques[k][2]) { uniques[k][3] = StrToInteger(uniques[k][3])+1; found=true; }

if (!found)

{

k = ArrayRange(uniques,0);

ArrayResize(uniques,k+1);

uniques[k][0] = OrderSymbol();

uniques[k][1] = OrderMagicNumber();

uniques[k][2] = OrderComment();

uniques[k][3] = 1;

}

}

PS: the size of the array itself (ArrayRange(uniques,0)) is the number of unique symbol + magic number + comment combinations, and the uniques[nn][3] is showing how many occurences for that particular combination are there in the orders queue

 

Thanks a lot Mladen ,

if I want to say if I have more than one trade that would be if (uniques[1][3] == 1) , correct ?

but this doesn't compile , is it because uniques[1][3] is a string array ?

Should it be

if (StrToInteger(uniques[1][3])==1) ?

 
MiniMe:
Thanks a lot Mladen ,

if I want to say if I have more than one trade that would be if (uniques[1][3] == 1) , correct ?

but this doesn't compile , is it because uniques[1][3] is a string array ?

Should it be

if (StrToInteger(uniques[1][3])==1) ?

yes, you have to convert it to integere first. But then the condition would be : if (StrToInteger(uniques[1][3])>1) and it would be for the second found symbol + magic number + comment unique combination

 

Hi Mladen,

I have this Demark's sequential...but it is wrong in countdown phase.

This is the exact explanation from Jason Perl's book:

tD Setup vs. tD Sequential countdown

Once TD Setup is complete,TD Countdown can begin, from the close

of bar nine of TD Setup (inclusive), onward. The distinction between

the two strategies is this:

• TD Setup compares the current close with the corresponding close

four bars earlier,

Whereas

• TD Countdown compares the current close with the low two bars

earlier for a potential buy, and compares the current close with the

high two bars earlier for a prospective sell.This price relationship is

an important distinction from TD Setup, because the market must

be trending for TD Countdown to objectively identify the likely

exhaustion point for a trend reversal.

One can start looking for the first bar of a TD Buy Countdown

when a TD Buy Setup is in place.

■ To Initiate TD Buy Countdown

After

TD Buy Setup is in place, look for the initiation of a TD Buy Countdown.

If

Bar nine of a TD Buy Setup also has a close less than, or equal to, the low two bars

earlier

Then,

Bar nine of a TD Buy Setup becomes bar one of a TD Buy Countdown.

If

That condition is not met,

Then

TD Buy Countdown bar one is postponed until it does, and the TD Buy Countdown

continues until there are a total of thirteen closes, each one less than, or equal to,

the low two bars earlier.

tD Sell countdown

As soon as a TD Sell Setup is in place, we can start looking for the first

bar of aTD Sell Countdown; bar nine of aTD Sell Setup can also be bar

one of a TD Sell Countdown if it satisfies the following conditions.

■ Requirement for a TD Sell Countdown

With bar nine of the TD Sell Setup in place, there must be a close greater than, or

equal to, the high two bars earlier.

In my image you can see (for countdown sell) that bar n°6 has not a close greater than high two bar earlier....so it is wrong!

Please,can you correct this error for countdown buy and sell?

thank's in advance

Files:
 

I found the mistake (f***ing version 500 of mt4 doesn´t create the ex4 files), now it works. I tried to erase the post, but couldn´t

marley60:
hello,

I hope you can help me with this. I want the dots(arrows; aqua&yellow) of the indi in window two to show as dots(arrows) on the close(or high for buy signal/low for sell signal) in window one(the main chart window). I tried for hours, but I will never be a coder ;-)

 
marley60:
I found the mistake (f***ing version 500 of mt4 doesn´t create the ex4 files), now it works. I tried to erase the post, but couldn´t

Don't worry about previous post

At least we know about one more bug in build 500

 

Hey all!

I have put together a 3 minute video explaining my problem in an attempt to be more concise and punchy with requesting some help!

Video:2013-06-13_1517 - D.Gilberto's library - should explain it clearly!

I would greatly appreciate anyone' suggestions or help. I am basically wanting to find out what the bar is at the time of when all the moving averages cross, to when the next bars following this one, comes back to touch the 21 EMA - At this point I want my order to be placed at the high/low of these bar ranges. The order should be pulled on the first bar to close past the 60 EMA...

I hope this isnt too much of an ask and I would greatly appreciate some bright spark lending me hand!

Thank you!

 

Coders

I like this simple strategy based on RSI in picture (may be it's from TS)

Nice and simple and yet effective No need to more clarify, a picture is worth a thousand words !

Is it possible to code such indicators( RSI candles & oscillator ) for MT4 ? or we already have such indicators !

Thanks

Files:
 
marley60:
I found the mistake (f***ing version 500 of mt4 doesn´t create the ex4 files), now it works. I tried to erase the post, but couldn´t

Marley,

See my post under Metatrader Known Bugs. I and several others have had the same problem

Tzuman