Inverse Bollinger Bands - Mike Need simple Help ! - page 2

 
Gero.Gero wrote >>

Hello,

Use this code to buy/ sell (change for your needs):

First Add the variable double RealPoint in your header declaraton:

double RealPoint = 0.0;

then add this to init() function:

RealPoint = Point;

if( Digits == 5 || Digits == 3 ) RealPoint *= 10;

void Buy()
{
RefreshRates();


SendOrder( OP_BUY, Ask, Ask+(RealPoint*TakeProfit), Bid-(RealPoint*StopLoss) );
}

void Sell()
{
RefreshRates();
SendOrder( OP_SELL, Bid, Bid-(RealPoint*TakeProfit), Ask+(RealPoint*StopLoss) );
}

void SendOrder( int type, double price, double takeprofit, double stoploss )
{


OrderSend( Symbol(), type, vol, price, 3, stoploss, takeprofit, "", MagicNumber, 0 );
Sleep(500);
}

OOps... vol = the lot size, of course... []´s.

 
jjc wrote >>

You're probably right, but there's a huge amount of code on this forum which uses OrdersTotal() in this sort of context - see 'Help with Max Trades' for one of the almost countless examples. It's so common that I assume lots of people really do only want to enter a new position if there are no existing open or pending orders from any source, rather than just from their own EA (implicitly running on only one chart).

Yes sir, this is only one form, I´m at moment trying to create another form, that account for possible loss of money also (see 'How to calculate cost per lot ?' ). []´s. Gero.

 

Dear ALL,

first of all thank you for your HELP !!!

I need to write a more difficult EA that work in this way:

1st) EA open a SELL position when value is bigger than BB bands

2nd) EA open a BUY position when value is lower than BB bands

3rd) BUY and SELL can happen in the same time but no more operetion are suitable

4th) I can use this EA in several pair (maybe changing the MagicNumber piar by pair)

5th) EA will close position when take profit 2 pips (impossible to set TP because is to low)

ANyone can help me?

You can contact me also in Yahoo messenger (michele_ainardi@yahoo.it) or in MSN (nuvoloso@hotmail.com) or by Skype (michele_ainardi)

Thank you again!!

Michele Ainardi

 
michele_ainardi wrote >>

Dear ALL,

first of all thank you for your HELP !!!

I need to write a more difficult EA that work in this way:

1st) EA open a SELL position when value is bigger than BB bands

2nd) EA open a BUY position when value is lower than BB bands

3rd) BUY and SELL can happen in the same time but no more operetion are suitable

4th) I can use this EA in several pair (maybe changing the MagicNumber piar by pair)

5th) EA will close position when take profit 2 pips (impossible to set TP because is to low)

ANyone can help me?

You can contact me also in Yahoo messenger (michele_ainardi@yahoo.it) or in MSN (nuvoloso@hotmail.com) or by Skype (michele_ainardi)

Thank you again!!

Michele Ainardi

Hello,

FXCM has some free EAs, and some uses BB, see here if you like http://forexforums.dailyfx.com/mt4/68570-free-fxcm-expert-advisors.html .

[]´s,

Gero.

 
Gero.Gero wrote >>

Hello,

FXCM has some free EAs, and some uses BB, see here if you like http://forexforums.dailyfx.com/mt4/68570-free-fxcm-expert-advisors.html .

[]´s,

Gero.

Thank you Gero ... but I can not have the source file.

I want to see the code :(

I am thinking to this strategy and I would like to write my EA but I am not able :(

Michele

 
michele_ainardi wrote >>

Thank you Gero ... but I can not have the source file.

I want to see the code :(

I am thinking to this strategy and I would like to write my EA but I am not able :(

Michele

Hello,

Only a tip: to check if a price (or MA, etc...) has crossed the borders of a band ( or MA, etc...) use a simple "state machine", something like:

add to declarative:

#define UP 1

#define DOWN -1

#define NOCROSS 0



int cross = 0, state = 0;

add to start() or any other function:

price = ...; band = ...;
if( price > band)  
{    
    if( state == DOWN )
      cross = UP;    
    state = UP;  
  }
if( price < band )
{    
    if( state == UP )      
      cross = DOWN;    
    state = DOWN;
  }
  if( cross != NOCROSS )  
    {     
       if( cross == UP )     
         {          
             //do anything...     
         }     
       if( cross == DOWN )    
         {        
             //do anything...    
         }     
         cross = NOCROSS;  
    }

Of course this is for 1 cross only, if you want to catch the crosses for the 2 bands, and also to check if it´s inside (between) the bands you need to add more states as needed (UP_UPPERBAND, DOWN_UPPERBAND, UP_LOWERBAND, DOWN_LOWERBAND, CROSS_UP_UPPERBAND, CROSS_DOWN_UPPERBAND, CROSS_UP_LOWERBAND, CROSS_DOWN_LOWERBAND, INSIDE_BAND, etc... ).

[]´s,

Gero.