Whats Wrong
Sorry, RSI above 50 and last bar close above last 15 bars high.
phy.........didn't get your point. m just a newbie here. Can you let me what exactly I need to change in the above code. ?
Somehow its not working. I don't know how to workaround this problem.
Another question, about swapping the trade. Say a short trade at RSI<=30 is close, and instantly a long tride is triggered, unless RSI <=70.
Hi All,
whats wrong with this code. I just want to get long as the last bar closes above the last 20 bars, and RSI is above 14.
extern int Quant_Bars=15;
extern int LongRSI = 50;
extern int ShortRSI = 50;
extern double TakeProfit = 100;
extern double Lots = 1;
extern double TrailingStop = 100;
int start()
{
//----Identify the highest and lowest of the last N bars
int i,ticket; // Bar number
double Minimum=Bid, // Minimal price
Maximum=Bid; // Maximal price
for(i=0;i<=Quant_Bars-1;i++) // From zero (!) to..
{ // ..Quant_Bars-1 (!)
if (Low[i]< Minimum) // If < than known
Minimum=Low[i]; // it will be min
if (High[i]> Maximum) // If > than known
Maximum=High[i]; // it will be max
}
Alert("For the last ",Quant_Bars, // Show message
" bars Min= ",Minimum," Max= ",Maximum);
//Place Orders
if((iRSI(NULL,0,14,PRICE_CLOSE,2) <= LongRSI) && (iRSI(NULL,0,14,PRICE_CLOSE, 1) > LongRSI)&& iClose(NULL,PERIOD_H1,0)>Maximum)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
//----
return(0);
}
//+------------------------------------------------------------------+