How to code? - page 215

 

A Little Bit of Programming Help

Hi Everyone,

This is my first post!!

I have been trying for about 3 months to program an EA to recognise a particular candlestick pattern and open either a Buy or Sell order after that pattern but, have been failing miserably!

I don't know how to post pictures here so I'll have to describe it.

For a Buy signal / trade I have been trying program:

Close[3] < Close[4],

Close[2] < Close[3],

High[2] < Open[3],

Low[1] > Low[2] and

Close[1] >= Open[3]

For the Sell signal / trade it is the opposite of the Buy.

It is probably very simple but I just can't do it.

Is there a kind and generous person out there who would be willing to program this for me???

Thanks

 
Cgage2491:
Hi Everyone,

For a Buy signal / trade I have been trying program:

Close[3] < Close[4],

Close[2] < Close[3],

High[2] < Open[3],

Low[1] > Low[2] and

Close[1] >= Open[3]

For the Sell signal / trade it is the opposite of the Buy.

Thanks

Hi Cgage....

Without your code I don't know what your variables are but you can try and modify this...it may work for you.

bool BuyCondition = false ;

bool SellCondition = false ;

//--------- BuyCondition ----------

if (Close[3] < Close[4] && Close[2] < Close[3] && High[2] Low[2] && Close[1] >= Open[3]) BuyCondition = true ; else BuyCondition = false;

For the Sell signal / trade it is the opposite of the Buy.

//--------- SellCondition ----------

if (Close[3] > Close[4] && Close[2] > Close[3] && High[2] > Open[3] && Low[1]< Low[2] && Close[1] <= Open[3]) SellCondition = true ; else SellCondition = false;

Good luck.

Robert

 
cosmiclifeform:
Hi Cgage....

Without your code I don't know what your variables are but you can try and modify this...it may work for you.

bool BuyCondition = false ;

bool SellCondition = false ;

//--------- BuyCondition ----------

if (Close[3] < Close[4] && Close[2] < Close[3] && High[2] Low[2] && Close[1] >= Open[3]) BuyCondition = true ; else BuyCondition = false;

For the Sell signal / trade it is the opposite of the Buy.

//--------- SellCondition ----------

if (Close[3] > Close[4] && Close[2] > Close[3] && High[2] > Open[3] && Low[1]< Low[2] && Close[1] <= Open[3]) SellCondition = true ; else SellCondition = false;

Good luck.

Robert

Thanks for the reply.

I tried something like this, I've tried lots of things.

The problems I've had have been multiple trades per bar, trades on every bar, not recognising the pattern at all, etc.

I understand the logic side of things but I don't know how to program it.

I tried doing cut and paste from other indicators / EAs but I can't get it to do what I want!

Basically, if the buy condition logic = true then open a buy trade and if sell condition logic = true then open a sell trade.

Any help appreciated.

 
Enforcer:
by OrderType( )

OP_BUY - buying position,

OP_SELL - selling position,

OP_BUYLIMIT - buy limit pending position,

OP_BUYSTOP - buy stop pending position,

OP_SELLLIMIT - sell limit pending position,

OP_SELLSTOP - sell stop pending position.

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if(OrderType() == OP_BUY) {...do some thing....}

if(OrderType() == OP_SELL) {...do other thing....}

}

[/PHP]

This above is your solution. You need to count existing orders so EA knwos they exist and not continue creating more

Cgage2491:

The problems I've had have been multiple trades per bar, trades on every bar, not recognising the pattern at all, etc.

See what I said above. Can also try similar to this:

[PHP]int i, ticket;

int total = OrdersTotal();

double totallongs=0, totalshorts =0;

for( i=0;i<total;i++)

{

OrderSelect(i, SELECT_BY_POS );

if ( OrderComment() == ExpertName )

{

int type = OrderType();

if (( OrderSymbol() == Symbol() && (type == OP_BUY ))) {totallongs=totallongs+1;}

if (( OrderSymbol() == Symbol() && (type == OP_SELL ))) {totalshorts=totalshorts+1;}

if (( OrderSymbol() == Symbol() && (type == OP_BUYLIMIT || OP_BUYSTOP ))) {totallongs=totallongs+1;}

if (( OrderSymbol() == Symbol() && (type == OP_SELLLIMIT || OP_SELLSTOP ))) {totalshorts=totalshorts+1;}

}

}
 

Thanks Guys,

Much better, it's not trading every bar now.

I have managed to get close to what I wanted but at the moment it's not finding the pattern I was after.

Just a few logic tweaks I think.

 

Percent of Resistance Indicator

Does anybody have or can code the percent of resistance indicator?

 

How to find the high and low of where the location of the mouse is?

Hi Gurus out there, I would like an indicator to show me what is the range of the current bar/period of where my mouse is and comment on the screen.

Can someone guide me to extract the values found at the Status bar of MT4 showing the High and Low values.

Thanks in advance.

Regards

Stardome

 
codersguru:
samahdi,

1- Could I see the code and tell me wht do you want to do?

2- magic number is a number you assign to your order(s)as a reference enables you to distinguish between the different orders.

You sould wait the third part of expert advisor lesson to know more about coding expert advisors.

Hi,

Would you help me in adding the "Time to trade" feature to this wonderful EA. I have to be able to set the "time to trade" in the EA. Please code this for me. I've attached the EA. Thanks.

Files:
 

Plz help me edit this EA!

newdigital:
All that I know that in most cases it is not helping.

Hi,

Would you help me in adding "Time to trade" feature to this wonderful EA. I have to able to set time to trade in the EA. Please code this for me. I've attached the EA. Thanks.

Files:
 

Get original order from history

Hi everyone,

Is it possible to get the original stop loss value for an order that has been modified several times (ie. trailing stop)?

Thanks,

Chris

Reason: