I have a strategy but no coding knowledge
indicators needed are
1. Moving Average Period 12, Method (Linear weighted), Apply to (Close)
2. Moving Average Period 40, Method (Linear weighted), Apply to (High)
3. Moving Average Period 40, Method (Linear weighted), Apply to (Low)
4. Commodity channel Index(CCI), Period 50, Apply to (close) Levels: (0)
5. Commodity channel Index(CCI), Period 20, Apply to (close) Levels: (100, -100, 200, -200)
6. Relative Strength Index(RSI), Period 7, Apply to (weighted Close(HLCC/4), Levels: 30, 70
7. Stochastic Oscillator %K (100), %D (100), Slowing (5), Price field (Close/Close), Method (Exponential), Levels: 20, 80
conditions for buy
1. Linear weighted Moving Average 12 closed above Linear weighted Moving average 40 Low and Linear weighted Moving average 40 High
2. RSI value must be above 70.00
3. CCI (Period 50) value must be above 0.00
4. CCI (Period 20) value must be above 100.00
5 The stochastic oscillator main line value greater than signal value
6. Buy at the closure of the candle that meet up with the 1 to 5 conditions above
7. Stop loss below the low of bull candle that meet up with the 1 to 5
8. Exit trade when RSI < 70.00, CCI (20) < 0.00, Bearish Candle formed below Moving Average 12
Condition for Sell
Will be opposite of the buying conditions
I just went through the Quick guide and got what I needed to do.....
thanks guys..... I will be back to feed you back how it got on the set file
#property indicator_chart_window
#property indicator_plots 0
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
// Define indicator handles
int ma12_handle, ma40_high_handle, ma40_low_handle, cci50_handle, cci20_handle, rsi_handle, stochastic_handle;
double ma12[], ma40_high[], ma40_low[], cci50[], cci20[], rsi[], stochastic_main[], stochastic_signal[];
double UpArrowBuffer[];
double DownArrowBuffer[];
// Define entry point function
int OnInit() {
// Initialize indicator handles
ma12_handle = iMA(NULL, 0, 12, 0, MODE_LWMA, PRICE_CLOSE);
ma40_high_handle = iMA(NULL, 0, 40, 0, MODE_LWMA, PRICE_HIGH);
ma40_low_handle = iMA(NULL, 0, 40, 0, MODE_LWMA, PRICE_LOW);
cci50_handle = iCCI(NULL, 0, 50, PRICE_CLOSE);
cci20_handle = iCCI(NULL, 0, 20, PRICE_CLOSE);
rsi_handle = iRSI(NULL, 0, 7, PRICE_WEIGHTED);
stochastic_handle = iStochastic(NULL, 0, 100, 100, 5, MODE_SMA, 1);
IndicatorBuffers(2);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 241); // Code 241 is the symbol for an up arrow
SetIndexBuffer(0, UpArrowBuffer);
SetIndexLabel(0, "Buy signal");
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 242); // Code 242 is the symbol for a down arrow
SetIndexBuffer(1, DownArrowBuffer);
SetIndexLabel(1, "Sell signal");
return(INIT_SUCCEEDED);
}
// Define the main indicator calculation
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Update indicator data
if(CopyBuffer(ma12_handle, 0, 0, rates_total, ma12) == -1 ||
CopyBuffer(ma40_high_handle, 0, 0, rates_total, ma40_high) == -1 ||
CopyBuffer(ma40_low_handle, 0, 0, rates_total, ma40_low) == -1 ||
CopyBuffer(cci50_handle, 0, 0, rates_total, cci50) == -1 ||
CopyBuffer(cci20_handle, 0, 0, rates_total, cci20) == -1 ||
CopyBuffer(rsi_handle, 0, 0, rates_total, rsi) == -1 ||
CopyBuffer(stochastic_handle, 0, 0, rates_total, stochastic_main) == -1 ||
CopyBuffer(stochastic_handle, 1, 0, rates_total, stochastic_signal) == -1)
{
Print("Failed to copy data. Error code = ", GetLastError());
return(-1);
}
// Check conditions for buy or sell
for(int i = 1; i < rates_total; i++)
{
// Buy conditions
if(ma12[i] > ma40_low[i] && ma12[i] > ma40_high[i] && rsi[i] > 70 && cci50[i] > 0 && cci20[i] > 100 && stochastic_main[i] > stochastic_signal[i])
{
Comment("Buy signal at ", time[i]);
UpArrowBuffer[i] = low[i] - 10 * Point; // Place the arrow 10 points below the low price
}
else
{
UpArrowBuffer[i] = EMPTY_VALUE;
}
// Sell conditions
if(ma12[i] < ma40_low[i] && ma12[i] < ma40_high[i] && rsi[i] < 30 && cci50[i] < 0 && cci20[i] < -100 && stochastic_main[i] < stochastic_signal[i])
{
Comment("Sell signal at ", time[i]);
DownArrowBuffer[i] = high[i] + 10 * Point; // Place the arrow 10 points above the high price
}
else
{
DownArrowBuffer[i] = EMPTY_VALUE;
}
}
return(rates_total);
}
Here is the rough code for the indicator based on your strategy, Ulises mentioned that it is better to create an indicator. The code still needs some work to fix errors to compile successfully. See if someone has time to help.