Wie bekomme ich den Indikator dazu, zu filtern, anstatt zu alarmieren? - Seite 8

 

Du bist der Mann!

Also.... mal sehen, ob ich das richtig verstehe...

wenn ich Positionen auf der Grundlage des Rückwärtskreuzes eines gleitenden Durchschnitts schließen wollte, müsste ich nur Folgendes codieren....

if(currentlong>minorts) {CloseOrder(OP_SELL); // Alle Verkaufsaufträge schließen}

wobei currentlong das 20ema und minorts das 150ema ist, so dass die offene Position ein Short gewesen wäre oder IST, der seinen Lauf genommen hat, und jetzt bewegt sich das 20ema über das 150ema, was das Schließungssignal für den Short-Handel ist.

und...

if (currentlong<minorts) {CloseOrder(OP_BUY); // Schließen Sie alle Kaufaufträge}

wobei currentlong das 20ema und minorts das 150ema ist, so dass die offene Position eine Long-Position gewesen wäre oder IST, die ihren Lauf genommen hat, und jetzt bewegt sich das 20ema unter das 150ema, was das Schließungssignal für den Long-Handel ist.

Ich könnte also einfach diese beiden Zeilen einfügen

if(currentlong<minorts) {CloseOrder(OP_BUY); // Alle Kaufaufträge schließen}

if(currentlong>minorts) {CloseOrder(OP_SELL); // Schließen Sie alle Verkaufsaufträge}

direkt nach dem Einstiegscode und vor all den anderen Schließungs- und Trailing-Stop-Sachen wie dieser? und es wird funktionieren?

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());

}

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

return(0);

}

}

//+---------end of order entry-------------------------+

//+------close on moving average cross-----------------+

if(currentlong<minorts) {CloseOrder(OP_BUY);} // Close all buy orders}

if(currentlong>minorts) {CloseOrder(OP_SELL);} // Close all sell orders}

//+--------end of close on moving average cross--------+

//+-------------------------Trailing Stop Code------------------------------------+

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

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

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

if(OrderType()==OP_BUY){

Der Compiler sagt dies:

')' - falsche Parameteranzahl C:\Programmdateien\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 43)

')' - falsche Anzahl von Parametern C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (86, 44)

Es mag diese Zeilen nicht. Ich habe das Gefühl, dass ich mich nicht sehr gut ausdrücken kann.

 

das ist interessant, plötzlich funktioniert meine Suchfunktion im Metaeditor??

bool OrderCloseBy( int ticket, int opposite, color Color=CLR_NONE)

Schließt einen geöffneten Auftrag durch einen anderen gegenüberliegenden geöffneten Auftrag. Wenn die Funktion erfolgreich ist, ist der Rückgabewert true. Schlägt die Funktion fehl, ist der Rückgabewert false. Um die detaillierten Fehlerinformationen zu erhalten, rufen Sie GetLastError() auf.

Parameter:

ticket - Eindeutige Nummer des Bestellscheins.

opposite - Eindeutige Nummer des gegenüberliegenden Bestellscheins.

Color - Farbe des Schließungspfeils im Diagramm. Wenn der Parameter fehlt oder den Wert CLR_NONE hat, wird der Schließungspfeil nicht im Diagramm angezeigt.

Beispiel:

if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}

Ich stelle mir das also ungefähr so vor...

if(currentlong<minorts)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}[/PHP]

thing is this doesn't distinguish what kind of position I'm into first, long or short. So if I put the opposite side of this with it...like this...

[PHP] if(currentlong>minorts)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}

zusammen würden sie einfach alles abschließen, nicht wahr? da muss es noch mehr geben... ich fühle mich so frustriert wie ein Kind, das noch nicht wirklich sprechen kann, um ganze Sätze zu kommunizieren, wenn ich komplette Ideen in mir habe, die ich nicht herausbekomme.

 
elihayun:
Ich habe das hier vergessen
void CloseOrder(int ticket,double numLots,double close_price)

{

int CloseCnt, err;

// try to close 3 Times

CloseCnt = 0;

color clr = Violet;

if (OrderType() == OP_SELL)

clr = Orange;

while (CloseCnt < 3)

{

if (OrderClose(ticket,numLots,close_price,Slippage,clr))

{

CloseCnt = 3;

}

else

{

err=GetLastError();

Print(CloseCnt," Error closing order : (", err , ") " + ErrorDescription(err));

if (err > 0) CloseCnt++;

}

}

}

[/PHP]

and dont forget to add this line after #property link

[PHP]#property link "http://www.elihayun.com"

#include

Ist das noch etwas, das ich herunterladen muss, damit es aufgerufen werden kann? Ich möchte verstehen, wie diese Funktion funktioniert und wie sie Long- und Short-Positionen unterscheidet. Das möchte ich lernen.

 
Aaragorn:
U da man!

so.... Mal sehen, ob ich das richtig verstehe...

Ich könnte also einfach diese beiden Zeilen einfügen

if(currentlong<minorts) {CloseOrder(OP_BUY); // Schließt alle Kaufaufträge}

if(currentlong>minorts) {CloseOrder(OP_SELL); // Schließen Sie alle Verkaufsaufträge}

//+------Schließen bei gleitendem Durchschnittskreuz-----------------+

if(currentlong<minorts) {CloseOrder(OP_BUY);} // Alle Kaufaufträge schließen}

if(currentlong>minorts) {CloseOrder(OP_SELL);} // Alle Verkaufsaufträge schließen}

if(OrderType()==OP_BUY){[/PHP]

Der Compiler sagt dies:

')' - falsche Parameteranzahl C:\Programmdateien\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 43)

')' - falsche Anzahl von Parametern C:\Programme\Interbank FX Trader 4-live mini\experts\whatever.mq4 (86, 44)

Es mag diese Zeilen nicht. Ich habe das Gefühl, dass ich nicht sehr gut kommuniziere.

Sie müssen CloseOrders mit s am Ende aufrufen, nicht CloseOrder (das schließt nur eine Order)

 
Aaragorn:
Was tut diese Funktion? Muss ich noch etwas anderes herunterladen, damit sie aufgerufen werden kann? Ich möchte verstehen, wie diese Funktion funktioniert, wie sie Long- und Short-Positionen unterscheidet. Ich möchte lernen.

Es ist Teil von MQL4 und enthält die Funktion ErrorDescription

 
elihayun:
Sein Teil von MQL4 und enthält die Funktion ErrorDescription

ok Ich brauche noch einen Code, der es mir ermöglicht, auf der Grundlage des gleitenden Durchschnitts zu schließen, der zurückgeht.

 

Dieses Stück Code sollte Ihnen den Einstieg erleichtern...

Natürlich müssen Sie ihn an Ihre eigenen Bedürfnisse anpassen. Aber es sollte Ihnen einen Ausgangspunkt bieten. Diese Routine verwendet die SMA1-Linie als Trailing-Stop. Nehmen Sie also diese Idee und sehen Sie, was Sie daraus machen können.

//these two lines within start()

SMA1 = iMA(NULL,TimePeriod,SlowPeriod,0,SlowMode,SlowPrice,1);

TrailingAlls(TrailStart, SMA1);

// trailing routine using the value of SMA1

void TrailingAlls(int start, double currvalue)

{

int profit;

double stoptrade;

double stopcal;

// if(stop==0) return;

int trade;

for(trade=OrdersTotal()-1;trade>=0;trade--)

{

if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))

continue;

if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)

continue;

if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)

{

if(OrderType()==OP_BUY)

{

profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Bid-(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal>stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);

}//Long

if(OrderType()==OP_SELL)

{

profit=NormalizeDouble((OrderOpenPrice()-Ask)/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Ask+(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal<stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);

}//Shrt

}

}//for

}

 

ein Trailing Stop Close ist möglicherweise nützlich, wenn ich dies herausfinden kann first....

Dieses Snippet, das mir elihayun gegeben hat, könnte funktionieren, wenn jemand herausfinden kann, wie man es dazu bringt, auf den ma backcross zu reagieren und in die richtige Richtung zu gehen. Ich bin verwirrt mit der op_buy und op_sell, die welche ist. und die zu verwenden, um lange Positionen zu schließen und die zu verwenden, um kurze Positionen zu schließen.

//+------close on moving average cross-----------------+

void CloseOrders(int op)

{

int tik[30], t = 0;

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

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){

if(OrderSymbol()==Symbol() && MagicNum==OrderMagicNumber() && OrderType() == op){

tik[t] = OrderTicket(); t++;

}

}

}

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

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

CloseOrder(tik, OrderLots(), prc);

}

}

}

//+--------end of close on moving average cross--------+[/PHP]

I think I see that at this point in the code it has selected the orders by ticket and it's figuring out to set the close price based on the bid or the ask. So I'm not sure which is which for long or short positions. If the ticket is a long position that means it was opened at the ask price right? so it should close on the bid price? so this snippet is saying use the bid price to close so I assume that's for a long position. THEN it asks the

if (op == OP_SELL) prc = Ask;

so I assume this is the first place in this code where we now know if we are looking at a long or a short position ticket.

Then it moves immediately to close. But if I can put my closing criteria in here BEFORE it does that???

here it is as I received it...

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

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

CloseOrder(tik, OrderLots(), prc);

}[/PHP]

so what I'm thinking is that this is the place in the code where I should insert the moving average criteria to trigger the close for long or short positions. Something like this...

[PHP]for (i = 0; i<t; i++)

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

if (prc == Bid && currentlong minorts);

CloseOrder(tik, OrderLots(), prc);

}

Will this do it? I think it might if I understand correctly..

Please tell me coders if this is correct??

I think this connects the direction of the moving average cross to the type of position that the ticket is identifed as being.

if the bid is to close long positions so we know the ticket is for a long position then it can close long positions if the currentlongema < minortsEMA because it knows that the ticket is for a long position and the 20ema has moved below the 150ema.

If the ask is for closing short positions and the ticket is identified as a short position because it wants to close at the ask price and the currentlongEMA has moved above the minortsEMA because it knows the ticket is for a short position and the 20ema has moved above the 150ema.

if that is correct will adding this line to the code,

if (prc == Bid && currentlong minorts)

stop it from closing UNLESS each ticket fits this criteria?

...that for the long position the 20ema150ema?

if that is ok then the logic for deciding to close long or short based on the emacrossback is ok and it's worth fixing these errors

I get these errors from the compiler...

[PHP]Compiling 'whatever.mq4'...

'(' - function definition unexpected C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 17)

'MagicNum' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (90, 40)

'op' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (90, 87)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 13)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 17)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 37)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (96, 18)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (98, 22)

'op' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (100, 14)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (102, 21)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 5)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 5)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 11)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 11)

'total' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 15)

'total' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 15)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 21)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 21)

'{' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 28)

'i' - variable is already defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (135, 11)

'}' - unbalanced parentheses C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (165, 1)

16 error(s), 5 warning(s)

 

Ein Vorschlag an alle Mitglieder: Verwenden Sie keine "Count-up"-Routinen zum Schließen von Geschäften. Verwenden Sie zum Beispiel nicht so etwas wie dieses:

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

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

CloseOrder(tik, OrderLots(), prc);

}

Wenn Sie mehrere Aufträge verwenden, wird der letzte Auftrag nicht geschlossen. Verwenden Sie eine "Countdown"-Routine. Hier ist meine Diskussion mit den Entwicklern von Metaquotes, als ich zum ersten Mal über diesen irritierenden "Bug" stolperte.

http://www.metaquotes.net/forum/2018/

 
Maji:
Dieses Stück Code sollte Ihnen den Einstieg erleichtern...

Natürlich müssen Sie es an Ihre eigenen Bedürfnisse anpassen. Dies sollte Ihnen jedoch einen Ausgangspunkt bieten. Diese Routine verwendet die SMA1-Linie als Trailing-Stop. Nehmen Sie also diese Idee und sehen Sie, was Sie daraus machen können.

//these two lines within start()

SMA1 = iMA(NULL,TimePeriod,SlowPeriod,0,SlowMode,SlowPrice,1);

TrailingAlls(TrailStart, SMA1);

// trailing routine using the value of SMA1

void TrailingAlls(int start, double currvalue)

{

int profit;

double stoptrade;

double stopcal;

// if(stop==0) return;

int trade;

for(trade=OrdersTotal()-1;trade>=0;trade--)

{

if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))

continue;

if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)

continue;

if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)

{

if(OrderType()==OP_BUY)

{

profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Bid-(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal>stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);

}//Long

if(OrderType()==OP_SELL)

{

profit=NormalizeDouble((OrderOpenPrice()-Ask)/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Ask+(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal<stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);

}//Shrt

}

}//for

}

Vielen Dank. Ich freue mich darauf, dies zu sezieren und zu sehen, was ich daraus machen kann...

Der Grund, warum ich zuerst den emacrossback zum Laufen bringen möchte, ist, dass er im Grunde mein Stoploss und meine Standardausstiegsstrategie sein wird.

Sobald das funktioniert, werde ich Dinge wie diese hinzufügen, um die Rentabilität zu erhöhen. Aber da ich keinen Stop-Loss haben kann, ohne ihn zu vermasseln, und da ich nicht bereit bin, riesige Stop-Loss-Parameter zuzulassen, möchte ich zuerst den gleitenden Durchschnitts-Crossback-Schluss zum Laufen bringen. Wenn Sie die Möglichkeit haben, zu überprüfen, was ich bisher mit dem Crossback-Close gemacht habe, wäre ich Ihnen dankbar.

Grund der Beschwerde: