Einzelnen Beitrag anzeigen
  #11 (permalink)  
Alt 19.05.20
berndao berndao ist offline
Neues Mitglied
 
Registriert seit: May 2020
Beiträge: 18
berndao befindet sich auf einem aufstrebenden Ast
Standard

Ich will ja auch gar nichts gesagt haben :-)

Ich glaube, so langsam kriege ich den Dreh raus.
Habe mir mal einen EA gebaut, der guckt ob für 5 hintereinanderfolgende Balken sich der Abstand von oberer Linie zu Mittellinie koninuierlich verringert :-)

Sowie eine Funktion, die mir bei jedem balken anzeigt wie sich prozentual der Abstand verändert hat :-)


Code:
//+------------------------------------------------------------------+
//|                                                        Test3.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

datetime LastActiontime;


bool BBcontract(){
   for(int i=1;i<=5;i++){
      double Band_Highcur = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,i);
      double Band_Modecur = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_MAIN,i);
      double Band_Highprev = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,i+1);
      double Band_Modeprev = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_MAIN,i+1);
   
     if((Band_Highprev-Band_Modeprev)*0.98<(Band_Highcur-Band_Modecur)){
       return false;
     }
  }
  return true; 
}


double BBContpercent(){

      double Band_Highcur = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,1);
      double Band_Modecur = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_MAIN,1);
      double Band_Highprev = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,2);
      double Band_Modeprev = iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_MAIN,2);
   
      return ((Band_Highcur-Band_Modecur) /(Band_Highprev-Band_Modeprev)); 
}


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
  Print("Start Time is= ",TimeCurrent());
  LastActiontime=Time[1];
  //Print("die Zahl ",1.23456789," gerundet auf die ",_Digits,"te Nachkommastelle ergibt ", roundD(1.23456789));
  Print("");
  //Print( DoubleToString(Wert, _Digits) );
   
//---
   return(INIT_SUCCEEDED);
  }
  
  
  
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick() {
  if(LastActiontime==Time[1]){
    return;
  }
  else
  {
     LastActiontime=Time[1];
  }
   
  //Print("Last Bar Time is= ",Time[1], "and last Close Price is= ",DoubleToString(Close[1],_Digits));
  Print("At the previous Bar, are the Bollinger Bands contracting? ", BBcontract() );
  Print("by how much compared to the previous bar? ", DoubleToString(BBContpercent(),2));
  Print("");
  
//+------------------------------------------------------------------+
}





//Round a double number down to the last visible digit
double roundD(double number){
  double n=number*MathPow(10,_Digits);
  int b=MathRound(n);
  double c=b;
  double result=c/MathPow(10,_Digits);
  return result;

}