매우 간단한 EA를 만드는 데 도움이 필요합니다. - 페이지 3

 

//+------------------------------------------------------------------+
//| Stepper.mq4 |
//| doshur |
//| www.doshur.com |
//+------------------------------------------------------------------+
#property copyright "doshur"
#property link "www.doshur.com"

extern int TakeProfit = 5;
extern int Range = 20;
extern int Risk = 2;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
  {
  return(0);
  }

int deinit()
  {
  return(0);
  }

int start()
  {
//----
  static bool ToTrade = false;
  static bool FirstTrade = true;

  double PrevLow = iLow(Symbol(), 0, 1);
  double PrevHigh = iHigh(Symbol(), 0, 1);
  double PrevRange = (PrevHigh - PrevLow) / Point;

  if(NewBar())
  {
  if(FirstTrade == false)
  {
  if(PrevRange >= Range)
  ToTrade = true;
  else
  ToTrade = false;
  }
  else
  {
  FirstTrade = false;
  }
  }

  if(ToTrade)
  {
  if(COT(1) < 1)
  {
  if(Ask > PrevHigh)
  OrderSend(Symbol(), OP_BUY, MM(PrevRange, Risk), Ask, 3, PrevLow, Ask + TakeProfit * Point, "Stepper - BUY", 57390, 0, Blue);
  }

  if(COT(2) < 1)
  {
  if(Bid < PrevLow)
  OrderSend(Symbol(), OP_SELL, MM(PrevRange, Risk), Bid, 3, PrevHigh, Bid - TakeProfit * Point, "Stepper - SELL", 57391, 0, Red);
  }
  }
//----
  return(0);
  }
//+------------------------------------------------------------------+

//---- Check Is New Bar
bool NewBar()
{
  static datetime PrevBar;

  if(PrevBar < Time[0])
  {
  PrevBar = Time[0];
  return(true);
  }
  else
  {
  return(false);
  }

  return(false);
}

//---- Check Open Trades
int COT(int BS)
{
  int Buys = 0, Sells = 0;

  for(int cnt_COT = 0; cnt_COT < OrdersTotal(); cnt_COT++)
  {
  OrderSelect(cnt_COT, SELECT_BY_POS, MODE_TRADES);

  if(OrderType() == OP_BUY && OrderSymbol() == Symbol()) Buys++;
  if(OrderType() == OP_SELL && OrderSymbol() == Symbol()) Sells++;
  }

  if(BS == 1) return(Buys);
  if(BS == 2) return(Sells);
}

//---- Money Management
double MM(int SL, int RK)
{
  double rLots = NormalizeDouble(AccountBalance() / 1000 * RK / SL, 1); // Risk ?% of balance

  if(rLots < 0.1) rLots = 0.1;

  return(rLots);
}


문제 및 기타 문제를 극복하기 위해 첫 번째 실행을 구현했습니다.

코드를 테스트하지 않았습니다

Pls는 다른 수정안을 테스트하고 나열합니다.

[삭제]  

is there away where we can modify the stop loss to so 15 or 20 instead of the other end of the candle?

 

crazfoto 2008.12.02 08:27 양초의 다른 쪽 끝 대신 손절매를 15 또는 20으로 수정할 수 있는 곳이 있습니까?


네. 것이 가능하다.

[삭제]  

2시간 평균인가요? 또는 30min의 다른 버전?


2시간 평균이면 어제 거래를 실행하지 않았습니다.

 
crazfoto :

2시간 평균인가요? 또는 30min의 다른 버전?


2시간 평균이면 어제 거래를 실행하지 않았습니다.

내 코드를 의미합니까?

요청하신 대로 30분 동안 구현되었습니다.

[삭제]  

오. 내 잘못이야. 지금 테스트하겠습니다.


도와주셔서 정말 감사합니다. 나는 4시간 차트에서 위트를 연주했다. 4시간 차트에서 스톱을 15 또는 20핍으로 변경하면 결과가 좋을 것이라고 생각합니다. 그리고 내가 무엇을 하던지.

[삭제]  
오프라인 2시간 차트에서 작동합니까? 많은 사람들이 오프라인 차트에서 EA를 사용하는 데 문제가 있는 것을 봅니다.
[삭제]  
1시간 차트에서만 작동합니다.
[삭제]  
좋아요. 30분 차트에서는 작동하지만 결제할 때마다 계속 주문을 입력합니다. 따라서 새 주문을 입력하기 전에 30분 촛불이 형성되기를 기다리지 않습니다.
 

이런.

일단 입력하면 비활성화하는 것을 잊었습니다.

내가 코드를 수정하자