코딩하는 방법? - 페이지 186

 

좋아, 원래 질문에:

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Magenta

extern int MAPeriod=200;

extern double iController = 1.386;

//---- buffers

//double Memory[200];

double ExtMapBuffer1[];

int limit = 200;

//---- variables

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorBuffers(1);

//---- drawing settings

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);

IndicatorShortName( "Antaria_Rising");

//---- initialization done

return(0);

}

int start()

{

int limit;

//ExtMapBuffer1[1] = ExtMapBuffer1[0];

//ExtMapBuffer1[0] = iController;

for(int i=(0); i<=(limit-1); i++)

{

ExtMapBuffer1 = ExtMapBuffer1;

}

ExtMapBuffer1[0] = iController;

return(0);

}[/CODE]

Above is the code for the indicator. Simply, it draws a line that should be updatable via the EA using the intiially mentioned code:

[CODE]temp = iCustom(NULL, 0, "AntariaRising", 200, 1.2, 0, 0); //temp not used. Function returns a double

나중에 중지 라인으로 사용할 수 있도록 해당 변수가 추적하는 incicator 개체로 실제로 업데이트할 수 있도록 하는 코드의 마지막 부분을 교체하고 싶습니다. 그러나 나머지 코드는 관련이 없습니다. 위의 기능 을 실행할 때 antaria가 1.39 또는 시작하는 위치에서 1.2로 위치를 이동할 것으로 예상합니다. 200 변수를 사용했는지 기억이 나지 않습니다. 내 머리글과 바닥글 주석을 잘랐다고 생각하지만 전체 슬레이브 표시기가 거기에 있습니다. 이는 바로 위 코드에서 의미하는 AntariaRising입니다.

이것은 표시기 개체와 통신하는 유일한 기능이며 다른 영역의 값을 읽는 데 사용합니다.

 

표시기 코드 정보. 틀렸어.

변수 제한은 0과 동일합니다.

문자열 제거:

정수 제한;

출발점에서().

 

이 코드를 도와주세요 pls

나는 누군가가 이 코드로 나를 도와주기를 원합니다. 원할 때 거래를 열지만 자동으로 닫히므로 다시 건너지 않을 때 닫히지 않는 정지 손실로 거래하기를 원합니다. 이것은 코드입니다

//+----------------------------------------------- -------------------+

//| JR300.mq4 |

//| 사랑 |

//| 외환 포럼 | 외환 거래 | 메타 트레이더 포럼 |

//+----------------------------------------------- -------------------+

#재산권 "원러브"

#속성 링크 "https://www.forex-tsd.com"

//---- 입력 매개변수

외부 이중 TakeProfit=250.0;

외부 이중 로트=0.1;

외부 이중 TrailingStop=35.0;

//+----------------------------------------------- -------------------+

//| 전문가 초기화 기능 |

//+----------------------------------------------- -------------------+

정수 초기화()

{

//----

//----

리턴(0);

}

//+----------------------------------------------- -------------------+

//| 전문가 초기화 해제 기능 |

//+----------------------------------------------- -------------------+

정수 초기화()

{

//----

//----

리턴(0);

}

int 교차 (이중 line1 , double line2)

{

정적 int last_direction = 0;

정적 int 현재 방향 = 0;

if(line1>line2)current_direction = 1; //위로

if(줄1<줄2)현재방향 = 2; //아래에

if(current_direction != last_direction) //변경됨

{

마지막 방향 = 현재 방향;

반환(last_direction);

}

또 다른

{

리턴(0);

}

}

//+----------------------------------------------- -------------------+

//| 전문가 시작 기능 |

//+----------------------------------------------- -------------------+

정수 시작()

{

//----

int cnt, 티켓, 합계;

더블 shortEma, longEma;

if(막대<100)

{

Print("100개 미만의 막대");

리턴(0);

}

if(테이크프로핏<10)

{

Print("TakeProfit이 10 미만입니다.");

리턴(0); // TakeProfit 확인

}

shortEma = iMA(NULL,0,1,0,MODE_EMA,PRICE_CLOSE,0);

longEma = iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,0);

int isCrossed = 교차(shortEma,longEma);

총계 = OrdersTotal();

if(총 < 1)

{

if(isCrossed == 1)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,

"내 EA",12345,0,녹색);

if(티켓>0)

{

if(OrderSelect(티켓,SELECT_BY_TICKET,MODE_TRADES))

Print("구매 주문이 열렸습니다 : ",OrderOpenPrice());

}

else Print("구매 주문 열기 오류: ",GetLastError());

리턴(0);

}

if(isCrossed == 2)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,

Bid-TakeProfit*Point,"My EA",12345,0,Red);

if(티켓>0)

{

if(OrderSelect(티켓,SELECT_BY_TICKET,MODE_TRADES))

Print("판매 주문이 열렸습니다 : ",OrderOpenPrice());

}

else Print("판매 주문 열기 오류: ",GetLastError());

리턴(0);

}

리턴(0);

}

for(cnt=0;cnt<전체;cnt++)

{

주문 선택(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY) // 롱 포지션 오픈

{

// 닫아야 하나?

if(isCrossed == 2)

{

OrderClose(OrderTicket(),OrderLots(), 입찰, 3, 보라색);

// 닫기 위치

리턴(0); // 출구

}

// 후행 정지 확인

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-

Point*TrailingStop,OrderTakeProfit(),0,Green);

리턴(0);

}

}

}

}

else // 숏 포지션으로 이동

{

// 닫아야 하나?

if(isCrossed == 1)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,바이올렛);

// 닫기 위치

리턴(0); // 출구

}

// 후행 정지 확인

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) ||

(OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,

OrderTakeProfit(),0,빨간색);

리턴(0);

}

}

}

}

}

}

리턴(0);

}

//+----------------------------------------------- -------------------+

 

이 시도:

//+------------------------------------------------------------------+

//| JR300.mq4 |

//| onelove |

//| Forex Forum | Forex Tsd | Metatrader Forum |

//+------------------------------------------------------------------+

#property copyright "oneLove"

#property link "https://www.forex-tsd.com"

//---- input parameters

extern double TakeProfit=250.0;

extern double StopLoss=100.0;

extern double Lots=0.1;

extern double TrailingStop=35.0;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

int Crossed (double line1 , double line2)

{

static int last_direction = 0;

static int current_direction = 0;

if(line1>line2)current_direction = 1; //up

if(line1<line2)current_direction = 2; //down

if(current_direction != last_direction) //changed

{

last_direction = current_direction;

return (last_direction);

}

else

{

return (0);

}

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

int cnt, ticket, total;

double shortEma, longEma;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

shortEma = iMA(NULL,0,1,0,MODE_EMA,PRICE_CLOSE,0);

longEma = iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,0);

int isCrossed = Crossed (shortEma,longEma);

total = OrdersTotal();

if(total < 1)

{

if(isCrossed == 1)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+ TakeProfit*Point,

"My EA",12345,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))

Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

if(isCrossed == 2)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,

Bid-TakeProfit*Point,"My EA",12345,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))

Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

//if(isCrossed == 2)

//{

//OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ;

// close position

//return(0); // exit

//}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-

Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

//if(isCrossed == 1)

//{

//OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ;

// close position

//return(0); // exit

//}

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) ||

(OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,

OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

//+------------------------------------------------------------------+
 

감사해요

Roger09:
이 시도:
//+------------------------------------------------------------------+

//| JR300.mq4 |

//| onelove |

//| Forex Forum | Forex Tsd | Metatrader Forum |

//+------------------------------------------------------------------+

#property copyright "oneLove"

#property link "https://www.forex-tsd.com"

//---- input parameters

extern double TakeProfit=250.0;

extern double StopLoss=100.0;

extern double Lots=0.1;

extern double TrailingStop=35.0;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

int Crossed (double line1 , double line2)

{

static int last_direction = 0;

static int current_direction = 0;

if(line1>line2)current_direction = 1; //up

if(line1<line2)current_direction = 2; //down

if(current_direction != last_direction) //changed

{

last_direction = current_direction;

return (last_direction);

}

else

{

return (0);

}

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

int cnt, ticket, total;

double shortEma, longEma;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

shortEma = iMA(NULL,0,1,0,MODE_EMA,PRICE_CLOSE,0);

longEma = iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,0);

int isCrossed = Crossed (shortEma,longEma);

total = OrdersTotal();

if(total < 1)

{

if(isCrossed == 1)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+ TakeProfit*Point,

"My EA",12345,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))

Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

if(isCrossed == 2)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,

Bid-TakeProfit*Point,"My EA",12345,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))

Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

//if(isCrossed == 2)

//{

//OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ;

// close position

//return(0); // exit

//}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-

Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

//if(isCrossed == 1)

//{

//OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ;

// close position

//return(0); // exit

//}

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) ||

(OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,

OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

//+------------------------------------------------------------------+

감사합니다 roger09 신의 축복이 있기를

 

감사합니다 Roger, 시작 기능 에서 두 번째 제한 선언을 제거했습니다. 컴파일러가 그것을 허용했다는 사실에 놀랐지만 내 프로그램에 눈에 띄게 영향을 미치지는 않았습니다.

여전히 내 EA에서 해당 표시기의 실행 중인 인스턴스를 변경하는 방법을 잘 모르겠습니다. API가 현재 실행 중인 표시기에 정보를 전달할 수 없도록 하는 방법 또는 최소한 확인하는 방법이 있으면 감사하겠습니다.

감사해요.

 
yingli:
여기에서 도움을 받기 위해 이 트레드를 시작했습니다.첨부된 표시기에 대한 코딩을 배우고 있습니다.그러나 제대로 작동하지 않았습니다.누군가 도와줄 수 있습니까? 이것은 매우 신뢰할 수 있는 지표이며 누군가 EA를 만들 수 있다면 거의 성배입니다.

기본 원리는 다음과 같습니다.

1.빨간 화살표가 나타나면 매도 포지션을 연다.

2흰색 화살표가 나타나면 매수 포지션을 열고 모든 매도 포지션/포지션을 자동으로 닫습니다.

3. 모든 기간에 신청하십시오.

4. 정지 손실 없음,

5.주문 기능 추가.

응답을 기대합니다!

//+----------------------------------------------- -------------------+

//| IINWMARROWS.mq4 |

//| EMA_CROSS.mq4 기반 |

//| Copyright ?2006, MetaQuotes Software Corp. |

//| Forex 거래 소프트웨어: Forex 거래 플랫폼 MetaTrader 4 |

//| Iin Zulkarnain이 마지막으로 수정 |

//+----------------------------------------------- -------------------+

#property copyright "Copyright ?2006, MetaQuotes Software Corp."

#속성 링크 "http://www.metaquotes.net"

//----

#속성 표시기_차트_창

#속성 표시기_버퍼 2

#property indicator_color1 흰색

#property indicator_color2 빨간색

#속성 표시기_너비1 2

#속성 표시기_너비2 2

//----

더블 크로스업[];

더블 크로스다운[];

extern int FasterMode=3; //0=sma, 1=ema, 2=smma, 3=lwma

extern int FasterMA= 3;

extern int 느린 모드 = 3; //0=sma, 1=ema, 2=smma, 3=lwma

extern int SlowerMA= 3;

//+----------------------------------------------- -------------------+

//| 커스텀 인디케이터 초기화 기능 |

//+----------------------------------------------- -------------------+

정수 초기화()

{

//---- 표시기

SetIndexStyle(0, DRAW_ARROW, EMPTY);

SetIndexArrow(0, 233);

SetIndexBuffer(0, 크로스업);

SetIndexStyle(1, DRAW_ARROW, EMPTY);

SetIndexArrow(1, 234);

SetIndexBuffer(1, 크로스다운);

//----

리턴(0);

}

//+----------------------------------------------- -------------------+

//| 커스텀 인디케이터 초기화 해제 기능 |

//+----------------------------------------------- -------------------+

정수 초기화()

{

//----

//----

리턴(0);

}

//+----------------------------------------------- -------------------+

//| 사용자 지정 표시기 반복 기능 |

//+----------------------------------------------- -------------------+

정수 시작()

{

int 제한, i, 카운터;

더블 fastMAnow, slowMAnow, fastMAprevious, slowMAprevious, fastMAafter, slowMAafter;

이중 범위, AvgRange;

int counted_bars=IndicatorCounted();

//---- 가능한 오류 확인

if(counted_bars<0) return(-1);

//---- 마지막으로 계산된 막대가 다시 계산됩니다.

if(counted_bars>0) counted_bars--;

//----

limit=막대-counted_bars;

for(i=0; i<=한계; i++)

{

카운터 = 나;

범위=0;

평균 범위=0;

for(카운터=i ;카운터<=i+9;카운터++)

{

AvgRange=AvgRange+MathAbs(높음[카운터]-낮음[카운터]);

}

범위=AvgRange/10;

fastMAnow=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);

fastMAprevious=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);

fastMAafter=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);

//----

slowMAnow=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i);

slowMAprevious=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i+1);

slowMAafter=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i-1);

if ((fasterMAnow > slowMAnow) && (fasterMAprevious slowMAafter))

{

CrossUp=낮음 - 범위*0.5;

}

else if ((fasterMAnow slowMAprevious) && (fasterMAafter < slowMAafter))

{

CrossDown=높음 + 범위*0.5;

}

}

리턴(0);

}

//+----------------------------------------------- -------------------+올바른 코딩 방법을 배우기 위한 이 스레드,

누구든지 이 표시기에 대한 경고를 코딩하는 데 도움을 줄 수 있습니까? 정말 멋집니다.

 

George's Oscar Calculator - 누구든지 이에 대한 지표를 코딩할 수 있습니까?

안녕 여러분,

George Smith의 Forex Made-EZ에 대해 잘 아는 사람이 있는지 모르겠습니다.

나는 현재 그의 작업을 검토하고 있으며 그가 사용하는 오스카 오실레이터에 대한 지표를 코딩한 사람이 있는지 궁금합니다.

공식은

A = 마지막 8개 막대 중 가장 높은 값(이 막대 포함)

let B = 지난 8개 막대 중 가장 낮은 최저점(이 막대 포함)

let C = 현재 막대 종가

let X = 이전 오실레이터 수치(Oscar)

오늘날의 "거친" 오실레이터는 (CB)를 (AB)로 나눈 값에 100을 곱한 것과 같습니다.

다음으로 우리는 대략적인 숫자(Y라고 부르자)를 다음과 같이 "매끄럽게" 합니다.

최종 오실레이터 번호 = ((X 나누기 3) 곱하기 2), 더하기 (Y 나누기 3).

누구든지 이것을 코딩했거나 코딩할 수 있다면 매우 감사할 것입니다.

스티브 안부

 

역 후행 정지

안녕,

아이디어에 도움이 필요합니다.

내 EA에서 후행 정지(3단계 후행)를 사용하고 있지만 손실을 보호하기 위해 거꾸로 하고 싶습니다.

나는 설명하려고 노력할 것이다:

초기 손절매 와 함께 주문을 엽니다.

거래가 손실 방향으로 15핍 이동하고 10핍으로 돌아오면 거래를 종료합니다(첫 번째 단계).

거래가 손실 방향으로 30핍 이동하고 15핍으로 돌아오면 거래를 닫습니다(두 번째 단계).

이 같은.

도와 주셔서 감사합니다

 
dedreko:
안녕,

아이디어에 도움이 필요합니다.

내 EA에서 후행 정지(3단계 후행)를 사용하고 있지만 손실을 보호하기 위해 거꾸로 하고 싶습니다.

나는 설명하려고 노력할 것이다:

초기 손절매와 함께 주문을 엽니다.

거래가 손실 방향으로 15핍 이동하고 10핍으로 돌아오면 거래를 종료합니다(첫 번째 단계).

거래가 손실 방향으로 30핍 이동하고 15핍으로 돌아오면 거래를 닫습니다(두 번째 단계).

이 같은.

도와 주셔서 감사합니다

이것은 나에게 새로운 것입니다.

따라서 손실을 입은 거래 마감은 항상 다시 반등할 때까지 기다려야 합니까?

반송이 되지 않는다면?

초기 SL에서 마감할까요?