Coding help - page 338

 
Maine:
Hello,

I would like to check if my last three closed sell or buy trades were profitable, and change a string value depending on it.

I have this code (MT4):

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

{

OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==BUY)

{

//for buy order

if(OrderType()==OP_BUY && OrderProfit()>0) last=1;

if(OrderType()==OP_BUY && OrderProfit()<0) last=0;

}

}

for(int j=(OrdersHistoryTotal()-1);j>=0;j--);

{

OrderSelect(j, SELECT_BY_POS,MODE_HISTORY);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==SELL)

{

//for sell order

if(OrderType()==OP_SELL && OrderProfit()>0) last2=1;

if(OrderType()==OP_SELL && OrderProfit()<0) last2=0;

}

}

But it doesn't work for me.

How I should modify it?

Thanks for help.

What do these two line try to do (what are BUY and SELL in your code - or did you try to compile that at all - since BUY and SELL are not predefined constants). Also, OrderMagicNumber() is a magic number not the type of the order :

OrderMagicNumber()==BUY

OrderMagicNumber()==SELL

 

Hi all,

I made a stepma expert and i use this :

int trendCurr = iCustom(s_symbol,StepMaTimeFrame,"Stepma",Length,Kv,StepSize,MA_Mode,Advance,Percentage,UpDownShift,HighLow,ColorMode,5,StepMaBarToTest );

int trendPrev = iCustom(s_symbol,StepMaTimeFrame,"Stepma",Length,Kv,StepSize,MA_Mode,Advance,Percentage,UpDownShift,HighLow,ColorMode,5,StepMaBarToTest+1);

if (trendCurr > 0 && trendPrev < 0) SendLong = true;

if (trendCurr 0) SendShort = true;

Now i need help, what sort of code can i use, if i want to trade the pullbacks of price on the stepma ?

If the price touch the stepma it enters in the way of the stepma color.

Thanks !

 
albert666:
Hi all,

I made a stepma expert and i use this :

int trendCurr = iCustom(s_symbol,StepMaTimeFrame,"Stepma",Length,Kv,StepSize,MA_Mode,Advance,Percentage,UpDownShift,HighLow,ColorMode,5,StepMaBarToTest );

int trendPrev = iCustom(s_symbol,StepMaTimeFrame,"Stepma",Length,Kv,StepSize,MA_Mode,Advance,Percentage,UpDownShift,HighLow,ColorMode,5,StepMaBarToTest+1);

if (trendCurr > 0 && trendPrev < 0) SendLong = true;

if (trendCurr 0) SendShort = true;

Now i need help, what sort of code can i use, if i want to trade the pullbacks of price on the stepma ?

If the price touch the stepma it enters in the way of the stepma color.

Thanks !

albert666

For that you have to compare prices to stepma value (not just the stepma trend. But since price is almost never the same as indicators value, you are going to have problems with that +you might end up with lagging signal (since you have to compare 3 bars and the newest bar must be confirmed or else you can get a lot of false signals

 

Hello albert,

Me too i'm thinking of the same idea.

Thanks Mladen for the answer, maybe we can use the close of a bar, it maybe will be easier ?

 
Big Joe:
Hello albert,

Me too i'm thinking of the same idea.

Thanks Mladen for the answer, maybe we can use the close of a bar, it maybe will be easier ?

Joe

Pullbacks are looking good in the hindsight but, just to remind you : every trend change was a potential pullback. Try to predict if it is going to be a pullback or a trend change in the run time and you will see what I mean

 
mladen:
albert666 For that you have to compare prices to stepma value (not just the stepma trend. But since price is almost never the same as indicators value, you are going to have problems with that +you might end up with lagging signal (since you have to compare 3 bars and the newest bar must be confirmed or else you can get a lot of false signals

Thank you sir Mladen, i understand what you mean, that's true it can sound crazy, but can you give me anyway some hints about coding this.

I'm completely lost, should i use Bid() and Ask() ?

Thanks.

 
mladen:
alpha24

You do not need a new indicator for that

Use any ma that is in separate window already, and then just drag the bollinger bands to that sub-window and choose previous indicator data as a price field

Mladen Sir

It looks you are too busy or not interested to do. My requirement was very small and simple. There is much more potential in small and simple things that is what I learned in Technical Analysis. any way thank you.

 
alpha24:
Mladen Sir It looks you are too busy or not interested to do. My requirement was very small and simple. There is much more potential in small and simple things that is what I learned in Technical Analysis. any way thank you.

alpha24

I fail to understand your post

I did explain to you how you can simply get what you need. What is the problem then? You do not like the solution (that is, btw, exactly what you have described and as simple as it gets)? I simply can not see what could be the problem when your post was answered with a correct solution

regards

 
albert666:
Thank you sir Mladen, i understand what you mean, that's true it can sound crazy, but can you give me anyway some hints about coding this.

I'm completely lost, should i use Bid() and Ask() ?

Thanks.

albert666

What I would like to recommend is that you try to estimate rebounds in runtime (not on historical data, but maximum on the first closed bar) for some time and that should make it much clearer what are the exact problems when it comes to guessing rebounds. That exact guessing game would need to be done by the EA too

 
alpha24:
Mladen Sir It looks you are too busy or not interested to do. My requirement was very small and simple. There is much more potential in small and simple things that is what I learned in Technical Analysis. any way thank you.

Here is one old moving average in a separate window : moving_averages_sw.mq4

Works in new metatrader too even though it is a very old one

Files:
Reason: