Mam problem z otwieraniem pozycji SELL przy warunku jeżeli cena jest równa odległości 20 pipsów od MA.
Nie wiem co źle robie, ponieważ gdy ustawie warunek cena jest niższa lub równa odległości 20 pipsów od MA zlecenia zostają otwarte.
Kod: Zaznacz cały
extern int Period3=30;
extern int Deviations3=2;
extern double Lot = 0.01;
extern double StopLoss = 100;
extern double TakeProfit = 10;
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double a = Ask;
double ma;
ma=iMA(NULL,0,Period3,Deviations3,MODE_SMA,PRICE_CLOSE,0);
double midPrice = (ma - 20*Point);
Alert ("cena midDistance: ",midPrice);
if (a==midPrice)
{
OrderSend(Symbol(),1,Lot,Bid,2,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",0,Red);
}
return(0);
}