Aide au codage - page 248

 

Bonjour, mes amis. C'est un excellent indicateur Dynamic_Momentum_Index pour Thinkorswim. Il est possible de le réécrire pour Metatrader 4. Ou peut-être que quelqu'un a un tel indicateur pour MT4 ?

declare lower;input price = close;input stdevLength = 5;input avgOfStdevLength = 10;input DYMILength = 30;input DYMILengthLowerLimit = 3;input DYMILengthUpperLimit = 30;assert(DYMILengthLowerLimit > 0, "'dymi length lower limit' must be positive : " + DYMILengthLowerLimit);assert(DYMILength entre DYMILengthLowerLimit et DYMILengthUpperLimit, "'dymi length' doit être entre la limite inférieure et supérieure : " + DYMILength);def std = stdev(price, stdevLength);def ratio = std / Average(std, avgOfStdevLength);def dynamicLength = Floor(DYMILength / ratio);def limitedLength = si dynamicLength entre DYMILengthLowerLimit et DYMILengthUpperLimit then dynamicLength else 0;def sf = 2 / (limitedLength + 1);def bn = Max(barNumber(), 0) ;# précision 10^-5 pour le multiplicateur emadef expIndex = if limitedLength == 0 then 1 else max(1, bn - ceil(-5 / lg(1 - sf)));def fromIndex = if isNan(expIndex) then 1 else expIndex ;def chg = prix - prix[1];def absChg = AbsValue(chg);def netChgAvg = fold indexN = fromIndex à bn + 1 with accuN do sf * (if isnan(getValue(chg, bn - indexN)) then 0 else getValue(chg, bn - indexN)) + (1 - sf * (1 - sf) * getValue(chg, bn - indexN)) + (1 - sf) * accuN;def totChgAvg = fold indexT = fromIndex to bn + 1 with accuT do sf * (if isnan(getValue(absChg, bn - indexT)) then 0 else getValue(absChg, bn - indexT)) + (1 - sf) * accuT;def RSI = if totChgAvg != 0 and limitedLength != 0 then 50 * (netChgAvg / totChgAvg + 1) else RSI[1];plot DYMI = RSI;plot OverBought = 90;plot OverSold = 10;DYMI.DefineColor("OverBought", GetColor(5));DYMI.DefineColor("Normal", GetColor(7));DYMI.DefineColor("OverSold", GetColor(1));DYMI.AssignValueColor(if RSI > overbought then DYMI.Color("OverBought") else if RSI =OverBought, "OverBought", Alert.BAR, Sound.ring);Alert (DYMI=OverBought then high*72 else double.nan;DotDn.setStyle(curve.POINTS);DotDn.setPaintingStrategy(paintingStrategy.arROW_DOWN);DotDn.setLineWeight(3);DotDn.setDefaultColor(color.wHITE);plot DotUp = if DYMI<=OverSold then low*-2 else double.nan;Dotup.setStyle(curve.POINTS);Dotup.setPaintingStrategy(paintingStrategy.arROW_UP);Dotup.setLineWeight(3);Dotup.setDefaultColor(color.wHITE);alert(Dotup, "Scalper Buy Signal", Alert.BAR, Sound.ring);alert(DotDn, "Scalper Buy Signal", Alert.BAR, Sound.ring) ;

Dossiers :
image_4.jpg  392 kb
 
olvus:
Bonjour, mes amis. C'est un excellent indicateur Dynamic_Momentum_Index pour Thinkorswim. Il est possible de le réécrire pour metatrader 4 .... Ou peut-être quelqu'un a un tel indicateur pour MT4 ?

declare lower;input price = close;input stdevLength = 5;input avgOfStdevLength = 10;input DYMILength = 30;input DYMILengthLowerLimit = 3;input DYMILengthUpperLimit = 30;assert(DYMILengthLowerLimit > 0, "'dymi length lower limit' must be positive : " + DYMILengthLowerLimit);assert(DYMILength entre DYMILengthLowerLimit et DYMILengthUpperLimit, "'dymi length' doit être entre la limite inférieure et supérieure : " + DYMILength);def std = stdev(price, stdevLength);def ratio = std / Average(std, avgOfStdevLength);def dynamicLength = Floor(DYMILength / ratio);def limitedLength = si dynamicLength entre DYMILengthLowerLimit et DYMILengthUpperLimit then dynamicLength else 0;def sf = 2 / (limitedLength + 1);def bn = Max(barNumber(), 0) ;# précision 10^-5 pour le multiplicateur emadef expIndex = if limitedLength == 0 then 1 else max(1, bn - ceil(-5 / lg(1 - sf)));def fromIndex = if isNan(expIndex) then 1 else expIndex ;def chg = prix - prix[1];def absChg = AbsValue(chg);def netChgAvg = fold indexN = fromIndex à bn + 1 with accuN do sf * (if isnan(getValue(chg, bn - indexN)) then 0 else getValue(chg, bn - indexN)) + (1 - sf * (1 - sf) * getValue(chg, bn - indexN)) + (1 - sf) * accuN;def totChgAvg = fold indexT = fromIndex to bn + 1 with accuT do sf * (if isnan(getValue(absChg, bn - indexT)) then 0 else getValue(absChg, bn - indexT)) + (1 - sf) * accuT;def RSI = if totChgAvg != 0 and limitedLength != 0 then 50 * (netChgAvg / totChgAvg + 1) else RSI[1];plot DYMI = RSI;plot OverBought = 90;plot OverSold = 10;DYMI.DefineColor("OverBought", GetColor(5));DYMI.DefineColor("Normal", GetColor(7));DYMI.DefineColor("OverSold", GetColor(1));DYMI.AssignValueColor(if RSI > overbought then DYMI.Color("OverBought") else if RSI =OverBought, "OverBought", Alert.BAR, Sound.ring);Alert (DYMI=OverBought then high*72 else double.nan;DotDn.setStyle(curve.POINTS);DotDn.setPaintingStrategy(paintingStrategy.arROW_DOWN);DotDn.setLineWeight(3);DotDn.setDefaultColor(color.wHITE);plot DotUp = if DYMI<=OverSold then low*-2 else double.nan;Dotup.setStyle(curve.POINTS);Dotup.setPaintingStrategy(paintingStrategy.arROW_UP);Dotup.setLineWeight(3);Dotup.setDefaultColor(color.wHITE);alert(Dotup, "Scalper Buy Signal", Alert.BAR, Sound.ring);alert(DotDn, "Scalper Buy Signal", Alert.BAR, Sound.ring) ;

olvus,

Voir ce post : https://www.mql5.com/en/forum/172919/page4. Peut-être que cela aide

 

Bonjour mladen, je voudrais vous demander cette faveur.... avez-vous la possibilité de traduire ce programme pour MT4 ?

Merci quand même...

C'EST LE PROGRAMME DANS UNE AUTRE LANGUE:// var : domanda(0), offerta(0), var1(0), var2(0), indzona1 ;

// var1= ((H/C[1])-1)*V ;

// var2= ((L/C[1]-1)*V*(-1) ;

// domanda= MOV(var1,450,S) ;

// offerta= MOV(var2,450,S) ;

// indzona1= CreateWiewport(100) ;

// PlotChart(domanda, indzona1, green, solid, 1) ;

// PlotChart(offerta, indzona1, red, solid, 1) ;C'EST MON TRAVAIL POUR LA LANGUE MT4, MAIS APRÈS LA DERNIÈRE MISE À JOUR, IL NE FONCTIONNE PLUS :

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Green

#property indicator_color2 Red

#property indicator_width1 1

#property indicator_width2 1

extern int periodo=128 ;

double DOMANDA[] ;

double OFFERTA[] ;

//+------------------------------------------------------------------+

//| Fonction d'initialisation de l'indicateur personnalisé |

//+------------------------------------------------------------------+

int init()

{

IndicatorDigits(6) ;

IndicatorBuffers(2) ;

SetIndexBuffer(0,DOMANDA) ;

SetIndexBuffer(1,OFFERTA) ;

retour(0) ;

}

//+------------------------------------------------------------------+

//| Fonction personnalisée de désinitialisation de l'indicateur |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0) ;

}

//+------------------------------------------------------------------+

//| Fonction d'itération de l'indicateur personnalisée |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted() ;

int limit = Bars - counted_bars ;

double var_dom[10000] ;

double var_off[10000] ;

ArraySetAsSeries(var_dom,true) ;

ArraySetAsSeries(var_off,true) ;

for(int i=0 ; i<limit ; i++)

{

var_dom = ((High/Close)-1)*Volume ;

var_off = ((Low/Close)-1)*Volume * (-1) ;

DOMANDA = iMAOnArray(var_dom,0,periodo,0,MODE_SMA,i) ;

OFFERTA = iMAOnArray(var_off,0,periodo,0,MODE_SMA,i) ;

}

return(0) ;

}//+------------------------------------------------------------------+

 
Stephan73:
Salut mladen, je voudrais te demander cette faveur.... avez-vous la possibilité de traduire ce programme pour MT4 ?

Merci quand même...

CECI EST LE PROGRAMME EN AUTRE LANGUE:// var : domanda(0), offerta(0), var1(0), var2(0), indzona1 ;

// var1= ((H/C[1])-1)*V ;

// var2= ((L/C[1]-1)*V*(-1) ;

// domanda= MOV(var1,450,S) ;

// offerta= MOV(var2,450,S) ;

// indzona1= CreateWiewport(100) ;

// PlotChart(domanda, indzona1, green, solid, 1) ;

// PlotChart(offerta, indzona1, red, solid, 1) ;C'EST MON TRAVAIL POUR LA LANGUE MT4, MAIS APRÈS LA DERNIÈRE MISE À JOUR, IL NE FONCTIONNE PLUS :

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Green

#property indicator_color2 Red

#property indicator_width1 1

#property indicator_width2 1

extern int periodo=128 ;

double DOMANDA[] ;

double OFFERTA[] ;

//+------------------------------------------------------------------+

//| Fonction d'initialisation de l'indicateur personnalisé |

//+------------------------------------------------------------------+

int init()

{

IndicatorDigits(6) ;

IndicatorBuffers(2) ;

SetIndexBuffer(0,DOMANDA) ;

SetIndexBuffer(1,OFFERTA) ;

retour(0) ;

}

//+------------------------------------------------------------------+

//| Fonction personnalisée de désinitialisation de l'indicateur |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0) ;

}

//+------------------------------------------------------------------+

//| Fonction d'itération de l'indicateur personnalisée |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted() ;

int limit = Bars - counted_bars ;

double var_dom[10000] ;

double var_off[10000] ;

ArraySetAsSeries(var_dom,true) ;

ArraySetAsSeries(var_off,true) ;

for(int i=0 ; i<limit ; i++)

{

var_dom = ((High/Close)-1)*Volume ;

var_off = ((Low/Close)-1)*Volume * (-1) ;

DOMANDA = iMAOnArray(var_dom,0,periodo,0,MODE_SMA,i) ;

OFFERTA = iMAOnArray(var_off,0,periodo,0,MODE_SMA,i) ;

}

return(0) ;

}//+------------------------------------------------------------------+

Stephan

Voici :

Dossiers :
_stephan.mq4  2 kb
stephan.gif  61 kb
 
mladen:
Stephan Voilà :

Yeesss, parfait ! !!!

Merci beaucoup ! !!

 

m. mladen, est-il possible de réécrire l'indicateur thinkorswim en indicateur metatrader 4 (post 2474) ?

 

Bonjour à tous ,

disons que j'ai une fonction qui boucle sur tous les ordres du marché et sélectionne le dernier en utilisant lastTicket(). ensuite j'utilise ot = orderopentime() . comment puis-je obtenir la valeur de ot de sorte que je puisse utiliser la valeur de ot dans n'importe quelle autre fonction du programme. je ne veux pas appeler checko() de l'intérieur de la boucle à travers toutes les fonctions, par exemple

void checko()

{

if (ot>presetdatetime)

{

closeorder() ;

}

}

 
hermes:
Bonjour à tous ,

disons que j'ai une fonction qui boucle sur tous les ordres du marché et sélectionne le dernier en utilisant lastTicket(). ensuite j'utilise ot = orderopentime() . comment puis-je obtenir la valeur de ot de sorte que je puisse utiliser la valeur de ot dans n'importe quelle autre fonction du programme. je ne veux pas appeler checko() à partir de l'intérieur de la boucle sur toutes les fonctions, par exemple

void checko()

{

if (ot>presetdatetime)

{

closeorder() ;

}

}

hermes

Une question : par dernier ticket d'ordre, entendez-vous le plus grand (qui est généralement l'ordre le plus récent) ou le plus petit (qui est généralement l'ordre le plus ancien) ?

 
mladen:
hermes Une question : par billet de dernier ordre, entendez-vous le plus grand (qui est généralement l'ordre le plus récent) ou le plus petit (qui est généralement l'ordre le plus ancien) ?

Merci Mladen, je veux dire le plus grand qui est la commande la plus récente.

 
hermes:
Merci Mladen, je veux dire le plus grand qui est la commande la plus récente.

alors vous pouvez utiliser une fonction comme celle-ci :

void deleteGreatestTicketOrder(datetime timeLimit)

{

int largestTicketNo = -1;

for (int i=OrdersTotal()-1; i>=0; i--)

{

if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;

largestTicketNo = MathMax(largestTicketNo,OrderTicket());

}

//

//

//

//

//

if (largestTicketNo>-1 )

{

if (OrderSelect(largestTicketNo,SELECT_BY_TICKET,MODE_TRADES))

if (OrderOpenTime()>timeLimit)

OrderDelete(largestTicketNo);

}

}

PS : cela ne fait pas de différence entre les symboles ou les éventuels chiffres magiques. Si vous avez besoin de les vérifier aussi, il faut ajouter du code supplémentaire à la fonction ci-dessus.