2017-06-24 11 views
0

mon problème est que je veux dessiner une flèche (vert) et flèche vers le bas (rouge) en bougie haussière et bougie baissière respectivement dans toute l'histoire du tableau de monnaie spécifique ici est mon code jusqu'à présentcomment dessiner une flèche avec mql4 dans tout le graphique?

//+------------------------------------------------------------------+ 
//|             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); 
} 

mais il ne dessiner que la flèche sur la dernière barre, et je veux dans toutes les bougies de tableau grâce,

Répondre

0

dans vos fonctions DrawArrowUp() et DrawArrowDn() vous appelez la fonction MT4 ObjectCreate() qui nécessite le nom, le type d'objet, le temps et prix. puisque vous placez tous les objets sur Time[0] - peut-être vous pouvez avoir beaucoup de flèches sur la même (dernière) bougie.

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); 
} 

Plus d'options pour créer et modifier les propriétés d'une flèche se trouvent here

maintenant dans la fonction OnCalculate():

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); 
}