how to put custom indicator to ea? - page 2

 

hello whroeder..


sometimes work well in month august, but error in march or other month...

so i change my normalize code to your coding..

OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl

i change some ordersend code, but not work well:

1. ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask - StopLose * pips2dbl,Ask+TakeProfit * pips2dbl,0,Green) ;

2. ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3* pips2points,Ask-StopLose*pips2dbl,Ask+TakeProfit*pips2dbl,0,Green) ;

not all position opened,

some position get error 4107 and invalid price..


what should i change?

thx..

 
hardyyanto:

hello whroeder..


some position get error 4107 and invalid price..

what should i change?

Without seeing all the code, impossible to know. Are you returning from Start. Do you have RefreshRate() between each server call.

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3* pips2points,Ask-StopLose*pips2dbl,Ask+TakeProfit*pips2dbl,0,Green) ;

For a buy, you open at the Ask, but the SL/TP are relative to the Bid and must be at least MarketInfo(Symbol(), MODE_STOPLEVEL)*Point
 

oh.. i am not have refreshrate()..

i never see that in other ea..

my ea code like this after using your code:


extern double TakeProfit = 50;
extern double StopLose = 40;
extern double Lots = 0.1;
double pips2points, pips2dbl;
int Digits.pips;
double
Pip;
//+------------------------------------------------------------------+

int init(){
if (Digits == 5 || Digits == 3){
pips2dbl = Point*10;
pips2points = 10;
Digits.pips = 1;
}
else {
pips2dbl = Point;
pips2points = 1;
Digits.pips = 0; }

}

//+------------------------------------------------------------------+
int start()
{
int total, ticket;
if(New_Bar()){
if((Open[2]>Close[2]) && (Open[1]>Close[1])){
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3* pips2points,Ask-StopLose*pips2dbl,Ask+TakeProfit*pips2dbl,0,Green) ;
}
}
return(0);
}



//+------------------------------------------------------------------+
bool New_Bar()
{
static datetime New_Time=0;
if(New_Time!=Time[0]){
New_Time=Time[0];
return(true);
}
return(false);

}



i saw many ea using "Ask" if want to doing buy..

and "Bid" for sell..

i think, maybe in ordersend that have wrong...

so what should i do?

thx..

 
  1. hardyyanto:

    oh.. i am not have refreshrate()..

    i never see that in other ea..

    Only necessary between multiple server calls, after sleep, or in EAs that don't return from start.

  2. You've been asked, TWICE

  3. Buy at the Ask. The stops are relative to the Bid. Your orderSend is wrong but that would be a problem only if the stops are near the spread in size. Yours are 10X.
  4. Some brokers don't allow stops to be set with the initial orderSend. You'll need to OrderSend/OrderSelect/RefreshRates/OrderModify
 


You've been asked, TWICE

oh... sory.. the src is in here..

yesterday i think u ask me to select src in metatrader, so not found..

hehe.. so now, just to know it's in this message box...

hehe.


.Some brokers don't allow stops to be set with the initial orderSend. 
You'll need to OrderSend/OrderSelect/RefreshRates/OrderModify
my broker is fxopen, so must using code except ordersend ya?
orderselect that like :
  OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
is it like that? 

and ordermodify for using trailingstop..
is it right?
i never using them, only always see in other ea..
 

hello roeder..

i am using this code again:

int init()
{
Pip = Point;
if(Digits==3||Digits==5)Pip*=10;
TakeProfit *= Pip;
StopLose *= Pip;

}

ticket=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,4),3,NormalizeDouble(Ask-StopLose,Digits),NormalizeDouble(Ask+TakeProfit,Digits),0,Green) ;


suddendly can work again from 1 jan 2010- sept 2010..

maybe open position based of custom indicator that make the problem..

because must using buffer ya, i still not undestand about buffer..

so i must many try..

do u know where the link that teach about custom indicator that using many formula, then put to expert advisor?

example indicator using high formula like pivot multiframe...

thx..

Reason: