2017-06-24 9 views
0

mein Problem ist, dass ich so weit meinen Code hierWie zeichne ich einen Pfeil mit mql4 im gesamten Diagramm?

einen Pfeil nach oben (Grün) und Pfeil nach unten (rot) in bullish Kerze und bearish Kerze jeweils in all der Geschichte der spezifischen Währung Diagramm zeichnen möge
//+------------------------------------------------------------------+ 
//|             PriceAction.mq4 | 
//|      Copyright 2017, MetaQuotes Software Corp. | 
//|            https://www.mql5.com | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2017, MetaQuotes Software Corp." 
#property link  "https://www.mql5.com" 
#property version "1.00" 
#property strict 
#property indicator_chart_window 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function       | 
//+------------------------------------------------------------------+ 
int OnInit() 
    { 
//--- indicator buffers mapping 

DrawArrowUp("up"+Bars,Close[1]+10*Point,Lime); 

//--- 
    return(INIT_SUCCEEDED); 
    } 


//+------------------------------------------------------------------+ 
//| Custom indicator iteration function        | 
//+------------------------------------------------------------------+ 
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[]) 
    { 
//--- 


//--- return value of prev_calculated for next call 
    return(rates_total); 
} 
//+------------------------------------------------------------------+ 
void DrawArrowUp(string ArrowName,double LinePrice,color LineColor) 
{ 
ObjectCreate(ArrowName, OBJ_ARROW, 0, Time[0], LinePrice); //draw an up arrow 
ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID); 
ObjectSet(ArrowName, OBJPROP_ARROWCODE, SYMBOL_ARROWUP); 
ObjectSet(ArrowName, OBJPROP_COLOR,LineColor); 
} 

void DrawArrowDown(string ArrowName,double LinePrice,color LineColor) 
{ 
ObjectCreate(ArrowName, OBJ_ARROW, 0, Time[0], LinePrice); //draw an up arrow 
ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID); 
ObjectSet(ArrowName, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN); 
ObjectSet(ArrowName, OBJPROP_COLOR,LineColor); 
} 

aber nur auf den Pfeil auf dem letzten Balken ziehen, , und ich will es in allen der Diagramm Kerzen dank,

Antwort

0

in Ihren Funktionen DrawArrowUp() und DrawArrowDn() Sie MT4 Funktion ObjectCreate() aufrufen, die Namen erfordert, Objekttyp, Zeit und Preis. da du alle Objekte auf Time[0] platzierst - vielleicht kannst du viele Pfeile auf der gleichen (letzten) Kerze haben.

const string PREFIX = "ALL_BARS_ARROWS";//to easily delete all objects in OnDeinit() 
void DrawArrow(double linePrice,datetime time,bool bullish){ 
    string name = PREFIX+"arrow"+(bullish?"up":"down")+IntegerToString(time); 
    ObjectCreate(name,OBJ_ARROW,0,time,linePrice); 
    ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); 
    ObjectSet(name, OBJPROP_ARROWCODE, bullish?SYMBOL_ARROWUP:SYMBOL_ARROWDOWN); 
    ObjectSet(name, OBJPROP_COLOR, bullish? clrLime : clrRed); 
} 

Weitere Optionen zum Erstellen und Bearbeiten Eigenschaften eines Pfeils können here

nun in der OnCalculate() Funktion zu finden:

int limit, i; 
if(prev_calculated==0){ 
    limit = rates_total-1; 
}else{ 
    limit = rates_total - prev_calculated; 
} 
bool isCandleBullish; 
for(i=limit; i>0; i--){ 
    isCandleBullish = close[i]>open[i];//think of doji candles also 
    DrawArrow(close+10*Point*(isBullish?1:-1),time[i],isCandleBullish); 
} 
Verwandte Themen