Rejoindre la communauté
banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Indicateur "Expansion de Fibonacci" pour traders Manuels.

  • arka3579

    J'ai trouvé sur le web un Indicateur retracement auto de Fibo.
    Je l'ai modifier un peu a ma sauce pour en faire une Expansion FIBO, dérivé de celle intégré par défaut a MT4.

    Code
    //+------------------------------------------------------------------+ //| 2022, Jeff West/ aRka3579 | //+------------------------------------------------------------------+ #property indicator_chart_window input color LC = SteelBlue; input ENUM_LINE_STYLE LS = 2; input int LW = 1; color levelColor; int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { ObjectDelete("XIT_FIBO"); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int fibHigh = iHighest(Symbol(),Period(),MODE_HIGH,WindowFirstVisibleBar()-1,1); int fibLow = iLowest(Symbol(),Period(),MODE_LOW,WindowFirstVisibleBar()-1,1); datetime highTime = Time[fibHigh]; datetime lowTime = Time[fibLow]; if(fibHigh>fibLow) { WindowRedraw(); ObjectCreate("XIT_FIBO",OBJ_FIBO,0,highTime,High[fibHigh],lowTime,Low[fibLow]); levelColor = LC; } else { WindowRedraw(); ObjectCreate("XIT_FIBO",OBJ_FIBO,0,lowTime,Low[fibLow],highTime,High[fibHigh]); levelColor = LC; } double fiboPrice1=ObjectGet("XIT_FIBO",OBJPROP_PRICE1); double fiboPrice2=ObjectGet("XIT_FIBO",OBJPROP_PRICE2); /*double fiboPriceDiff = fiboPrice2-fiboPrice1; string fiboValue0 = DoubleToStr(fiboPrice2-fiboPriceDiff*0.0,Digits); string fiboValue23 = DoubleToStr(fiboPrice2-fiboPriceDiff*0.236,Digits); string fiboValue38 = DoubleToStr(fiboPrice2-fiboPriceDiff*0.382,Digits); string fiboValue50 = DoubleToStr(fiboPrice2-fiboPriceDiff*0.50,Digits); string fiboValue61 = DoubleToStr(fiboPrice2-fiboPriceDiff*0.618,Digits); string fiboValue100 = DoubleToStr(fiboPrice2-fiboPriceDiff*1.0,Digits);*/ ObjectSet("XIT_FIBO",OBJPROP_FIBOLEVELS,5); ObjectSet("XIT_FIBO",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSet("XIT_FIBO",OBJPROP_FIRSTLEVEL+1,0.618); ObjectSet("XIT_FIBO",OBJPROP_FIRSTLEVEL+2,1.190); ObjectSet("XIT_FIBO",OBJPROP_FIRSTLEVEL+3,1.590); ObjectSet("XIT_FIBO",OBJPROP_FIRSTLEVEL+4,2.618); ObjectSet("XIT_FIBO",OBJPROP_LEVELCOLOR,levelColor); ObjectSet("XIT_FIBO",OBJPROP_LEVELWIDTH,LW); ObjectSet("XIT_FIBO",OBJPROP_LEVELSTYLE,LS); ObjectSetFiboDescription( "XIT_FIBO",0, "Début de la Vague"); ObjectSetFiboDescription( "XIT_FIBO",1, "Niv Fibo Exp 1"); ObjectSetFiboDescription( "XIT_FIBO",2, "Niv Fibo Exp 2"); ObjectSetFiboDescription( "XIT_FIBO",3, "Niv Fibo Exp 3"); ObjectSetFiboDescription( "XIT_FIBO",4, "Niveau MAX"); return(rates_total); }

    Vous pouvez l'associer a cet Indic supplémentaire d'alertes. (A positionner sur vos niveaux Fibo)



    Code
    #property indicator_chart_window //---- input parameters extern color UpperColour = Gray; extern color LowerColour = Pink; extern int LineWidth = 2; extern string NoteDrawTrendline = "true=trendline; false=horizontal line"; extern bool DrawTrendline = true; extern string NoteSingleAlert = "true ==> only one hi/lo alert per bar"; extern bool SingleAlertMode = true; extern bool TidyOnExit = false; //---- data static int prevTime = 0; static double prevPrice; string upperName = "Upper Alert !"; string lowerName = "Lower Alert !"; double hiAlert; double loAlert; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- prevTime = Time[0]; prevPrice = ((Ask + Bid) / 2.0); double topPrice = WindowPriceMax() - (WindowPriceMax() - WindowPriceMin())*0.2; double bottomPrice = WindowPriceMax() - (WindowPriceMax() - WindowPriceMin())*0.8; if(DrawTrendline) { SetTrendlineObject(upperName, Time[30], topPrice, Time[0], topPrice, UpperColour); SetTrendlineObject(lowerName, Time[30], bottomPrice, Time[0], bottomPrice, LowerColour); } else { SetHorizlineObject(upperName, topPrice, UpperColour); SetHorizlineObject(lowerName, bottomPrice, LowerColour); } //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Avoid deleting these upper and lower alert trendlines so they are not lost if chart is reloaded (unless flag is set) if(TidyOnExit) { ObjectDelete(upperName); ObjectDelete(lowerName); } //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { string alertMsg = ""; double midPrice = ((Ask + Bid) / 2.0); static bool lowerAlertLatch = false; static bool upperAlertLatch = false; if(prevTime != Time[0]) { //Print("NewTimeFrame=", TimeToStr(Time[0])); lowerAlertLatch = false; upperAlertLatch = false; prevTime = Time[0]; } hiAlert = 0.0; if(ObjectFind(upperName) == 0) { if(DrawTrendline) hiAlert = NormalizeDouble(ObjectGetValueByShift(upperName,0),Digits); else hiAlert = NormalizeDouble(ObjectGet(upperName, OBJPROP_PRICE1),Digits); } loAlert = 0.0; if(ObjectFind(lowerName) == 0) { if(DrawTrendline) loAlert = NormalizeDouble(ObjectGetValueByShift(lowerName,0),Digits); else loAlert = NormalizeDouble(ObjectGet(lowerName, OBJPROP_PRICE1),Digits); } if(hiAlert > 0.0 && prevPrice < hiAlert && midPrice > hiAlert) { //Print("hi alert cond"); if(!upperAlertLatch || !SingleAlertMode) { alertMsg = "Upper Level " + Symbol() + " " + DoubleToStr(midPrice, Digits); Alert(alertMsg); upperAlertLatch = true; } } if(loAlert > 0.0 && prevPrice > loAlert && midPrice < loAlert) { //Print("lo alert cond"); if(!lowerAlertLatch || !SingleAlertMode) { alertMsg = "Lower Level " + Symbol() + " " + DoubleToStr(midPrice, Digits); Alert(alertMsg); lowerAlertLatch = true; } } /* * Print("mid=" + DoubleToStr( midPrice, Digits) * + " prev=" + prevPrice * + " hi=" + hiAlert * + " lo=" + loAlert); */ prevPrice = midPrice; return(0); } //+------------------------------------------------------------------+ //| SetTrendlineObject | //+------------------------------------------------------------------+ void SetTrendlineObject(string name, datetime T1, double P1, datetime T2, double P2, color colour) { if(ObjectFind(name) == -1) { ObjectCreate(name, OBJ_TREND, 0, T1, P1, T2, P2); ObjectSet(name, OBJPROP_COLOR, colour); ObjectSet(name, OBJPROP_BACK, false); ObjectSet(name, OBJPROP_WIDTH, LineWidth); } } //+------------------------------------------------------------------+ //| SetHorizlineObject | //+------------------------------------------------------------------+ void SetHorizlineObject(string name, double P1, color colour) { if(ObjectFind(name) == -1) { ObjectCreate(name, OBJ_HLINE, 0, 0, P1); ObjectSet(name, OBJPROP_COLOR, colour); ObjectSet(name, OBJPROP_BACK, false); ObjectSet(name, OBJPROP_WIDTH, LineWidth); } } //+------------------------------------------------------------------+
  • arka3579

    En image
    arka3579 a joint une image
    indicateur-expansion-de-fibonacci-pour-traders-manuels-13799