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

 

암호

cja:
안녕하세요 mladen님

이거 볼 시간 있나요?

친절한 인사 CJA

안녕하세요 mladen님

할 일 목록에서 이를 제거할 수 있도록 후행 코드 요청에 대한 솔루션을 얻었음을 알려드리는 간단한 메모입니다.

감사합니다

 

문제를 해결하셨다니 다행입니다

더 행복한 코딩과 거래

cja:
안녕하세요 mladen님

할 일 목록에서 이를 제거할 수 있도록 후행 코드 요청에 대한 솔루션을 얻었음을 알려드리는 간단한 메모입니다.

감사합니다
 

안녕,

내 ea의 마지막 마감 주문이 이익인지 손실인지 확인 해야 합니다.

EA의 마지막 2개 클로즈드 손익 오더를 확인하고 합산해볼까 하는 생각이 들었습니다.

문제는 동일한 계정에 여러 개의 EA가 있으므로 특정 MagicNumber로 History 순서를 확인해야 한다는 것입니다. 여러 모드에서 시도하지만 성공하지 못합니다.

도와주세요??

고맙습니다

 

다시오

함수 는 마지막으로 마감된 주문 이익을 반환합니다(보다시피 매직 넘버를 매개변수로 지정할 수 있으므로 여러 인스턴스의 문제를 해결할 수 있습니다).

double lastOrderProfit(int magicNumber=0)

{

datetime lastTime = 0;

double lastProfit = 0;

for(int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==false) break;

if (magicNumber!=0)

if (OrderMagicNumber() != magicNumber) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderCloseTime() <= lastTime) continue;

lastTime = OrderCloseTime();

lastProfit = OrderProfit()+OrderSwap()+OrderCommission();

}

return(lastProfit);

}

함수의 반환값이 양수인지 음수인지만 확인하면 됩니다.

dasio:
안녕,

내 ea의 마지막 마감 주문이 이익인지 손실인지 확인해야 합니다.

EA의 마지막 2개 클로즈드 손익 오더를 확인하고 합산해볼까 하는 생각이 들었습니다.

문제는 동일한 계정에 여러 개의 EA가 있으므로 특정 MagicNumber로 History 순서를 확인해야 한다는 것입니다. 여러 모드에서 시도하지만 성공하지 못합니다.

도와주세요??

고맙습니다
 
mladen:
다시오

이 함수는 마지막으로 마감된 주문 이익을 반환합니다(보다시피 매직 넘버를 매개변수로 지정할 수 있으므로 여러 인스턴스의 문제를 해결할 수 있습니다).

double lastOrderProfit(int magicNumber=0)

{

datetime lastTime = 0;

double lastProfit = 0;

for(int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==false) break;

if (magicNumber!=0)

if (OrderMagicNumber() != magicNumber) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderCloseTime() <= lastTime) continue;

lastTime = OrderCloseTime();

lastProfit = OrderProfit()+OrderSwap()+OrderCommission();

}

return(lastProfit);

}
함수의 반환값이 양수인지 음수인지만 확인하면 됩니다.

그래서 나는 내 magicnumber로 함수 를 호출하기만 하면 되며 결과적으로 내 ea의 마지막 마감 주문의 이익이 발생합니까? 오른쪽??

 

네 맞아요

dasio:
그래서 나는 내 magicnumber로 함수를 호출하기만 하면 되며 결과적으로 내 ea의 마지막 마감 주문의 이익이 발생합니까? 오른쪽??
 
mladen:
네 맞아요

고맙습니다.

하지만 내가 ea를 시작했는데 히스토리에 순서가 없다면 내 ea가 포지션을 닫았을 때만 그 기능 을 어떻게 불러낼 수 있습니까?

 

그런 다음 이 기능을 먼저 사용하십시오.

int closedSoFarForMagic(int magicNumber=0)

{

int closedSoFar=0;

for(int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==false) break;

if (magicNumber!=0)

if (OrderMagicNumber() != magicNumber) continue;

if (OrderSymbol() != Symbol()) continue;

closedSoFar++;

}

return(closedSoFar);

}

ClosedSoFarForMagic() > 0이면 이력에 특정 매직 넘버 에 대해 이미 마감된 주문이 있다는 것을 알고 마지막 주문 이익을 확인할 수 있습니다.

dasio:
고맙습니다. 하지만 내가 ea를 시작했는데 히스토리에 순서가 없다면 내 ea가 포지션을 닫았을 때만 그 기능을 어떻게 불러낼 수 있습니까?
 

vma 크로스 팬테일

안녕하세요, 두 개의 vma가 교차할 때 화살표를 표시하는 표시기를 만들려고 합니다. 저는 mql 초보자이고 내 표시기가 분명히 작동하지 않습니다. 막혔습니다. 누군가 나를 도울 수 있습니까?

원래 표시기는 MA - fantail vma 3입니다.

#property copyright "Copyright © 2007, Forex-TSD.com "

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

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Black

#property indicator_width1 2

//#property indicator_color2 Red

//#property indicator_width2 2

//---- input parameters

//For both user settings, 2 is fast, 8 is slow.Weight=2.3 gives late entry.

extern int ADX_Length=2;

extern double Weighting=2.0;

extern int MA_Length=1;//This must be =1 so that the VMA base line does not get averaged.

extern int MA_Mode=1;

//---- buffers

double MA[];

double VMA[];

double VarMA[];

double ADX[];

double ADXR[];

double sPDI[];

double sMDI[];

double STR[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

IndicatorBuffers(8);

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,MA);

SetIndexBuffer(1,VMA);

// SetIndexStyle(2,DRAW_LINE);

SetIndexBuffer(2,VarMA);

SetIndexBuffer(3,ADX);

SetIndexBuffer(4,ADXR);

SetIndexBuffer(5,sPDI);

SetIndexBuffer(6,sMDI);

SetIndexBuffer(7,STR);

//---- name for DataWindow and indicator subwindow label

string short_name="MA - Fantail vma 3";

IndicatorShortName(short_name);

SetIndexLabel(0,"MA - Fantail vma 3");

//----

SetIndexDrawBegin(0,2*MA_Length+40);

// SetIndexDrawBegin(1,2*MA_Length+40);//Used for displaying internal signals.

//---- Safety limits for user settings

if (ADX_Length<2)ADX_Length=2;

if (ADX_Length>8)ADX_Length=8;

if (Weighting<1)Weighting=1;

if (Weighting>8)Weighting=8;

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int limit, i, j, counted_bars=IndicatorCounted();

//----

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

if ( counted_bars ==0 ) limit=Bars-1;

if ( counted_bars < 1 )

for(i=1;i<2*(MA_Length+ADX_Length+10);i++)

{

VMA=Close;

VarMA=Close;

MA=Close;

STR = High-Low;

sPDI = 0;

sMDI = 0;

ADX=0;

ADXR=0;

}

if(counted_bars>0) limit=Bars-counted_bars;

limit--;

for(i=limit; i>=0; i--)

{

double Hi = High;

double Hi1 = High;

double Lo = Low;

double Lo1 = Low;

double Close1= Close;

double Bulls = 0.5*(MathAbs(Hi-Hi1)+(Hi-Hi1));

double Bears = 0.5*(MathAbs(Lo1-Lo)+(Lo1-Lo));

if (Bulls > Bears) Bears = 0;

else

if (Bulls < Bears) Bulls = 0;

else

if (Bulls == Bears) {Bulls = 0;Bears = 0;}

sPDI = (Weighting*sPDI + Bulls)/(Weighting+1);//ma weighting

sMDI = (Weighting*sMDI + Bears)/(Weighting+1);//ma weighting

double TR = MathMax(Hi-Lo,Hi-Close1);

STR = (Weighting*STR + TR)/(Weighting+1);//ma weighting

if(STR>0 )

{

double PDI = sPDI/STR;

double MDI = sMDI/STR;

}

if((PDI + MDI) > 0)

double DX = MathAbs(PDI - MDI)/(PDI + MDI);

else DX = 0;

ADX = (Weighting*ADX + DX)/(Weighting+1);//ma weighting

double vADX = ADX;

double ADXmin = 1000000;

for (j=0; j<=ADX_Length-1;j++) ADXmin = MathMin(ADXmin,ADX);

double ADXmax = -1;

for (j=0; j<=ADX_Length-1;j++) ADXmax = MathMax(ADXmax,ADX);

double Diff = ADXmax - ADXmin;

if(Diff > 0) double Const = (vADX- ADXmin)/Diff; else Const = 0;

VarMA=((2-Const)*VarMA+Const*Close)/2;//Same equation but one less array, mod 10 Sept 2007.

}

for(j=limit; j>=0; j--) MA[j] = iMAOnArray(VarMA,0,MA_Length,0,MA_Mode,j);

//----

return(0);

}

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

[/PHP]

and this is mine

[PHP]

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

//| VMA cross arrows.mq4 |

//| thefxpros@katamail.com |

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

#property copyright "thefxpros"

#property link "thefxpros@katamail.com"

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 C'255,198,198'

#property indicator_color2 C'198,255,198'

#property indicator_color3 Crimson

#property indicator_color4 DarkGreen

#property indicator_width1 3

#property indicator_width2 3

#property indicator_width3 2

#property indicator_width4 2

//--------------------------------------------------------

extern int VMA1_ADXLenght = 2;

extern double VMA1_Weighting = 2.0;

extern int VMA1_Length = 1;

extern int VMA1_Mode = 1;

extern int VMA2_ADXLenght = 2;

extern double VMA2_Weighting = 3.0;

extern int VMA2_Length = 3;

extern int VMA2_Mode = 2;

//--------------------------------------------------------

double buffer1[];

double buffer2[];

double buffer3[];

double buffer4[];

//--------------------------------------------------------

int init()

{

SetIndexStyle (0,DRAW_HISTOGRAM);

SetIndexStyle (1,DRAW_HISTOGRAM);

SetIndexBuffer (0,buffer3);

SetIndexBuffer (1,buffer4);

SetIndexBuffer (2,buffer1);

SetIndexBuffer (3,buffer2);

return(0);

}

int deinit()

{

return(0);

}

//--------------------------------------------------------

int start()

{

int counted_bars=IndicatorCounted();

int limit,i;

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

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//--------------------------------------------------------

for(i=limit; i>=0; i--)

{

buffer1 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA1_Weighting, VMA1_Length, VMA1_Mode, i);

buffer2 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA2_Weighting, VMA2_Length, VMA2_Mode, i);

buffer3 = buffer1;

buffer4 = buffer2;

}

return(0);

}

 

더 엑스 프로,

먼저 표시기의 이름을 확인하십시오.

""MA - 파테일 vma 3"

거기에 "팬테일"이 있어야합니다.

또한 iCustom() 표시기에 대한 호출에서 버퍼 번호 가 누락되었습니다. 나는 이것이 당신이 달성하려고했던 것이라고 추측합니다.

buffer1 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA1_Weighting, VMA1_Length, VMA1_Mode,0, i);

buffer2 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA2_Weighting, VMA2_Length, VMA2_Mode,1, i);[/PHP]

thefxpros:
Hi, i'm trying to make an indicator that shows arrows when two vma crosses. I'm a mql beginner and my indicator obviously does not work, I'm stuck. Somebody can help me?

The original indicator is MA - fantail vma 3

#property copyright "Copyright © 2007, Forex-TSD.com "

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

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Black

#property indicator_width1 2

//#property indicator_color2 Red

//#property indicator_width2 2

//---- input parameters

//For both user settings, 2 is fast, 8 is slow.Weight=2.3 gives late entry.

extern int ADX_Length=2;

extern double Weighting=2.0;

extern int MA_Length=1;//This must be =1 so that the VMA base line does not get averaged.

extern int MA_Mode=1;

//---- buffers

double MA[];

double VMA[];

double VarMA[];

double ADX[];

double ADXR[];

double sPDI[];

double sMDI[];

double STR[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

IndicatorBuffers(8);

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,MA);

SetIndexBuffer(1,VMA);

// SetIndexStyle(2,DRAW_LINE);

SetIndexBuffer(2,VarMA);

SetIndexBuffer(3,ADX);

SetIndexBuffer(4,ADXR);

SetIndexBuffer(5,sPDI);

SetIndexBuffer(6,sMDI);

SetIndexBuffer(7,STR);

//---- name for DataWindow and indicator subwindow label

string short_name="MA - Fantail vma 3";

IndicatorShortName(short_name);

SetIndexLabel(0,"MA - Fantail vma 3");

//----

SetIndexDrawBegin(0,2*MA_Length+40);

// SetIndexDrawBegin(1,2*MA_Length+40);//Used for displaying internal signals.

//---- Safety limits for user settings

if (ADX_Length<2)ADX_Length=2;

if (ADX_Length>8)ADX_Length=8;

if (Weighting<1)Weighting=1;

if (Weighting>8)Weighting=8;

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int limit, i, j, counted_bars=IndicatorCounted();

//----

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

if ( counted_bars ==0 ) limit=Bars-1;

if ( counted_bars < 1 )

for(i=1;i<2*(MA_Length+ADX_Length+10);i++)

{

VMA=Close;

VarMA=Close;

MA=Close;

STR = High-Low;

sPDI = 0;

sMDI = 0;

ADX=0;

ADXR=0;

}

if(counted_bars>0) limit=Bars-counted_bars;

limit--;

for(i=limit; i>=0; i--)

{

double Hi = High;

double Hi1 = High;

double Lo = Low;

double Lo1 = Low;

double Close1= Close;

double Bulls = 0.5*(MathAbs(Hi-Hi1)+(Hi-Hi1));

double Bears = 0.5*(MathAbs(Lo1-Lo)+(Lo1-Lo));

if (Bulls > Bears) Bears = 0;

else

if (Bulls < Bears) Bulls = 0;

else

if (Bulls == Bears) {Bulls = 0;Bears = 0;}

sPDI = (Weighting*sPDI + Bulls)/(Weighting+1);//ma weighting

sMDI = (Weighting*sMDI + Bears)/(Weighting+1);//ma weighting

double TR = MathMax(Hi-Lo,Hi-Close1);

STR = (Weighting*STR + TR)/(Weighting+1);//ma weighting

if(STR>0 )

{

double PDI = sPDI/STR;

double MDI = sMDI/STR;

}

if((PDI + MDI) > 0)

double DX = MathAbs(PDI - MDI)/(PDI + MDI);

else DX = 0;

ADX = (Weighting*ADX + DX)/(Weighting+1);//ma weighting

double vADX = ADX;

double ADXmin = 1000000;

for (j=0; j<=ADX_Length-1;j++) ADXmin = MathMin(ADXmin,ADX);

double ADXmax = -1;

for (j=0; j<=ADX_Length-1;j++) ADXmax = MathMax(ADXmax,ADX);

double Diff = ADXmax - ADXmin;

if(Diff > 0) double Const = (vADX- ADXmin)/Diff; else Const = 0;

VarMA=((2-Const)*VarMA+Const*Close)/2;//Same equation but one less array, mod 10 Sept 2007.

}

for(j=limit; j>=0; j--) MA[j] = iMAOnArray(VarMA,0,MA_Length,0,MA_Mode,j);

//----

return(0);

}

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

and this is mine

[PHP]

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

//| VMA cross arrows.mq4 |

//| thefxpros@katamail.com |

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

#property copyright "thefxpros"

#property link "thefxpros@katamail.com"

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 C'255,198,198'

#property indicator_color2 C'198,255,198'

#property indicator_color3 Crimson

#property indicator_color4 DarkGreen

#property indicator_width1 3

#property indicator_width2 3

#property indicator_width3 2

#property indicator_width4 2

//--------------------------------------------------------

extern int VMA1_ADXLenght = 2;

extern double VMA1_Weighting = 2.0;

extern int VMA1_Length = 1;

extern int VMA1_Mode = 1;

extern int VMA2_ADXLenght = 2;

extern double VMA2_Weighting = 3.0;

extern int VMA2_Length = 3;

extern int VMA2_Mode = 2;

//--------------------------------------------------------

double buffer1[];

double buffer2[];

double buffer3[];

double buffer4[];

//--------------------------------------------------------

int init()

{

SetIndexStyle (0,DRAW_HISTOGRAM);

SetIndexStyle (1,DRAW_HISTOGRAM);

SetIndexBuffer (0,buffer3);

SetIndexBuffer (1,buffer4);

SetIndexBuffer (2,buffer1);

SetIndexBuffer (3,buffer2);

return(0);

}

int deinit()

{

return(0);

}

//--------------------------------------------------------

int start()

{

int counted_bars=IndicatorCounted();

int limit,i;

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

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//--------------------------------------------------------

for(i=limit; i>=0; i--)

{

buffer1 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA1_Weighting, VMA1_Length, VMA1_Mode, i);

buffer2 = iCustom(NULL, 0, "MA - fatail vma 3", VMA1_ADXLenght, VMA2_Weighting, VMA2_Length, VMA2_Mode, i);

buffer3 = buffer1;

buffer4 = buffer2;

}

return(0);

}

사유: