Sembra che ti siano state date risposte ed esempi esaurienti, ma hai ancora bisogno di leggere l'aiuto per capire come vengono chiamate le funzioni e perché viene usato il modificatore statico.
Ecco un altro modo, forse ti sarà più facile da capire:
int N(bool reset=false) // если вызываем N() то возвращает следующее значение n++, при первом вызове n=0, но вернет 1, т.к. n=0, а затем n++, если нужно 0 то
// или staticint n=-1; или вызывайте сначала N(true)
{ // если вызываем N(true), то сбрасываем n=0 и возвращзаем 0staticint n=0;
if(reset) n=0; else n++;
return n;
}
Sembra che ti siano state date risposte ed esempi esaurienti, ma hai ancora bisogno di leggere l'aiuto per capire come vengono chiamate le funzioni e perché viene usato il modificatore statico.
Ecco un'altra variante, forse questo vi renderà più facile la comprensione:
Il primo esempio mostra una chiamata di funzione quando non viene presa nessuna posizione e il risultato restituito viene confrontato.
if( ((OpenB-Ask)/ma+TimeB/60) > N() )
Ecco perché probabilmente vale la pena di fare solo il ritorno senza azzerare e aggiungere. Che ho implementato in 2 varianti
//+------------------------------------------------------------------+//| elliotbutton.mq4 |//| Copyright 2018, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2018, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
ButtonCreate();
ButtonCreate(0,"ButtonMinor",0,10,60,50,50,CORNER_LEFT_UPPER,"(i)","Arial",12,clrBlack, C'236,233,216',clrNONE,false,false,false,false,0);
return(INIT_SUCCEEDED);
}
voidOnTick()
{
}
voidOnChartEvent(constint id,
constlong &lparam,
constdouble &dparam,
conststring &sparam)
{
if (ObjectGetInteger(0,"Button",OBJPROP_STATE,0)==true)
{
int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
if(ChartXYToTimePrice(0,x,y,window,dt,price))
{
PrintFormat("Window=%d X=%d Y=%d => Time=%s Price=%G",window,x,y,TimeToString(dt),price);
if(ChartTimePriceToXY(0,window,dt,price,x,y))
PrintFormat("Time=%s Price=%G => X=%d Y=%d",TimeToString(dt),price,x,y);
ChartRedraw(0);
}
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"i","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"ii","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"iii","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"iv","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"v","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
ObjectSetInteger(0,"Button",OBJPROP_STATE,False);
}
if (ObjectGetInteger(0,"ButtonMinor",OBJPROP_STATE,0)==true)
{
int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
if(ChartXYToTimePrice(0,x,y,window,dt,price))
{
PrintFormat("Window=%d X=%d Y=%d => Time=%s Price=%G",window,x,y,TimeToString(dt),price);
if(ChartTimePriceToXY(0,window,dt,price,x,y))
PrintFormat("Time=%s Price=%G => X=%d Y=%d",TimeToString(dt),price,x,y);
ChartRedraw(0);
}
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"(i)","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"(ii)","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"(iii)","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"(iv)","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
TextCreate(0,"Text "+string(MathRand()),0,dt,price,"(v)","Arial",10,clrBlack,0.0,ANCHOR_LEFT_UPPER,false,true,false,0);
ObjectSetInteger(0,"ButtonMinor",OBJPROP_STATE,False);
}
}
voidOnDeinit(constint reason)
{
ObjectDelete(0,"Button");
ObjectDelete(0,"ButtonMinor");
}
bool ButtonCreate(constlong chart_ID=0, // ID графика conststring name="Button", // имя кнопки constint sub_window=0, // номер подокна constint x=10, // координата по оси X constint y=10, // координата по оси Y constint width=50, // ширина кнопки constint height=50, // высота кнопки constENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // угол графика для привязки conststring text="i", // текст conststring font="Arial", // шрифт constint font_size=10, // размер шрифта constcolor clr=clrBlack, // цвет текста constcolor back_clr=C'236,233,216', // цвет фона constcolor border_clr=clrNONE, // цвет границы constbool state=false, // нажата/отжата constbool back=false, // на заднем плане constbool selection=false, // выделить для перемещений constbool hidden=false, // скрыт в списке объектов constlong z_order=0) // приоритет на нажатие мышью
{
ResetLastError();
if(ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0))
{
ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);
ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);
ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);
ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
}
return(true);
}
bool TextCreate(constlong chart_ID=0, // ID графика conststring name="Text", // имя объекта constint sub_window=0, // номер подокна datetime time=0, // время точки привязки double price=0, // цена точки привязки conststring text="Text", // сам текст conststring font="Arial", // шрифт constint font_size=10, // размер шрифта constcolor clr=clrBlack, // цвет constdouble angle=0.0, // наклон текста constENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // способ привязки constbool back=false, // на заднем плане constbool selection=true, // выделить для перемещений constbool hidden=true, // скрыт в списке объектов constlong z_order=0) // приоритет на нажатие мышью
{
ResetLastError();
if(ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price))
{
ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
}
return(true);
}
scrivere un EA che quando clicco sul pulsante, crea un testo nel posto del grafico, come mostrato dal mouse. Ora il mio Expert Advisor crea solo il testo al posto del pulsante.
Chi altro può aiutare?).
Sembra che ti siano state date risposte ed esempi esaurienti, ma hai ancora bisogno di leggere l'aiuto per capire come vengono chiamate le funzioni e perché viene usato il modificatore statico.
Ecco un altro modo, forse ti sarà più facile da capire:
Sembra che ti siano state date risposte ed esempi esaurienti, ma hai ancora bisogno di leggere l'aiuto per capire come vengono chiamate le funzioni e perché viene usato il modificatore statico.
Ecco un'altra variante, forse questo vi renderà più facile la comprensione:
Il primo esempio mostra una chiamata di funzione quando non viene presa nessuna posizione e il risultato restituito viene confrontato.
Ecco perché probabilmente vale la pena di fare solo il ritorno senza azzerare e aggiungere. Che ho implementato in 2 varianti
scrivere un EA che quando clicco sul pulsante, crea un testo nel posto del grafico, come mostrato dal mouse. Ora il mio Expert Advisor crea solo il testo al posto del pulsante.
Ciao, come faccio a fare in modo che quando trascino manualmente un ordine pendente buystop, l'altro ordine pendente sellstop si sposti con esso?
Come posso legare uno all'altro, in modo che quando ne muovo uno, li muova entrambi contemporaneamente?
Perché lo spam?
Perché lo spam?
Scrivete i vostri zecchini e metteteli nel tester di strategia.
Saluti. Puoi dirmi qual è il problema e come risolverlo?
Ho cambiato alcuni candelieri nella storia per i test, per il 1°, 2°, 3° e 6°.
Durante il test, il secondo viene elaborato, il terzo viene disegnato (senza elaborazione), e si ferma dando un errore fermato a causa di Stop Out
Buon pomeriggio
Ho una situazione molto semplice ma ho problemi a risolverla.
Per favore, ditemi cosa sto sbagliando:
problema: non riesco a legare l'indicatore personalizzato(i-DRP...) all'Expert Advisor (DR Test) tramite iCustom
grazie in anticipo