묻다! - 페이지 34

 
AnasFX:
좋아, 작동했지만 이제 문제는 성능입니다. 전체 이력을 확인하려면 시간이 걸립니다. 1년 반 동안 백테스트를 했는데 속도가 느리다는 것을 알았습니다. 그 이유는 내역에 있는 모든 주문을 확인하고 마감 가격과 마감 시간을 비교하기 때문입니다. 그렇다면 최근 주문만 검색하도록 히스토리 검색을 제한하는 방법이 있습니까? 어쨌든 성능을 높일 수 있습니까?

당신은 시도 할 수 있습니다

주문 선택(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

그러나 나는 이것이 확실하지 않습니다. 나는 그것이 전체 역사상 마지막 주문을 집어 올릴 것이라고 생각합니다.

건배

 

안녕하세요 여러분...

아무도 나를 도울 수 있습니다 ..

EA를 생성 하기 위한 지표가 있습니다.

 
phoenix:
당신은 시도 할 수 있습니다

주문 선택(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

그러나 나는 이것이 확실하지 않습니다. 나는 그것이 전체 역사상 마지막 주문을 집어 올릴 것이라고 생각합니다.

건배

내 잘못을 수정했습니다.

주문 선택( HistoryTotal()-1 ,SELECT_BY_POS,MODE_HISTORY);

 

중복글 올려서 죄송하지만 도움이 필요합니다...

저는 절망적입니다. 어레이가 작동하도록 밤새도록 노력했지만 아무 일도 일어나지 않았습니다. 나는 정말로 자급자족하고 배우려고 노력했지만 여전히 내가 가야 할 곳에 도달할 수 없습니다. 누군가 나에게 자비를 베풀고 도움을 줄 수 있다면.... 제발!!!!!

그리드 스크립트를 실행하고 있지만 Symbol로 얼마나 많은 로트를 실행하고 있는지 추적하고 싶습니다. 내 총 위치를 lotsize별로 더할 수 있기를 원합니다. 0.10, 0.10, 0.10, 0.10, 0.20, 0.30이 있다고 가정해 보겠습니다. 0.90랏에 해당하는 수량을 알고 싶습니다. 또한 최소 및 최대 로트 크기를 알고 싶습니다....0.10 및 0.30

ArrayResize(OrderArray, i);

ArrayInitialize(OrderArray,0);

cnt = 0;

for (i = 0; i < OrdersTotal(); i++)

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

////// I can't get anything to work!!!!!!!

BuyLots += OrderArray[cnt][LOTS];

////// This returns Zero when I place BuyLots in my Comments

////// This returns error messages

MaxBuyLots =ArrayMaximum(OrderArray[LOTS],WHOLE_ARRAY,0);

}

 
deeforex:
중복글 올려서 죄송하지만 도움이 필요합니다...

저는 절망적입니다. 어레이가 작동하도록 밤새도록 노력했지만 아무 일도 일어나지 않았습니다. 나는 정말로 자급자족하고 배우려고 노력했지만 여전히 내가 가야 할 곳에 도달할 수 없습니다. 누군가 나에게 자비를 베풀고 도움을 줄 수 있다면.... 제발!!!!!

그리드 스크립트를 실행하고 있지만 Symbol로 얼마나 많은 로트를 실행하고 있는지 추적하고 싶습니다. 내 총 위치를 lotsize별로 더할 수 있기를 원합니다. 0.10, 0.10, 0.10, 0.10, 0.20, 0.30이 있다고 가정해 보겠습니다. 0.90랏에 해당하는 수량을 알고 싶습니다. 또한 최소 및 최대 로트 크기를 알고 싶습니다....0.10 및 0.30

문제는 arrayresize()가 두 번째가 아닌 첫 번째 요소의 크기만 조정한다는 것입니다. 분명히 LOTS, PROFIT 및 OPEN 매크로는 각각 0,1,2여야 합니다. 또한 for 루프의 count 개체는 (i)이지만 블록 코드는 (cnt)를 참조합니다. 이것을 시도하고 이것이 작동하는지 확인하십시오.

double OrderArray[][3];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

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

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArray[cnt][LOTS];

MaxBuyLots =ArrayMaximum(OrderArray);

}

 

Nicholishen님, 감사합니다.

나는 조금 더 가까워지고 있다. BuyLots는 내가 원하는 것을 반환하지만 ArrayMaximum은 내가 잘 알 수 없는 이상한 숫자를 제공합니다. 가장 큰 LotSize를 반환하지 않습니다.

도움을 주셔서 정말 감사합니다.

 
deeforex:
Nicholishen님, 감사합니다.

나는 조금 더 가까워지고 있다. BuyLots는 내가 원하는 것을 반환하지만 ArrayMaximum은 내가 잘 알 수 없는 이상한 숫자를 제공합니다. 가장 큰 LotSize를 반환하지 않습니다.

도움을 주셔서 정말 감사합니다.

배열을 다른 배열로 분할하거나 최대 배열을 추출하는 루프를 작성해야 합니다. 와 같은:

double OrderArray...[];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

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

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArrayProfit[cnt] = OrderProfit() + OrderSwap();

OrderArrayOpen[cnt] = OrderOpenPrice();

OrderArrayLots[cnt] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArrayLots[cnt];

MaxBuyLots =ArrayMaximum(OrderArrayLots);

}

[/CODE]

or

[CODE]double OrderArray[][3];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

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

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArray[cnt][LOTS];

}

double MBL;

for(int i=0;i<OrdersTotal();i++){

if(OrderArrayLots[LOTS]>MBL)MBL=OrderArrayLots[LOTS];

}

MaxBuyLots =MBL;

 

다음은 배열을 사용하여 후행 데이터를 해당 거래의 티켓 번호와 짝을 지어 동일한 통화에 대한 여러 거래에서 긴밀한 후행 정지를 추적하는 기능 의 또 다른 예입니다. 어쩌면 이것은 또한 당신에게 몇 가지 아이디어를 제공하는 데 도움이 될 것입니다.

int tsTicket[21];

double tsPrice[21];

bool tsok[21];

int tkt3[20];

int SuperClose(){// superclose by nicholishen

int cnp=ordercnt();

for(int i=0;i<cnp;i++){

if(OrderMatch(i)){

if(0==0){//Pulls in order that meets the criteria for processing

int num=0;int pos=0;

for(int b=0;b<21;b++){// this (loopB) compares the ticket# of the selected order against the number stored in the ticket array

if(tsTicket==OrderTicket() ){

num++; pos=b;// if ticket numbers match, pos is the position in the array where the trailing data is stored

break;

}

}

if(num==0){ // if the loopB did not find a matching ticket number it is time to initialize the data

for(int j=0;j<21;j++){

if(tsTicket[j]==0){// this is looking for the earliest instance within the array to store the data

pos=j;

break;

}

}

tsTicket[pos]=OrderTicket();// setting the ticket number

tsok[pos]=false;// this is to determine when trailing kicks in

// Print("(",pos,") New ticket initialized = ",tsTicket[pos]);

}

if (OrderType()==OP_SELL) {

if (!tsok[pos] && (OrderOpenPrice()-Ask>=TSactivation*Point || TSactivation==0 ) ) {// if the trailing factor is false, but it has hit the activation point continue

tsPrice[pos]=Ask+TrailPips*Point;// this is the new trailinf stop price

tsok[pos]=true;// it's ok to proceed with trailing stop

if(TrailPips>8){// if this distance from the current price to the new stop, then modify the order.

ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());//modifies order

}

}

if (tsok[pos] && Ask+TrailPips*Point < tsPrice[pos] ){//if the position is gaining in profit

tsPrice[pos]=Ask+TrailPips*Point;

if(TrailPips>8){

ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Ask >= tsPrice[pos] ){// if the postion hits the stop price

if(CloseOrder(Ask)==STOP)return(STOP);

Print("Short Order ",tsTicket[pos]," Closed from TS");

}

}

else if (OrderType()==OP_BUY) {// reverse of SELL

if(!tsok[pos] && (Bid-OrderOpenPrice() >= TSactivation*Point || TSactivation==0 ) ) {

tsPrice[pos]=Bid-TrailPips*Point;

tsok[pos]=true;

if(TrailPips>8){

ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Bid-TrailPips*Point > tsPrice[pos] ){

tsPrice[pos]=Bid-TrailPips*Point;

if(TrailPips > 8){

ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Bid <= tsPrice[pos] ){

if(CloseOrder(Bid)==STOP)return(STOP);

Print("Long Order ",tsTicket[pos]," Closed from TS");

}

}

}

}

if(RefreshRates())return(STOP);

}

for(i=0;i<21;i++){// this searches the array for ticket numbers that are now obsolete due to an order that has closed

if(tsTicket>0){

bool found=false;

for(b=0;b<OrdersTotal();b++){

OrderSelect(b,SELECT_BY_POS);

if(tsTicket==OrderTicket()){

found=true;

break;

}

}

if(!found){// if there are matching ticket numbers in the trade pool and the array then nothing happens

tsTicket=0;tsPrice=0;tsok=false;// if there is an obolete ticket the the data is reset. And the next new ticket data can occupy this space

// Print("Array pos ",i," Cleaned");

}

}

}

return(0);

}

int ordercnt(){

int c;

for(int i=0;i<OrdersTotal();i++){

if(OrderSelect(i,SELECT_BY_POS)){

if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){

tkt3[c]=OrderTicket();

c++;

}

}

}

return(c);

}

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

int curcnt(){

int c;

for(int i=0;i<OrdersTotal();i++){

if(OrderSelect(i,SELECT_BY_POS)){

if(OrderSymbol()==Symbol()){

c++;

return(c);

}

}

}

return(c);

}

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

bool OrderMatch(int i){

if(OrderSelect(tkt3,SELECT_BY_TICKET)){

if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){

return(true);

}

}

return(false);

}
 

다시 한번 감사합니다!

나는 마지막 줄에서 3 번째 줄을 이것으로 변경했습니다.

if(OrderArray[LOTS]>MBL)MBL=OrderArray[LOTS];

작동하도록 했습니다. 취침 시간이 훨씬 지났습니다. 내일 일어나면 당신의 코드 논리를 공부할 것입니다. 하지만 고집이 세다보니 ArrayMaximum 함수 사용법을 알아내려고 합니다!! 나는 또한 나의 예전 방식이 얼마나 잘못된 것인지 알아보기 위해 인덱싱에 대해 더 읽어야 할 것입니다.

다시 한번 감사합니다!!!!

 
deeforex:
다시 한번 감사합니다!

나는 마지막 줄에서 3 번째 줄을 이것으로 변경했습니다.

if(OrderArray[LOTS]>MBL)MBL=OrderArray[LOTS];

작동하도록 했습니다. 취침 시간이 훨씬 지났습니다. 내일 일어나면 당신의 코드 논리를 공부할 것입니다. 하지만 고집이 세서 ArrayMaximum 함수 사용법을 알아내려고 합니다!! 나는 또한 나의 예전 방식이 얼마나 잘못된 것인지 알아보기 위해 인덱싱에 대해 더 읽어야 할 것입니다.

다시 한번 감사합니다!!!!

시간을 절약하기 위해 max 함수 가 원하는 대로 작동하지 않는 이유는 다차원 배열을 사용하고 있고 다른 종류의 데이터를 저장하고 있기 때문입니다. 해당 데이터의 최대값을 반환하므로 이익 수 또는 실제 최대 로트 크기보다 큰 값을 반환했을 가능성이 큽니다.