EA pin bar

EA pin bar

EA pin bar

hunt money

Active Member
131
115
Mình có file EA pin bar mql4 có đính kèm với một số file *.mqh, trong đó có 1 file mqh bị lỗi, bác nào pro về code MT4 vào sửa giúp mình với.
-------------------------------------------------------------

enum SRTypes
{
Daily,
Weekly,
DailyAndWeekly
};
extern string __trendfilter = " ------- Pinbar settings ------------";
extern bool Use50PercentRetracementEntry = true;
extern SRTypes SupportResistanceLines = Weekly;
include <CStrategy.mqh>
include <CSupportResistance.mqh>
//--------------------------------------------------------------------
class CPriceActionStrategy : public IStrategy
{
private:
CSupportResistance* _supportResistanceD1;
CSupportResistance* _supportResistanceW1;

int _indicatorCount;
CIndicator* _indicators[];
CSignal* _signal;
string _symbol;

public:
//--------------------------------------------------------------------
CPriceActionStrategy(string symbol)
{
_symbol = symbol;
_signal = new CSignal();
_supportResistanceD1 = new CSupportResistance(_symbol, PERIOD_D1);
_supportResistanceW1 = new CSupportResistance(_symbol, PERIOD_W1);

ArrayResize(_indicators, 10);
_indicatorCount = 0;
_indicators[_indicatorCount++] = new CIndicator(" Pinbar");
_indicators[_indicatorCount++] = new CIndicator("S&R");
if (Use50PercentRetracementEntry)
{
_indicators[_indicatorCount++] = new CIndicator("50%rt");
}
}

//--------------------------------------------------------------------
~CPriceActionStrategy()
{
delete _signal;
delete _supportResistanceD1;
delete _supportResistanceW1;

for (int i=0; i < _indicatorCount;++i)
{
delete _indicators;
}
ArrayFree(_indicators);
}

//--------------------------------------------------------------------
CSignal* Refresh()
{
double priceOpen = iOpen (_symbol, 0, 1);
double priceClose = iClose(_symbol, 0, 1);
double priceHi = iHigh (_symbol, 0, 1);
double priceLow = iLow (_symbol, 0, 1);
double pinbarRange = priceHi - priceLow ;
double priceRetracement = priceLow + (pinbarRange * 0.5);

double bodyLo = MathMin(priceOpen, priceClose);
double bodyHi = MathMax(priceOpen, priceClose);
double wickLoRange = MathAbs(bodyLo - priceLow);
double wickHiRange = MathAbs(priceHi - bodyHi);
double bodyRange = MathAbs(bodyHi - bodyLo);

double priceNow = MarketInfo(_symbol, MODE_BID);
double points = MarketInfo(_symbol, MODE_POINT);
double digits = MarketInfo(_symbol, MODE_DIGITS);
double mult = 1;
if (digits ==3 || digits==5) mult = 10;

_signal.Reset();

for (int i=0; i < _indicatorCount;++i)
{
_indicators.IsValid = false;
}

if (priceClose < priceOpen)
{
// red candle
// do we have a pinbar with a large upper wick ?
bool isPinBar = false;
if (wickHiRange >= 2 * bodyRange)
{
if (wickHiRange >= 2 * wickLoRange)
{
isPinBar = true;
}
}
if (isPinBar)
{
double pips = MathAbs(priceHi - bodyHi);
pips /= mult;
pips /= points;
_indicators[0].IsValid = isPinBar;

bool srValid = false;
double stopLoss = priceHi;
// and is it at a weekly S/R level ?
switch (SupportResistanceLines)
{
case Daily:
srValid = _supportResistanceD1.IsAtResistance(priceHi, pips, stopLoss);
break;

case Weekly:
srValid = _supportResistanceW1.IsAtResistance(priceHi, pips, stopLoss);
break;

case DailyAndWeekly:
srValid = _supportResistanceD1.IsAtResistance(priceHi, pips, stopLoss) ||
_supportResistanceW1.IsAtResistance(priceHi, pips, stopLoss);
break;
}
_indicators[1].IsValid = srValid;
_signal.IsSell = true;
_signal.StopLoss = stopLoss;

// check if price is now at a 50% retracement of the pinbar
if (Use50PercentRetracementEntry)
{
if ( priceNow >= priceRetracement && priceNow < stopLoss )
{
_indicators[2].IsValid = true;
}
}
}
}
else if (priceClose > priceOpen )
{
// green candle
// do we have a pinbar with a large lower wick ?
bool isPinBar = false;
if (wickLoRange >= 2 * bodyRange)
{
if (wickLoRange >= 2 * wickHiRange )
{
isPinBar=true;
}
}
if (isPinBar)
{
double pips= MathAbs(priceLow - bodyLo);
pips /= mult;
pips /= points;
_indicators[0].IsValid = isPinBar;

// and is it at a weekly S/R level ?
bool srValid = false;
double stopLoss = priceLow;
switch (SupportResistanceLines)
{
case Daily:
srValid = _supportResistanceD1.IsAtSupport(priceLow, pips, stopLoss);
break;

case Weekly:
srValid = _supportResistanceW1.IsAtSupport(priceLow, pips, stopLoss);
break;

case DailyAndWeekly:
srValid = _supportResistanceD1.IsAtSupport(priceLow, pips, stopLoss) ||
_supportResistanceW1.IsAtSupport(priceLow, pips, stopLoss);
break;
}

_indicators[1].IsValid = srValid;
_signal.IsBuy = true;
_signal.StopLoss = stopLoss;

// check if price is now at a 50% retracement of the pinbar
if (Use50PercentRetracementEntry)
{
if ( priceNow <= priceRetracement && priceNow > stopLoss )
{
_indicators[2].IsValid = true;
}
}
}
}

// do we have a pinbar
if (!_indicators[0].IsValid)
{
// no then we dont have a signal
_signal.IsBuy = false;
_signal.IsSell = false;
}
return _signal;
}

//--------------------------------------------------------------------
int GetIndicatorCount()
{
return _indicatorCount;
}

//--------------------------------------------------------------------
CIndicator* GetIndicator(int indicator)
{
return _indicators[indicator];
}

//--------------------------------------------------------------------
double GetStopLossForOpenOrder()
{
return 0;
}
};
 
 

Giới thiệu sách Trading hay
Phương Pháp Thực Chiến Hiệu Suất Cao Của Nhà Quán Quân Giao Dịch Tài Chính

Sách hướng dẫn phương pháp giao dịch hiệu suất cao của tác giả Robert Miner, người đã từng nhiều lần vô địch và đạt thứ hạng cao tại các cuộc thi trading toàn thế giới

BÌNH LUẬN MỚI NHẤT

AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

Back
Bên trên

Miễn trừ trách nhiệm

Tất cả nội dung trên website này đều vì mục đích cung cấp thông tin và không phải lời khuyên đầu tư.

Tại Việt Nam, giao dịch CFD forex có các rủi ro nhất định, trong đó bao gồm rủi ro về pháp lý. Độc giả nên tìm hiểu kỹ trước khi đưa ra quyết định tham gia.