Aide au codage - page 321

 

C'est ce que j'ai fait en essayant d'appliquer une MA au SSA directement, comme l'exemple dans mon image.

Bien sûr, je suis un vrai noob en matière de codage ...

Donc, si quelqu'un pouvait me dire ce que je dois changer, je lui en serais très reconnaissant.

J'aime résoudre les choses, même si je suis un noob en la matière, mais si quelqu'un n'essaie pas de résoudre ses problèmes, il restera un noob pour toujours ...

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

//| FullSSA.mq4 |

//| Copyright © 2007,klot |

//| klot@mail.ru |

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

#property copyright "Copyright © 2007, klot"

#property link "klot@mail.ru"

#import "libSSA.dll"

void fastSingular(double& a[],int n,int lag ,int s,double&b[]) ;

#import

#property indicateur_separate_window

#property indicator_buffers 2

#property indicator_color1 White

#property indicator_color2 Rose foncé

#property indicator_width1 3

#property indicator_level1 0.0

#property indicateur_levelstyle STYLE_DASH

#property indicator_levelcolor Magenta

extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF" ;

extern string TimeFrame = "Cadre temporel actuel" ;

extern int Lag = 10 ;

extern int NumComps = 2 ;

extern int PeriodNorm = 10 ;

extern int N = 1000 ;

extern int SSAMa_Mode = 3 ;

extern int MaPeriod = 5 ;

extern int Ma_Mode = 3 ;

extern bool Interpolate = true ;

double SSA[] ;

double ssaWork[] ;

double SSAma[] ;

double arryTimeSeries[] ;

string indicatorFileName ;

bool returnBars ;

bool calculateValue ;

int timeFrame ;

int init()

{

SetIndexBuffer(0,SSA) ; SetIndexBuffer(1,SSAma);SetIndexStyle(0,DRAW_LINE) ; SetIndexDrawBegin(0,Bars-N) ;

indicatorFileName = WindowExpertName() ;

calculateValue = (TimeFrame== "calculateValue") ; if(calculateValue) return(0) ;

returnBars = (TimeFrame=="returnBars") ; if(returnBars) return(0) ;

timeFrame = stringToTimeFrame(TimeFrame) ;

IndicatorShortName(timeFrameToString(timeFrame)+ " FullSSA normalize correct") ;

return(0) ;

}

int deinit(){return(0);}

int start()

{

double dev,ma ;

int nmax, nmin ;

int size = N ;

if (size>Bars) size = Bars ;

si (ArraySize(arryTimeSeries) != size)

{

ArrayResize(arryTimeSeries,size) ;

ArrayResize(ssaWork,size) ;

}

int limite, i ;

int counted_bars=IndicatorCounted() ;

if(counted_bars<0) return(-1) ;

si(counted_bars>0) counted_bars-- ;

limit=MathMin(Bars-counted_bars,Bars-1) ;

if (returnBars) { SSA[0] = limit+1 ; return(0) ; }

si (calculateValue || timeFrame==Period())

{

for( i=taille-1 ; i>=0 ; i--)

{

ma=iMA(NULL,0,PeriodNorm,0,MODE_SMA,PRICE_CLOSE,i) ;

dev=3*iStdDev(NULL,0,PeriodNorm,0,MODE_SMA,PRICE_CLOSE,i) ;

si(dev==0) dev=0.1 ;

arryTimeSeries=(Close-ma)/dev;//iDeMarker(NULL,0,PeriodNorm,i) ;

ObjectDelete("Sell "+Time) ;

ObjectDelete("Buy "+Time) ;

}

fastSingular(arryTimeSeries,size,Lag,NumComps,ssaWork) ;

ArrayCopy(SSA,ssaWork) ;

nmax=ArrayMaximum(SSA,3,1) ;

nmin=ArrayMinimum(SSA,3,1) ;

if(nmax==2) {

ObjectCreate("Sell "+Time[0],OBJ_ARROW,0,Time[0],Open[0]) ;

ObjectSet("Sell "+Time[0],OBJPROP_ARROWCODE,226) ;

}

if(nmin==2) {

ObjectCreate("Buy "+Time[0],OBJ_ARROW,0,Time[0],Open[0]) ;

ObjectSet("Buy "+Time[0],OBJPROP_ARROWCODE,225) ;

}

//----

retour(0) ;

}

limit =MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"", "returnBars",0,0)*timeFrame/Period())) ;

for(i=limit ; i>=0 ; i--)

for (i=limit ; i>=0 ; i--) SSAma = iMAOnArray(SSA,Bars,MaPeriod,0,Ma_Mode,i) ;

{

int y = iBarShift(NULL,timeFrame,Time) ;

SSA =iCustom(NULL,timeFrame,indicatorFileName,"", "calculateValue",Lag,NumComps,PeriodNorm,N,0,y) ;

if (timeFrame <= Period() ||y==iBarShift(NULL,timeFrame,Time)) continue ;

if (!Interpolate) continue ;

datetime time = iTime(NULL,timeFrame,y) ;

for(int n = 1 ; i+n =time ; n++) continue ;

double facteur = 1.0 / n ;

for(int x = 1 ; x < n ; x++)

{

SSA= x*facteur*SSA + (1.0-x*facteur)*SSA ;

}

}

return(0) ;

}

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

string sTfTable[] ={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200} ;

//

//

//

//

//

int stringToTimeFrame(string tfs)

{

tfs = StringUpperCase(tfs) ;

for (int i=ArraySize(iTfTable)-1 ; i>=0 ; i--)

if (tfs==sTfTable || tfs==""+iTfTable)return(MathMax(iTfTable,Period())) ;

return(Période()) ;

}

string timeFrameToString(int tf)

{

for (int i=ArraySize(iTfTable)-1 ; i>=0 ; i--)

if (tf==iTfTable) return(sTfTable) ;

return("") ;

}

//

//

//

//

//

string StringUpperCase(string str)

{

string s = str ;

for (int length=StringLen(str)-1 ; length>=0 ; length--)

{

int tchar = StringGetChar(s, length) ;

if((tchar > 96 && tchar 223 && tchar < 256))

s = StringSetChar(s, length, tchar - 32) ;

autre si(tchar > -33 && tchar < 0))

s = StringSetChar(s, length, tchar + 224) ;

}

return(s) ;

}

 
mladen:
Pour les changements de pente, essayez quelque chose comme ceci :[PHP]double current = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,0);double previous1 = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,1);double previous2 = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,2);if (current>previous1 && previous1

Merci Mladen !!, maintenant je comprends que j'ai oublié d'ajouter Extmapbuffer, numéro 2 aux conditions.

Comment serait la condition pour "while is Uptrend" acheter ou "while is Dntrend" alors vendre, comme j'ai déjà des conditions d'exécution pour les ordres, pas pour les changements de pente ?

Merci encore

Daniel

 

Cher Mladen,

J'ai besoin que la condition soit "pendant la tendance" et non pas au changement exact de la pente, j'ai donc écrit ceci mais j'ai un problème avec la tendance à la baisse, ces conditions sont-elles correctes ? Pour la tendance à la hausse, cela semble bien fonctionner... mais pour la tendance à la baisse, j'ai des problèmes... J'espère que vous pourrez m'aider, merci.

if (current>previous1)

{

// tendance à la hausse

}

if(current<previous1)

{

// tendance à la baisse CECI NE FONCTIONNE PAS ET NE DÉCLENCHE AUCUN ORDRE DE VENTE DU TOUT...

}

 
Wulong10:
C'est ce que j'ai fait en essayant d'appliquer une MA à la SSA directement, comme l'exemple dans mon image.

Bien sûr, je suis un vrai noob en matière de codage ...

Donc, si quelqu'un pouvait me dire ce que je dois changer, je lui en serais très reconnaissant.

J'aime résoudre les choses, même si je suis un noob en la matière, mais si quelqu'un n'essaie pas de résoudre ses problèmes, il restera un noob pour toujours ...

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

//| FullSSA.mq4 |

//| Copyright © 2007,klot |

//| klot@mail.ru |

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

#property copyright "Copyright © 2007, klot"

#property link "klot@mail.ru"

#import "libSSA.dll"

void fastSingular(double& a[],int n,int lag ,int s,double&b[]) ;

#import

#property indicateur_separate_window

#property indicator_buffers 2

#property indicator_color1 White

#property indicator_color2 Rose foncé

#property indicator_width1 3

#property indicator_level1 0.0

#property indicateur_levelstyle STYLE_DASH

#property indicator_levelcolor Magenta

extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF" ;

extern string TimeFrame = "Cadre temporel actuel" ;

extern int Lag = 10 ;

extern int NumComps = 2 ;

extern int PeriodNorm = 10 ;

extern int N = 1000 ;

extern int SSAMa_Mode = 3 ;

extern int MaPeriod = 5 ;

extern int Ma_Mode = 3 ;

extern bool Interpolate = true ;

double SSA[] ;

double ssaWork[] ;

double SSAma[] ;

double arryTimeSeries[] ;

string indicatorFileName ;

bool returnBars ;

bool calculateValue ;

int timeFrame ;

int init()

{

SetIndexBuffer(0,SSA) ; SetIndexBuffer(1,SSAma);SetIndexStyle(0,DRAW_LINE) ; SetIndexDrawBegin(0,Bars-N) ;

indicatorFileName = WindowExpertName() ;

calculateValue = (TimeFrame== "calculateValue") ; if(calculateValue) return(0) ;

returnBars = (TimeFrame=="returnBars") ; if(returnBars) return(0) ;

timeFrame = stringToTimeFrame(TimeFrame) ;

IndicatorShortName(timeFrameToString(timeFrame)+ " FullSSA normalize correct") ;

return(0) ;

}

int deinit(){return(0);}

int start()

{

double dev,ma ;

int nmax, nmin ;

int size = N ;

if (size>Bars) size = Bars ;

si (ArraySize(arryTimeSeries) != size)

{

ArrayResize(arryTimeSeries,size) ;

ArrayResize(ssaWork,size) ;

}

int limite, i ;

int counted_bars=IndicatorCounted() ;

if(counted_bars<0) return(-1) ;

si(counted_bars>0) counted_bars-- ;

limit=MathMin(Bars-counted_bars,Bars-1) ;

if (returnBars) { SSA[0] = limit+1 ; return(0) ; }

si (calculateValue || timeFrame==Period())

{

for( i=taille-1 ; i>=0 ; i--)

{

ma=iMA(NULL,0,PeriodNorm,0,MODE_SMA,PRICE_CLOSE,i) ;

dev=3*iStdDev(NULL,0,PeriodNorm,0,MODE_SMA,PRICE_CLOSE,i) ;

si(dev==0) dev=0.1 ;

arryTimeSeries=(Close-ma)/dev;//iDeMarker(NULL,0,PeriodNorm,i) ;

ObjectDelete("Sell "+Time) ;

ObjectDelete("Buy "+Time) ;

}

fastSingular(arryTimeSeries,size,Lag,NumComps,ssaWork) ;

ArrayCopy(SSA,ssaWork) ;

nmax=ArrayMaximum(SSA,3,1) ;

nmin=ArrayMinimum(SSA,3,1) ;

if(nmax==2) {

ObjectCreate("Sell "+Time[0],OBJ_ARROW,0,Time[0],Open[0]) ;

ObjectSet("Sell "+Time[0],OBJPROP_ARROWCODE,226) ;

}

if(nmin==2) {

ObjectCreate("Buy "+Time[0],OBJ_ARROW,0,Time[0],Open[0]) ;

ObjectSet("Buy "+Time[0],OBJPROP_ARROWCODE,225) ;

}

//----

retour(0) ;

}

limit =MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"", "returnBars",0,0)*timeFrame/Period())) ;

for(i=limit ; i>=0 ; i--)

for (i=limit ; i>=0 ; i--) SSAma = iMAOnArray(SSA,Bars,MaPeriod,0,Ma_Mode,i) ;

{

int y = iBarShift(NULL,timeFrame,Time) ;

SSA =iCustom(NULL,timeFrame,indicatorFileName,"", "calculateValue",Lag,NumComps,PeriodNorm,N,0,y) ;

if (timeFrame <= Period() ||y==iBarShift(NULL,timeFrame,Time)) continue ;

if (!Interpolate) continue ;

datetime time = iTime(NULL,timeFrame,y) ;

for(int n = 1 ; i+n =time ; n++) continue ;

double facteur = 1.0 / n ;

for(int x = 1 ; x < n ; x++)

{

SSA= x*facteur*SSA + (1.0-x*facteur)*SSA ;

}

}

return(0) ;

}

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

string sTfTable[] ={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200} ;

//

//

//

//

//

int stringToTimeFrame(string tfs)

{

tfs = StringUpperCase(tfs) ;

for (int i=ArraySize(iTfTable)-1 ; i>=0 ; i--)

if (tfs==sTfTable || tfs==""+iTfTable)return(MathMax(iTfTable,Period())) ;

return(Période()) ;

}

string timeFrameToString(int tf)

{

for (int i=ArraySize(iTfTable)-1 ; i>=0 ; i--)

if (tf==iTfTable) return(sTfTable) ;

return("") ;

}

//

//

//

//

//

string StringUpperCase(string str)

{

string s = str ;

for (int length=StringLen(str)-1 ; length>=0 ; length--)

{

int tchar = StringGetChar(s, length) ;

if((tchar > 96 && tchar 223 && tchar < 256))

s = StringSetChar(s, length, tchar - 32) ;

autre si(tchar > -33 && tchar < 0))

s = StringSetChar(s, length, tchar + 224) ;

}

return(s) ;

}

Wulong10

Je ne vois pas l'image

Pourriez-vous la joindre ?

 

J'avais déjà posté l'image, mais la voici à nouveau.

Donc, quand je prends une MA de MT4 et que je l'applique au SSA (appliquer aux premières données ind.), la MA semble correcte, quand j'ouvre MT4, mais quand elle fonctionne en temps réel, elle ne suit plus le SSA.

Cela ne se produit que sur M1, sur le M5 il fonctionne sans problème.

L'image devrait l'expliquer visuellement.

Merci.

Dossiers :
ssa.png  72 kb
 
Wulong10:
J'avais déjà posté l'image, mais la voici à nouveau.

Donc, quand je prends une MA de MT4 et que je l'applique au SSA (appliquer aux premières données ind.), la MA semble correcte, quand j'ouvre MT4, mais quand elle fonctionne en temps réel, elle ne suit plus le SSA.

Cela ne se produit que sur M1, sur le M5 il fonctionne sans problème.

L'image devrait l'expliquer visuellement.

Merci.

N'oubliez pas que le SSA recalcule. Si vous ne calculez pas la MA de toutes les barres SSA qui sont recalculées, il cessera de suivre le SSA.

 

Ok, maintenant je comprends, pourquoi cela fonctionne sur la M5, c'est parce que j'ai réglé la période de la MA là sur 1 et sur la M1 je l'ai réglé sur 2 ....Cela devrait résoudre le problème. Je l'ai testé sur ma simulation de trading, ce n'est pas parfait, mais beaucoup mieux !

Avec la période 1, la MA devrait suivre le SSA.

Mais comment puis-je incorporer une MA directement dans le code du SSA ? Et cela devrait aussi recalculer toutes les barres du SSA.... ou ce n'est pas possible ?

 
Wulong10:
Ok, maintenant je comprends, pourquoi cela fonctionne sur la M5, c'est parce que j'ai réglé la période de la MA là sur 1 et sur la M1 je l'ai réglé sur 2 ....Cela devrait résoudre le problème. Je l'ai testé sur ma simulation de trading, ce n'est pas parfait, mais beaucoup mieux !

Avec la période 1, la MA devrait suivre le SSA.

Mais comment puis-je incorporer une MA directement dans le code du SSA ? Et cela devrait aussi recalculer toutes les barres du SSA.... ou ce n'est pas possible ?

Wulong10

Pouvez-vous s'il vous plaît poster votre fichier mq4 aussi (copier du texte à mql provoque presque toujours quelques problèmes) ?

 

Peu importe la dernière demande

Voici une version avec une moyenne mobile ajoutée : ssa__ma.mq4

Dossiers :
ssa__ma.mq4  5 kb
ssa__ma.gif  75 kb
 

Ok, merci Mladen, tu es le meilleur !

Je n'ai pas le temps de le tester maintenant, c'est à pied ce soir, je vous ferai part du résultat ...quand le temps sera venu.

Maintenant je peux aussi voir comment j'aurais dû faire, donc je serai 0,5 % moins nul après l'avoir étudié.

Raison: