거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

Singleton Example - MetaTrader 4용 expert

조회수:
8224
평가:
(17)
게시됨:
2015.11.18 10:20
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

This is a working singleton code example. The sole purpose of this post is to provide a working code sample of a singleton object. A singleton object is created when there 'can be only one' of the object. This is accomplished by making an object's constructor private, and ensuring assignment and copy operations are also private.

I was working on an EA and identified that an object should never have more than one copy. I don't expect the EA to ever get large enough for it to actually matter that a singleton is used, but I like the clarity in the code for the object's type. Some programmers argue against the use of singletons, but I think the technical reasons for not using them are mostly resolved with newer compiler technology. It didn't seem like anyone had provided an example of this functionality in this environment — I found only an old reference in the Code Base from before private static variable initialization was supported by the compiler — as you can see in this example, this functionality works well today.

Comments or contributions for improving the code are always welcome.

Running Singleton Example

Simple Copier Simple Copier

Copying utility with minimal functionality.

Simple Levels Simple Levels

EA opens trades from support and resistance levels which were set by a trader.

Millenium Code Millenium Code

This program is a basic version of the original code of relatively simple system Millenium.

Cidomo_v.1 Cidomo_v.1

The strategy of this EA is daily breakout which is compare previous high or low previous day candle then place a pending order for breakout.