Mój pierwszy robot. Mam problem z dodaniem funkcji ograniczającej 1 transakcje na świeczkę, kod się kompiluje, EA otwiera pozycje jednak mogą być jakieś tam drobne błędy - w końcu dopiero zaczynam.
Założenie jest takie, że muszą być minimum dwie świeczki (może być więcej) wewnątrz tej głównej.
Proszę o dopisanie tej funkcji ograniczającej jedną transakcję na bar (bo teraz to otwiera tyle ile razy cena przechodzi przez ten poziom) + MM, jeśli to nie będzie duży problem
Pozdrawiam

Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| InsideBars EA.mq4 |
//| Copyright 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double Lots = 0.1;
extern int mm = 0;
extern double RiskReward=1.5;
extern int StopLoss = 0;
extern int TakeProfit = 0;
extern int MagicNumber=0;
extern int shift=1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double digits=MarketInfo(Symbol(),MODE_DIGITS);
double spread=MarketInfo(Symbol(),MODE_SPREAD);
double BuyValue=0, SellValue=0;
BuyValue=0; SellValue=0;
double BuyPrice=0, SellPrice=0;
BuyPrice=0; SellPrice=0;
double Buy_StopLoss=0, Buy_TakeProfit=0;
Buy_StopLoss=0; Buy_TakeProfit=0;
double Sell_StopLoss=0, Sell_TakeProfit=0;
Sell_StopLoss=0; Sell_TakeProfit=0;
double BarHeight=0;
if (
((High[shift+1]<High[shift+2] && Low[shift+1]>Low[shift+2])
&& (High[shift]<High[shift+2] && Low[shift]>Low[shift+2])))
{
BuyPrice=High[shift+2];
SellPrice=Low[shift+2];
if (Bid==BuyPrice){
BuyValue=1;
BarHeight=BuyPrice-SellPrice;
Buy_StopLoss=SellPrice-spread*Point;
Buy_TakeProfit=BuyPrice+BarHeight*RiskReward;
}
else if (Bid==SellPrice){
SellValue=1;
BarHeight=BuyPrice-SellPrice;
Sell_StopLoss=BuyPrice+spread*Point;
Sell_TakeProfit=SellPrice-BarHeight*RiskReward;
}
}
double buy_sl=NormalizeDouble(Buy_StopLoss, digits);
double buy_tp=NormalizeDouble(Buy_TakeProfit, digits);
double sell_sl=NormalizeDouble(Sell_StopLoss, digits);
double sell_tp=NormalizeDouble(Sell_TakeProfit, digits);
if (BuyValue>0) {
OrderSend(Symbol(),OP_BUY,Lots,Ask,0,buy_sl,buy_tp,0,0);
}
if (SellValue>0) {
OrderSend(Symbol(),OP_SELL,Lots,Bid,0,sell_sl,sell_tp,0,0);
}
return(0);
}
//+------------------------------------------------------------------+