How to code? - page 246

 
linwood2010:
Could someone tell me how to add stoploss for following code.

Thank you.

say you wanna put 20 pips stoploss to a limit buy you would change the code as

OrderSend(Symbol(),OP_BUYLIMIT,Lots,OpenPrice,0,OpenPrice-20*Point, ClosePrice,"",MAGIC,0,Blue);

-guyver

 

how to make an EA backtest itself?

Hi, I am currently using iExpertAdvisor's Visual Trader Studio to make an EA... I was wondering if it's possible to have an EA backtest itself, all by itself?

For example, it will have indicators to work with and as it encounters the market, it will continuously backtest itself with the incoming ticks and set its indicator parameters to an optimal state to make profitable trades.

 

StopLoss Percentage

Does anyone have a stoploss code that is a percentage of the equity or balance free margin?

Balance 100

10% SL 10

TickValue 9.5

Lot Size 0.01

TickSize 0.095

SL in pips 105.2632

I think that's right. I am looking for it to able to be applied to multiple pairs.

Any help would be good.

Cheers

Beno

 

Help

Could someone please code HIDE TAKE PROFIT for this version of blessing or help me in this direction. Thanks

Files:
 

error opening buy order : no error

anyone know what this means? I am transition from a 4 digit to 5 digit for interbank and cant get it to open a trade.

below is my init function. below that is the order function..

Does anyone have any ideas what to do differently???? HELP!

Pl ease don't send me the weblinks to update the ea .. I tried those already!

//+------------------------------------------------------------------

int init()

{

if (Digits == 3 || Digits == 5)

{

point = Point*10;

}

else

{

point = Point;

}

return(0);

}

int OpenOrder(int type)

{

int ticket=0;

int err=0;

int c = 0;

if(type==OP_BUY)

{

for(c = 0 ; c < NumberOfTries ; c++)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*point,Ask+TakeProfit*point,ExpertComment,MagicNumber,0,Yellow);

err=GetLastError();

if(err==0)

{

break;

}

else

{

if(err==4 || err==137 ||err==146 || err==136) //Busy errors

{

Sleep(5000);

continue;

}

else //normal error

{

break;

}

}

}

}

 

First of all, Interbank FX does not allow stoplosses or takeprofit anymore in the ticket to buy or sell. This would stop the trade immediately. You must have these set at 0.

error 4=Trade server is busy.

error 137=Broker is busy.

error 146=Trade context is busy.

error 136=Off quotes.

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,ExpertComment, MagicNumber,0,Yellow);

Check with InterbankFX on how the Slippage is to be set for 5-digit. You may have to add an additional 0 to the slippage number, i.e. slippage of 3 may have to be 30 in the 5 digit platform.

Good luck!

 

no, stop loss is kind of nuts in trading but thanks... I did not know this !

 

Divergence

I need help coding a simple divergence EA. i have found several EA that trade divergence but none the way that i would like.

I would live the EA to trade divergence according to the Divergence indicator that i have.

and i only want the EA to trade true divergences ( the divergences that show a possible trend reversal indicated by a solid colored line by the indicator) that occur outside of the support and resistance.

all it should need are simple inputs like

-timer

SwingHigh/LowStoploss

-TpPips

-LotSize

i have included the indicators needed and pictures for examples.

the first picture is of a Confirmed trade. and the second picture would not be a confirmed trade. due to the fact that the divergence did not occur outside of the support and resistance.

Please can anyone help me?

 

Custom Indicator

Hi,

I have programmed a customised indicator.

Everythink works perfekt but the last buffer isn't drawn and I can't understand why!

First try:

BuyBuffer[k] = (WL+WS)/2;

if(SumBuffer[k]>WL)

if(Sum2Buffer[k]<WL)

{

BuyBuffer[k] = EMPTY_VALUE;

}

So everything works fine. I see my line at the high of (WL+WS)/2 and on some short lines (they are about 2 or 3mm) I see the interrupts of the line (=the EMPTY_VALUE)

NOW I want to chance, that means I only want to draw the short lines if the conditions are true:

BuyBuffer[k] = EMPTY_VALUE;

if(SumBuffer[k]>WL)

if(Sum2Buffer[k]<WL)

{

BuyBuffer[k] = (WL+WS)/2;

}

But now, I can't see any line - nothing! And I can't understand it!!

Now I tried another way.

I changed the

SetIndexStyle into "DRAW_ARROW"

and here

if(SumBuffer[k]>WL)

if(Sum2Buffer[k]<WL)

{

BuyBuffer[k] = SYMBOL_ARROWUP;

}

Now my problems are:

1.My indicator is in an seperate_window from 0 to 100 but the Symbol is drawn at the high of 253.707. How can I change it??

2.I always get a cross as symbol even though I wrote SYMBOL_ARROWUP and SYMBOL_ARROWDOWN

I hope you can help my!

 

Help: how to write EA close order wnen it profit 2 pip???

Hi all,

Some body can help me :

how to write EA close order wnen it profit 2 pip???

i want write EA auto close order when it profit 2 pip and loss 1 USD, because i trade with 0.01 lot.

help me please!!! thanks u so much!!!