| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
any one know the problem here?
hi all
iam making my first indicator ![]() but ther is some thing wrong here is the code Code:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
//---- input parameters
extern int rsiPeriod = 10;
//---- buffers
double buySignal[];
double sellSignal[];
static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexBuffer(0, buySignal);
SetIndexBuffer(1, sellSignal);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
SetIndexArrow(0, 233);
SetIndexArrow(1, 234);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for (int i = Bars - IndicatorCounted(); i >= 0; i--)
{
double rsi1 = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, i+1);
double rsi2 = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, i+2);
double displacement = GetArrowDisplacement(i);
if (rsi1>40&&rsi2<40||rsi1>50&&rsi2<50)
{
buySignal[i+1] = Low[i+1] - displacement;
}
if (rsi1<50&&rsi2>50||rsi1<40&&rsi2>40)
{
sellSignal[i+1] = High[i+1] + displacement;
}
}
return(0);
}
//+------------------------------------------------------------------+
void SignalAlert(string message)
{
if (Time[0] != lastAlertTime)
{
Alert(message, Symbol(), ", ", Period(), " Minutes chart");
lastAlertTime = Time[0];
}
}
//+------------------------------------------------------------------+
double GetArrowDisplacement(int i)
{
double high = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_HIGH, i);
double low = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_LOW, i);
return ((high - low) / 2);
as you see in the pic when the RSI line across level 50 and 40 it give me two arrow!! is there is any code to solve this? ![]() |
|
|||
|
Code:
(rsi1<50&&rsi2>50||rsi1<40&&rsi2>40)
__________________
There is no candle. |
|
|||
|
i mean the problem is when rsi gives me buy signal it gives many arrows
many arrows tell me keep buy signal] i want one arrow only says to me buy. then when rsi gives sell signal i want one arrow appears only. u can notice here many arrows tell me buy i just want one arrow. i know my program is making the arrows alot i want a code or some thing to not the same arrows appears many time |
|
|||
|
thank you HerbertH
i added MA to my indicator but there is problem can you help me? the code Code:
//+------------------------------------------------------------------+
//| FX5_OmarSherif.mq4 |
//| FX5, Copyright Đ 2007 |
//| hazem@uk2.net |
//+------------------------------------------------------------------+
#property copyright "FX5, Copyright Đ 2007"
#property link "hazem@uk2.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
//---- input parameters
extern bool enableAlert = true;
//---- buffers
double buySignal[];
double sellSignal[];
static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexBuffer(0, buySignal);
SetIndexBuffer(1, sellSignal);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
SetIndexArrow(0, 233);
SetIndexArrow(1, 234);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for (int i = Bars - IndicatorCounted(); i >= 0; i--)
{
double ali1 = iRSI(NULL, 0, 21, PRICE_CLOSE, i+1);
double ali2 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE,i+1);
double ali3 = iMA(NULL, 0, 25, 0, MODE_SMA, PRICE_CLOSE,i+1);
double displacement = GetArrowDisplacement(i);
if (ali1>50&&ali2>ali3)
{
buySignal[i+1] = Low[i+1] - displacement;
if (enableAlert == true && i == 0)
SignalAlert("Buy signal On: ");
}
if (ali1<50&&ali2<ali3)
{
sellSignal[i+1] = High[i+1] + displacement;
if (enableAlert == true && i == 0)
SignalAlert("Sell signal On: ");
}
}
return(0);
}
//+------------------------------------------------------------------+
void SignalAlert(string message)
{
if (Time[0] != lastAlertTime)
{
Alert(message, Symbol(), ", ", Period(), " Minutes chart");
lastAlertTime = Time[0];
}
}
//+------------------------------------------------------------------+
double GetArrowDisplacement(int i)
{
double high = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_HIGH, i);
double low = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_LOW, i);
return ((high - low) / 2);
}
//+------------------------------------------------------------------+
|
|
||||
|
Please explain first
Quote:
Please explain what you want to achieve and then I can help or modify the code for you.
__________________
Better being out, wishing to be in than being in and wishing to be out..... |
|
||||
|
Result
Quote:
Cheers
__________________
Better being out, wishing to be in than being in and wishing to be out..... |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with .ex4................. | EFX | General Discussion | 4 | 10-21-2006 07:23 AM |
| iTime problem | danielpasono | Expert Advisors - Metatrader 4 | 3 | 07-06-2006 04:29 AM |
| Problem with BGcross EA | Andrewsurfer | Expert Advisors - Metatrader 4 | 2 | 05-26-2006 06:13 AM |
| My First EA problem | demag | Questions | 4 | 02-10-2006 08:18 AM |
| I've a Problem here | hellkas | Metatrader 4 | 6 | 11-04-2005 12:30 AM |