I have a strategy but no coding knowledge

Avatar
  • updated
  • Can't be answered


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

Avatar
0
jay hu
Quote from ajayi oluwaseun

i am lost totally, i understand nothing here

YouTube and Google are good tools to learn some basic functions of MT5, I also recommend you ask questions on you.com to get the information you want. It is a good start.

Avatar
0
Sai Pratap
Quote from ajayi oluwaseun

i am lost totally, i understand nothing here

It cannot be explained any better than this!

Avatar
0
ajayi oluwaseun
Quote from Ulises Cune

what a waste of time for all of us

I can learn if only steps are given....

i got the message right, I know you are not pleased with me because of all these my slow grab.

sometimes it can be more frustrating than any other thing when a teacher is trying all possible best to teach his student and he is not grabbing.... 

my question is how do I install the CP EA at first?

Avatar
0
ajayi oluwaseun

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

Avatar
1
jay hu
Quote from ajayi oluwaseun

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.

Avatar
1
jay hu
Quote from jay hu

#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.

//+------------------------------------------------------------------+

//| Moving average, CCI, RSI indicator |

//+------------------------------------------------------------------+

#property indicator_chart_window


double ma12[];

double ma40_high[];

double ma40_low[];

double cci50[];

double cci20[];

double rsi[];

double stochastic_main[];

double stochastic_signal[];

double UpArrowBuffer[];

double DownArrowBuffer[];

int OnInit()

{

SetIndexBuffer(0, UpArrowBuffer, INDICATOR_DATA);

PlotIndexSetInteger(0, PLOT_ARROW, 241); // Code 241 is the symbol for an up arrow

SetIndexLabel(0, "Buy signal");

SetIndexBuffer(1, DownArrowBuffer, INDICATOR_DATA);

PlotIndexSetInteger(1, PLOT_ARROW, 242); // Code 242 is the symbol for a down arrow

SetIndexLabel(1, "Sell signal");

return (INIT_SUCCEEDED);

}

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[])

{

ArraySetAsSeries(ma12, true);

ArraySetAsSeries(ma40_high, true);

ArraySetAsSeries(ma40_low, true);

ArraySetAsSeries(cci50, true);

ArraySetAsSeries(cci20, true);

ArraySetAsSeries(rsi, true);

ArraySetAsSeries(stochastic_main, true);

ArraySetAsSeries(stochastic_signal, true);

ArraySetAsSeries(UpArrowBuffer, true);

ArraySetAsSeries(DownArrowBuffer, true);

int ma12_period = 12;

int ma40_period = 40;

int cci50_period = 50;

int cci20_period = 20;

int rsi_period = 7;

int stochastic_period = 100;

// Rest of the code remains unchanged...

CopyClose(Symbol(), 0, 0, rates_total, ma12);

CopyHigh(Symbol(), 0, 0, rates_total, ma40_high);

CopyLow(Symbol(), 0, 0, rates_total, ma40_low);

CopyClose(Symbol(), 0, 0, rates_total, cci50);

CopyClose(Symbol(), 0, 0, rates_total, cci20);

CopyClose(Symbol(), 0, 0, rates_total, rsi);

for (int i = 0; i < rates_total; i++)

{

ma12[i] = iMA(NULL, 0, ma12_period, 0, MODE_LWMA, PRICE_CLOSE, i);

ma40_high[i] = iMA(NULL, 0, ma40_period, 0, MODE_LWMA, PRICE_HIGH, i);

ma40_low[i] = iMA(NULL, 0, ma40_period, 0, MODE_LWMA, PRICE_LOW, i);

cci50[i] = iCCI(NULL, 0, cci50_period, PRICE_CLOSE, i);

cci20[i] = iCCI(NULL, 0, cci20_period, PRICE_CLOSE, i);

rsi[i] = iRSI(NULL, 0, rsi_period, PRICE_CLOSE, i);

stochastic_main[i] = iStochastic(NULL, 0, stochastic_period, 5, MODE_SMA, 1, MODE_MAIN, i);

stochastic_signal[i] = iStochastic(NULL, 0, stochastic_period, 5, MODE_SMA, 1, MODE_SIGNAL, 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 ", TimeToString(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 ", TimeToString(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);

}

//+------------------------------------------------------------------+

Try to edit this mql.5 in here but failed. still has 20 errors, anyone who had experience may improve this indicator code.

Avatar
0
ajayi oluwaseun
Quote from jay hu

//+------------------------------------------------------------------+

//| Moving average, CCI, RSI indicator |

//+------------------------------------------------------------------+

#property indicator_chart_window


double ma12[];

double ma40_high[];

double ma40_low[];

double cci50[];

double cci20[];

double rsi[];

double stochastic_main[];

double stochastic_signal[];

double UpArrowBuffer[];

double DownArrowBuffer[];

int OnInit()

{

SetIndexBuffer(0, UpArrowBuffer, INDICATOR_DATA);

PlotIndexSetInteger(0, PLOT_ARROW, 241); // Code 241 is the symbol for an up arrow

SetIndexLabel(0, "Buy signal");

SetIndexBuffer(1, DownArrowBuffer, INDICATOR_DATA);

PlotIndexSetInteger(1, PLOT_ARROW, 242); // Code 242 is the symbol for a down arrow

SetIndexLabel(1, "Sell signal");

return (INIT_SUCCEEDED);

}

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[])

{

ArraySetAsSeries(ma12, true);

ArraySetAsSeries(ma40_high, true);

ArraySetAsSeries(ma40_low, true);

ArraySetAsSeries(cci50, true);

ArraySetAsSeries(cci20, true);

ArraySetAsSeries(rsi, true);

ArraySetAsSeries(stochastic_main, true);

ArraySetAsSeries(stochastic_signal, true);

ArraySetAsSeries(UpArrowBuffer, true);

ArraySetAsSeries(DownArrowBuffer, true);

int ma12_period = 12;

int ma40_period = 40;

int cci50_period = 50;

int cci20_period = 20;

int rsi_period = 7;

int stochastic_period = 100;

// Rest of the code remains unchanged...

CopyClose(Symbol(), 0, 0, rates_total, ma12);

CopyHigh(Symbol(), 0, 0, rates_total, ma40_high);

CopyLow(Symbol(), 0, 0, rates_total, ma40_low);

CopyClose(Symbol(), 0, 0, rates_total, cci50);

CopyClose(Symbol(), 0, 0, rates_total, cci20);

CopyClose(Symbol(), 0, 0, rates_total, rsi);

for (int i = 0; i < rates_total; i++)

{

ma12[i] = iMA(NULL, 0, ma12_period, 0, MODE_LWMA, PRICE_CLOSE, i);

ma40_high[i] = iMA(NULL, 0, ma40_period, 0, MODE_LWMA, PRICE_HIGH, i);

ma40_low[i] = iMA(NULL, 0, ma40_period, 0, MODE_LWMA, PRICE_LOW, i);

cci50[i] = iCCI(NULL, 0, cci50_period, PRICE_CLOSE, i);

cci20[i] = iCCI(NULL, 0, cci20_period, PRICE_CLOSE, i);

rsi[i] = iRSI(NULL, 0, rsi_period, PRICE_CLOSE, i);

stochastic_main[i] = iStochastic(NULL, 0, stochastic_period, 5, MODE_SMA, 1, MODE_MAIN, i);

stochastic_signal[i] = iStochastic(NULL, 0, stochastic_period, 5, MODE_SMA, 1, MODE_SIGNAL, 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 ", TimeToString(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 ", TimeToString(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);

}

//+------------------------------------------------------------------+

Try to edit this mql.5 in here but failed. still has 20 errors, anyone who had experience may improve this indicator code.

Brother, you have tried for me, hope to see someone who can help fix the errors.... I tried the SET file, it still need more fix as sometime it does not close trade and most closed trade are at negative (loss)

Avatar
0
jay hu
Quote from ajayi oluwaseun

Brother, you have tried for me, hope to see someone who can help fix the errors.... I tried the SET file, it still need more fix as sometime it does not close trade and most closed trade are at negative (loss)

Understood. I am still working on the set which can handle any market conditions as well.

Avatar
0
jay hu
Quote from jay hu

Understood. I am still working on the set which can handle any market conditions as well.

MA_CCI_RSI strategy indicator.mq5

MA_CCI_RSI strategy indicator.ex5
Avatar
0
ajayi oluwaseun

i have taken time to test the indicator but still not working..... Jay Hu, you have really tried... hoping to see some one else to help out