Fragen Sie! - Seite 34

 
AnasFX:
Ok, es hat funktioniert, aber jetzt ist das Problem die Leistung. Das Überprüfen der gesamten Historie braucht Zeit. Ich habe einen Backtest über einen Zeitraum von anderthalb Jahren durchgeführt und festgestellt, dass er langsam ist. Der Grund dafür ist, dass ich alle Aufträge in der Historie prüfe und deren Schlusskurs und Schlusszeit vergleiche. Gibt es eine Möglichkeit, die Suche in der Historie so einzuschränken, dass sie nur die jüngsten Aufträge durchsucht? Kann ich die Leistung irgendwie erhöhen?

Sie können versuchen

OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

aber ich bin mir nicht sicher, denn ich denke, es wird die letzte Bestellung in der gesamten Historie auswählen.

Danke

 

hallo Leute...

kann mir jemand helfen...

Ich habe einige Indikatoren, um EA.... zu erstellen.

 
phoenix:
Sie können versuchen

OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

aber ich bin mir nicht sicher, denn ich denke, es wird die letzte Bestellung in der gesamten Historie abholen

Danke

editiert von meinem Fehler..es muss sein

OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);

 

Entschuldigung für das doppelte Posting, aber ich brauche wirklich Hilfe...

Ich bin hier verzweifelt. Ich habe die ganze Nacht versucht, mein Array zum Laufen zu bringen, aber nichts passiert. Ich habe wirklich versucht, selbständig zu sein und zu lernen, aber ich komme immer noch nicht ans Ziel. Wenn sich bitte jemand meiner erbarmen könnte und mir helfen würde....BITTE!!!!!

Ich verwende ein Grid-Skript, würde aber gerne verfolgen, wie viele Lose ich pro Symbol verwende. Ich möchte in der Lage sein, meine Gesamtposition nach Losgröße zu addieren. Sagen wir, ich habe 0,10, 0,10, 0,10, 0,10, 0,20, 0,30, dann möchte ich wissen, dass ich das Äquivalent zu 0,90 Lots habe. Ich möchte auch die minimale und maximale Losgröße wissen....0.10 und 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:
Entschuldigung für das doppelte Posting, aber ich brauche wirklich Hilfe...

Ich bin hier verzweifelt. Ich habe die ganze Nacht versucht, mein Array zum Laufen zu bringen, aber nichts passiert. Ich habe wirklich versucht, mich selbst zu versorgen und zu lernen, aber ich komme immer noch nicht ans Ziel. Wenn sich bitte jemand meiner erbarmen könnte und mir helfen würde....BITTE!!!!!

Ich verwende ein Grid-Skript, würde aber gerne verfolgen, wie viele Lose ich pro Symbol verwende. Ich möchte in der Lage sein, meine Gesamtposition nach Losgröße zu addieren. Sagen wir, ich habe 0,10, 0,10, 0,10, 0,10, 0,20, 0,30, dann möchte ich wissen, dass ich das Äquivalent zu 0,90 Lots habe. Ich würde auch gerne die minimale und maximale Losgröße wissen....0.10 und 0.30

Das Problem ist, dass arrayresize() nur die Größe des ersten Elements ändert, nicht die des zweiten. Offensichtlich müssen Ihre Makros LOTS, PROFIT und OPEN jeweils 0, 1 und 2 sein. Außerdem ist das count-Objekt in der for-Schleife (i), aber der Blockcode bezieht sich auf (cnt). Probieren Sie dies aus und sehen Sie, ob es funktioniert.

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);

}

 

Danke Nicholishen,

Ich bin ein bisschen näher dran. BuyLots gibt zurück, was ich will, aber ArrayMaximum gibt mir eine seltsame Zahl, die ich nicht ganz herausfinden kann. Es gibt nicht die größte LotSize zurück.

Ich bin wirklich dankbar für Ihre Hilfe.

dee

 
deeforex:
Danke Nicholishen,

Ich bin ein bisschen näher dran. BuyLots gibt zurück, was ich will, aber ArrayMaximum gibt mir eine seltsame Zahl, die ich nicht ganz herausfinden kann. Es gibt nicht die größte LotSize zurück.

Ich bin Ihnen wirklich dankbar für Ihre Hilfe.

dee

Sie müssen das Array in verschiedene Arrays aufteilen oder eine Schleife schreiben, um das ArrayMaximum zu extrahieren. z.B.:

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;

 

Hier ein weiteres Beispiel für eine Funktion, die enge Trailing-Stops über mehrere Trades in derselben Währung verfolgt, indem sie Trailing-Daten mit der Ticketnummer des entsprechenden Trades verknüpft - unter Verwendung von Arrays. Vielleicht gibt Ihnen das auch einige Anregungen.

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);

}
 

Nochmals vielen Dank!

Ich habe die 3. von der letzten Zeile in diese geändert

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

und es hat funktioniert. Es ist schon lange nach meiner Schlafenszeit. Morgen, wenn ich aufwache, werde ich die Logik deines Codes studieren. Aber weil ich stur bin, werde ich herausfinden, wie man die verflixte ArrayMaximum-Funktion benutzt!!! Ich werde auch mehr über Indizierung lesen müssen, um zu sehen, dass meine alten Methoden sooooo falsch waren.

Nochmals vielen Dank!!!!

dee

 
deeforex:
Nochmals vielen Dank!

Ich änderte die 3. von der letzten Zeile in diese

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

und es hat funktioniert. Es ist schon lange nach meiner Schlafenszeit. Morgen, wenn ich aufwache, werde ich die Logik Ihres Codes studieren. Aber weil ich stur bin, werde ich herausfinden, wie man die verflixte ArrayMaximum-Funktion benutzt!!! Ich werde auch mehr über Indizierung lesen müssen, um zu sehen, dass meine alten Methoden sooooo falsch waren.

Danke nochmal!!!!

dee

Um Ihnen etwas Zeit zu ersparen: Der Grund, warum die max-Funktion nicht funktioniert, ist, dass Sie ein mehrdimensionales Array verwenden und verschiedene Arten von Daten speichern. Es wird das Maximum dieser Daten zurückgegeben, daher ist es wahrscheinlich, dass Sie eine Gewinnzahl oder irgendetwas höheres als Ihre ECHTE maximale Losgröße zurückgeben.