Proszę pomóżcie. Probowałem coś zmodzić ale...utknałem.
Zalezy mi na tym: gdy DTSOSC jest SELL/Buy aby pojawial sie na wykresie text SELL/BUY po zamknieciu swiecy na zadanym okresie, TF.
Np. Handluje na 1H- aby po nakreśleniu sie kierunku wówczas nastepowal text Buy/Sell. Nie chce ogladac wskaznika na wykresie a jedynie sam text Sell/Buy.
oto kod wskaźnika:
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_width1 2
#property indicator_width2 2
#property indicator_level1 20
#property indicator_level2 80
extern string TimeFrame = "Current time frame";
extern int PeriodRSI =13;
extern int PeriodStoch= 8;
extern int PeriodSK = 5;
extern int PeriodSD = 3;
// 0 = SMA
// 1 - EMA
// 2 - SMMA
// 3 - LWMA
extern int MAMode=0;
extern bool alertsOn = true;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true;
extern bool alertsSound = true;
extern bool alertsEmail = false;
extern string soundfile = "alert2.wav";
double SK[];
double SD[];
double StoRSI[];
double RSI[];
double cross[];
string IndicatorFileName;
int timeFrame;
bool returnBars=false;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0,SK);
SetIndexBuffer(1,SD);
SetIndexBuffer(2,StoRSI);
SetIndexBuffer(3,RSI);
SetIndexBuffer(4,cross);
if (TimeFrame == "getBarsCount")
{
returnBars=true;
return(0);
}
timeFrame = stringToTimeFrame(TimeFrame);
IndicatorShortName("DTOSC ("+PeriodRSI+","+PeriodStoch+","+PeriodSK+","+PeriodSD+")");
IndicatorFileName = WindowExpertName();
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i,limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit=Bars-counted_bars;
if (returnBars) { SK[0] = limit; return(0); }
if (timeFrame != Period())
{
limit = MathMax(limit,MathMin(Bars,iCustom(NULL,timeFrame,IndicatorFileName,"getBarsCount",0,0)*timeFrame/Period()));
for(i=0; i<limit; i++)
{
int y = iBarShift(NULL,timeFrame,Time);
SK = iCustom(NULL,timeFrame,IndicatorFileName,"",PeriodRSI,PeriodStoch,PeriodSK,PeriodSD,MAMode,0,y);
SD = iCustom(NULL,timeFrame,IndicatorFileName,"",PeriodRSI,PeriodStoch,PeriodSK,PeriodSD,MAMode,1,y);
}
return(0);
}
for(i=limit; i>=0; i--)
{
RSI = iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i);
double LLV = RSI[ArrayMinimum(RSI,PeriodStoch,i)];
double HHV = RSI[ArrayMaximum(RSI,PeriodStoch,i)];
if ((HHV-LLV)!=0)
StoRSI = 100.0*((RSI - LLV)/(HHV - LLV));
else StoRSI = 0;
}
for(i=limit; i>=0; i--) SK=iMAOnArray(StoRSI,0,PeriodSK,0,MAMode,i);
for(i=limit; i>=0; i--)
{
SD=iMAOnArray( SK,0,PeriodSD,0,MAMode,i);
cross = cross[i+1];
if (SK[i]>SD[i]) cross[i] = 1;
if (SK[i]<SD[i]) cross[i] = -1;
}
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1;
if (cross[whichBar] != cross[whichBar+1])
if (cross[whichBar] == 1)
doAlert("BUY");
ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
ObjectSetText("ObjName","BUY",53, "Verdana", Green);
ObjectSet("ObjName", OBJPROP_CORNER, 0);
ObjectSet("ObjName", OBJPROP_XDISTANCE, 10);
ObjectSet("ObjName", OBJPROP_YDISTANCE, 33);
// tu nie moge sobie poradzic....Zalezy mi na tym: gdy DTSOSC jest SELL/Buy
// aby pojawiał sie na wykresie text SELL/BUY po zamknięciu świecy na zadanym okresie, TF.
// Handluje na 15M a wskazania DTOSC potrzebuje na zamknięciu świecy z 1H- aby wowczas następował monit
// alert, text Buy/Sell. Powiecz czy jesteś wstanie zmodyfikować ten kod...lub podać wskazówkę.
doAlert("SELL");
} ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
ObjectSetText("ObjName","Sell",53, "Verdana", Red);
ObjectSet("ObjName", OBJPROP_CORNER, 0);
ObjectSet("ObjName", OBJPROP_XDISTANCE, 10);
ObjectSet("ObjName", OBJPROP_YDISTANCE, 33);
return(0);
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
void doAlert(string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Kierunek ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol()," Dtosc "),message);
if (alertsSound) PlaySound(soundfile);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int stringToTimeFrame(string tfs)
{
for(int l = StringLen(tfs)-1; l >= 0; l--)
{
int tchar = StringGetChar(tfs,l);
if((tchar > 96 && tchar < 123) || (tchar > 223 && tchar < 256))
tfs = StringSetChar(tfs, l, tchar - 32);
else
if(tchar > -33 && tchar < 0)
tfs = StringSetChar(tfs, l, tchar + 224);
}
int tf=0;
if (tfs=="M1" || tfs=="1") tf=PERIOD_M1;
if (tfs=="M5" || tfs=="5") tf=PERIOD_M5;
if (tfs=="M15"|| tfs=="15") tf=PERIOD_M15;
if (tfs=="M30"|| tfs=="30") tf=PERIOD_M30;
if (tfs=="H1" || tfs=="60") tf=PERIOD_H1;
if (tfs=="H4" || tfs=="240") tf=PERIOD_H4;
if (tfs=="D1" || tfs=="1440") tf=PERIOD_D1;
if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;
if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;
if (tf<Period()) tf=Period();
return(tf);