Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Feststellen aus welcher Richtung Indikator kommt (http://www.expert-advisor.com/forum/showthread.php?t=6596)

MA-EA 04.02.20 18:55

Feststellen aus welcher Richtung Indikator kommt
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo.

Um Fehlsignale zu reduzieren, würde ich gerne den EA im Anhang rausfinden lassen, aus welcher Richtung der RSI kommt. Genauer gesagt, ob er zuletzt über oder unter der jeweiligen Indicator Line war. Dachte an ne While-Schleife. Blöderweise hab ich diese Schleifen nie so richtig kapiert. :rolleyes:

Ungefähr so:
Code:

RSI-Bar = 1;

while RSI < && > IL1 und IL2

RSI-Bar++

return ( RSI-Wert wenn er zuletzt <Untere Linie oder >Obere Linie ist/war ) ;

So in etwa dachte ich mir das. Aber wie gesagt bin ich aus for und while nie schlau geworden. :rolleyes:

MA-EA 04.02.20 20:54

Liste der Anhänge anzeigen (Anzahl: 1)
Funktioniert das so? :confused:
Code:

//=============================================================================================================
// O P E N  O R D E R S
//=============================================================================================================


if( RT==true && SPR_AL==true && BuyInv==false && SelInv==false ){


  int RSI_p_Bar = 2;
  double RSI_p = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_p_Bar);


  if(open_Buy==true){
 
    if( RSI>RSI_IL_1 && RVI_Ma>RVI_Si ){


      while( RSI_p > RSI_IL_1 ){
   
        RSI_p_Bar++;
       
        Print( "-RSI Past=",RSI_p , "-RSI Past Bar=",RSI_p_Bar );
       
        return(RSI_p);}
       

        if( RSI_p < RSI_IL_1 ){
 
          if(IsTradeAllowed()==true)Ti=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Buy_SL,Buy_TP,NULL,Buy_MN,0,Beige);

          Print( "send Buy:" , "-RSI=",RSI , "-RVI_Ma=",RVI_Ma , "-RVI_Si=",RVI_Si );

          if(Percent_of_Balance==true)Print( "AutoLot:" , "-MarginReq1L=",M_REQ , "-MinLot=",Min_L , "-OneL/MinL=",OneL_MinL , "-MREQ/MinL=",MREQ_MinL , "-AccBal=",AccountBalance() , "-1PercAccBal=",OPAB , "-ALP=",Auto_Lotsize_Perc , "-1PercAccBal*ALP=",OPAB_ALP , "-OPABALP/MREQMinL=",OPABALP_MREQMinL , "-OPABALP_MREQMinL*Min_L=",OPABALP_MREQMinL , "-Lots=OPABALP_MREQMinL*Min_L=",Lots );

          return(Ti); } } }


//////////////////////////////////////////////////////////////////////////////////////////////////////////////


  if(open_Sell==true){


    if( RSI<RSI_IL_2 && RVI_Ma<RVI_Si ){
   
     
      while(RSI_p < RSI_IL_2 ){
   
        RSI_p_Bar++;
     
        Print( "-RSI Past=",RSI_p , "-RSI Past Bar=",RSI_p_Bar );

        return(RSI_p);}


        if( RSI_p > RSI_IL_2 ){
 
          if(IsTradeAllowed()==true)Ti=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Sel_SL,Sel_TP,NULL,Sell_MN,0,Blue);

          Print( "send Sell:" , "-RSI=",RSI , "-RVI_Ma=",RVI_Ma , "-RVI_Si=",RVI_Si );

          Print( "AutoLot:" , "-MarginReq1L=",M_REQ , "-MinLot=",Min_L , "-OneL/MinL=",OneL_MinL , "-MREQ/MinL=",MREQ_MinL , "-AccBal=",AccountBalance() , "-1PercAccBal=",OPAB , "-ALP=",Auto_Lotsize_Perc , "-1PercAccBal*ALP=",OPAB_ALP , "-OPABALP/MREQMinL=",OPABALP_MREQMinL , "-OPABALP_MREQMinL*Min_L=",OPABALP_MREQMinL , "-Lots=OPABALP_MREQMinL*Min_L=",Lots );

          return(Ti); }}} }


MA-EA 05.02.20 12:33

Liste der Anhänge anzeigen (Anzahl: 1)
Anscheinend macht er das nur ein mal. Und öffnet Trades, obwohl die Kerzen was Anderes sagen.
Code:

  int RSI_p_Bar = 2;
  double RSI_p = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_p_Bar);


  if(open_Buy==true){
 
    if( RSI>RSI_IL_1 && RVI_Ma>RVI_Si ){


      while( RSI_p > RSI_IL_1 ){
   
        RSI_p_Bar++;
       
        Print( "-RSI Past=",RSI_p , "-RSI Past Bar=",RSI_p_Bar );
       
        return(RSI_p);}
       

        if( RSI_p < RSI_IL_1 ){

Code:

   
 
if( RSI<RSI_IL_2 && RVI_Ma<RVI_Si ){
   
     
      while(RSI_p < RSI_IL_2 ){
   
        RSI_p_Bar++;
     
        Print( "-RSI Past=",RSI_p , "-RSI Past Bar=",RSI_p_Bar );

        return(RSI_p);}


        if( RSI_p > RSI_IL_2 ){

Wie bekommt man das hin, dass er eine vorige RSI-Kerze nach der Anderen prüft, ob sie zuletzt über oder unter IL 1 / IL 2 waren? :confused:

MA-EA 06.02.20 10:29

Liste der Anhänge anzeigen (Anzahl: 1)
Vielleicht mit nem bool?
Code:

if( RSI > IL1 ) bool RSI_p_over_IL2 = true ;
Und dass dann irgendwie mit ner while-Schleife prüfen. Wenn der bool true ist, die zu prüfende Kerze des RSI erhöhen. :confused:
Code:


int RSI_p_Bar = 2;
 
double RSI_p = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_p_Bar);

if ( RSI_over_IL2 == true )  RSI_p_Bar++ ;

Oder RSI_p_Bar + 1 ? :confused:

Könnte das nach einem while ( bool == true ) - Prinzip ungefähr funktionieren?

Leopold 07.02.20 21:42

Ich war jetzt schon eine Weile nicht auf hier, hätte nicht gedacht, dass du deine Monologe immer noch hier führst ... :D

MA-EA 22.02.20 23:11

Liste der Anhänge anzeigen (Anzahl: 1)
Hallo.

Im Anhang eine Version, in der versucht wird, festzustellen, aus welcher Richtung der RSI kommt. Von oben oder unten.

Ich kenn mich mit MQL 4 nicht so gut aus und schon gar nicht mit irgendwelchen Schleifen. Die While-Schleifen im EA sollen zählen, wie oft die vergangenen RSI-Kerzen über oder unter dem von Bar 1 waren. Der kleinere Wert soll dann bestimmen, ober er auf jeweilige Einstiegssignale (Buy oder Sell) reagiert oder nicht. Aber wie gesagt ist das Alles für mich eigentlich viel zu hoch. :rolleyes: Deswegen hab ich die OrderSend-Bedingungen erst mal ohne diese Zählerei gelassen.

Keine Ahnung, ob ich damit wenigstens ein wenig auf dem Richtigen oder auf dem totalen Holzweg bin. :rolleyes:
Code:

//=============================================================================================================
// R S I  D E K L A R A T I O N
//=============================================================================================================

double RSI=iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,1);

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


// RSI past

int RSI_Past_Bar = 2;
double RSI_Past = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_Past_Bar);


int RSI_P_under=0;
int RSI_P_over=0;


if( RSI > RSI_IL_1 && RSI < RSI_IL_2 ) {


  while( RSI_Past < RSI ){

    RSI_P_under++;
   
    RSI_Past_Bar++;

    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_under=",RSI_P_under );
   
    return(RSI_P_under);}
 

  while( RSI_Past > RSI ){
   
    RSI_P_over++;
   
    RSI_Past_Bar++;
   
    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_over=",RSI_P_over );
   
    return(RSI_P_over);}

}

:confused:

MA-EA 22.02.20 23:45

Liste der Anhänge anzeigen (Anzahl: 1)
Kann jetzt nicht mehr Editieren. So müsste es reichen.
Code:

//=============================================================================================================
// R S I  D E K L A R A T I O N
//=============================================================================================================

double RSI=iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,1);

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


// RSI past

int RSI_Past_Bar = 2;
double RSI_Past = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_Past_Bar);


int RSI_P_under=0;
int RSI_P_over=0;


  while( RSI_Past < RSI ){

    RSI_P_under++;
   
    RSI_Past_Bar++;

    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_under=",RSI_P_under );
   
    return(RSI_P_under);}
 

  while( RSI_Past > RSI ){
   
    RSI_P_over++;
   
    RSI_Past_Bar++;
   
    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_over=",RSI_P_over );
   
    return(RSI_P_over);}

:confused:

Bayreuther 23.02.20 21:14

Code:

if (RSI0 > EbeneX && RSI1 < EbeneX)
Der RSI schneidet die EbeneX von unten nach oben.

if (RSI0 < EbeneX && RSI1 > EbeneX)
Der RSI schneidet die EbeneX von oben nach unten.


MA-EA 24.02.20 15:39

Liste der Anhänge anzeigen (Anzahl: 1)
Danke. Aber dann steigt er nur ein, wenn die Werte sich gerade erst gekreuzt haben. Er soll auch Stunden später noch einsteigen.

Irgendeinen Weg muss es geben, raus zu finden, ob der RSI zuletzt unter Indicator Line 1 (Bestätigung für Buy) oder über Indicator Line 2 (Bestätigung für Sell) war.

Mit der Idee zeigt er irgendwie immer nur Kerze 3 an und tut dann nix mehr. Ausser immer weiter zu printen. :rolleyes:
Code:

// RSI past

int RSI_Past_Bar = 2;
double RSI_Past = iRSI(Symbol(),Timeframe,RSI_Period,RSI_Price,RSI_Past_Bar);


int RSI_P_under=0;
int RSI_P_over=0;


  while( RSI_Past < RSI ){

    RSI_P_under++;
   
    RSI_Past_Bar++;

    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_under=",RSI_P_under );
   
    return(RSI_P_under);}
 

  while( RSI_Past > RSI ){
   
    RSI_P_over++;
   
    RSI_Past_Bar++;
   
    Print( "-RSI_Past_Bar=",RSI_Past_Bar , "-RSI_Past=",RSI_Past , "-RSI_P_over=",RSI_P_over );
   
    return(RSI_P_over);}


TogoTiger 24.02.20 16:40

Hör einfach auf. Du wirst das nie lernen und nervst einfach nur.


Alle Zeitangaben in WEZ +2. Es ist jetzt 23:02 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum