Einzelnen Beitrag anzeigen
  #3 (permalink)  
Alt 29.05.21
miortech miortech ist offline
Neues Mitglied
 
Registriert seit: May 2021
Beiträge: 9
miortech befindet sich auf einem aufstrebenden Ast
Standard

Vielleicht ist ein "predictive" Ansatz gemeint? Denn Schätzung gibt es nicht!
Hier werden 2 EMA berechnet und verglichen, welche dann ein Kauf ider Verkauf Signal abgeben
Code:
double LongPeriod=24.0;  // note that for an EMA you can have floating point numbers. 
double ShortPeriod=12.0;
double ExtraTimeForward=1.0; // how much to further extrapolate location. 
double LongPeriodx=20.0;  // note that for an EMA you can have floating point numbers. 
double ShortPeriodx=10.0;
double ExtraTimeForwardx=1.0; // how much to further extrapolate location. 

if(Predictive_Buy || Predictive_Sell){
   int counted_bars=1000;  
   
   int limit;
   double ma1,ma3;
   double p1,p3; 
   double t1,t3,t;
   double val=0;

   int limitx;
   double max1,max3;
   double px1,px3; 
   double tx1,tx3,tx;
   double valx=0;

//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   p1 = 2.0/(LongPeriod+1.0);
   p3 = 2.0/(ShortPeriod+1.0); 
   t1 = (LongPeriod-1.0)/2.0;
   t3 = (ShortPeriod-1.0)/2.0;
   t = ShortPeriod + ExtraTimeForward;
   
   ma1 = Close[limit-1];
   ma3 = ma1;
   for(int i=limit-1; i>= 0; i--) 
    val = Close[i];
    double slope1, predict;
         
    ma1 = p1*val + (1.0-p1)*ma1;
    ma3 = p3*val + (1.0-p3)*ma3;      
    slope1 = (ma3-ma1)/(t1-t3);
    predict = ma3 + slope1*t;
    
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limitx=Bars-counted_bars;
//---- main loop x
   px1 = 2.0/(LongPeriodx+1.0);
   px3 = 2.0/(ShortPeriodx+1.0);   
   tx1 = (LongPeriodx-1.0)/2.0;
   tx3 = (ShortPeriodx-1.0)/2.0;
   tx = ShortPeriodx + ExtraTimeForwardx;
   
   max1 = Close[limitx-1];
   max3 = max1;
   for(int o=limitx-1; o>= 0; o--) 
    valx = Close[o];
    double slope1x, predictx;
         
    max1 = px1*valx + (1.0-px1)*max1;
    max3 = px3*valx + (1.0-px3)*max3;     
    slope1x = (max3-max1)/(tx1-tx3);
    predictx = max3 + slope1x*tx;

if ((predict > predictx)         )

...execution
Ohne Gewähr

Gruß