Trabalho concluído
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Termos de Referência
Arrow buffer for up or down
6-8 buffers.
Strategies for open, and close are defined within enums (two dummy strategies only required for job and have set these out below for you).
The reason for including enums is so that I can add strategies for open, and for close, and select them from within the indicator. This makes life simpler.
Note, not an EA, and not for trading, simply returns an on-chart arrow for "buy", for "sell" for "buy exit" And for "sell exit", and a corresponding "buy_signal_live" and "sell_signal_live" buffer which takes either 0 or 1, and resets to 0 after the exit is signalled.
Maintains a buffer for where we are in the trades, as below:
Buffer 0 → is 0 except where open_signal returns a ‘buy_arrow’ (1 period only) below the signal candle - "buy_arrow_buffer"
Buffer 1 → is 0 unless buy_arrow is present (1 period only) [[[NOTE YOU CAN COMBINE buffers 1 and 2 into one if simplifies]]]!!!
Buffer 2 → is 0 unless ‘buy’ is currently active (more than 1 period)
Buffer 3 → is 0 unless ‘buy_exit’ is currently active (1 period only)
Buffer 4, 5, 6, 7 -as above, but for sell (note 5 and 6 can be combined into 1 buffer potentially - if it simplifies, then do it).
Input index = 1; //index candle is previous candle close (i.e. refreshes on bar open), if 0, then is current. Thjs is for when grabbing the data from buffers from handles, for the strategies
input number_of_trades_max_each_direction =
Flow is as follows:
(1) Name open strategies as an enum
(2) Name close strategies as an enum
(3) Define [indicator] handles needed for open and close strategies
(4) Define rules for open strategies which return either "buy_arrow", "sell_arrow" or "nothing_" and also associated buy_signal_binary, buy_signal_live buffers
(5) Define rules for close strategies, which return either "buy_exit_arrow", "sell_exit_arrow" or "nothing_" and associated "buy_exit_binary" and "cancel_buy_signal_live..."
Define strategies using an enum
For this code, use:
enum open_strats {
RSI_Open_Strat,
CCI_Open_Strat
}
enum close_strats {
RSI_Close_Strat,
CCI_Close_Strat
}
//Define handles needed for strategies
//Handles needed for open_RSI
If open_strats == RSI… || close_strats == RSI..
handle_RSI = iRSI(....);
if(handle_RSI == INVALID_HANDLE) → log error
Etc
if open_strats == CCI || close_strats == CCI...
handle_CCI = iCCI(etc.);
if(handle_CCI == INVALID_HANDLE) → log error
//Strategies themselves
if (open_strats == RSI_Open_Strat)
Values_Needed == 3;
Index == 1;
double bufferRSI[] = 0
Copybuffer(RSI, buffer0, index + Values_Needed-1,index); //Copy the RSI from period = index to period = ......
(or error)
//Get the data for the rules:
RSI0 = bufferRSI[index];
RSI1 = bufferRSI[index+1];
if (RSI1 < 60 && RSI0 >= 60) //Buy rule
return(Buy_Arrow)
also: buybuffer == 1 (for that period)
also: buybufferlive == 1 (continuously until exit - see below)
//Reverse for sell
if (RSI1 > 40 && RSI0 <= 40) //Buy rule
return(Buy_Arrow)
also: buybuffer == 1 (for that period)
also: buybufferlive == 1 (continuously until exit - see below)
If RSI1 > 40 && RSI0 <= 40
return(Sell_Arrow)
+ sellbuffer == 1 (for that period)
+ sellbufferlive ==1 (continuously until exit - see below)
//Same principle for CCI, but use >50 (buy), <-50 (Sell)
//Exit strategies
//Exit is the opposite
If close_strats == RSI…
if RSI0 < 40
return (exit_buy)
--> buy_exit_buffer_arrow (1 period)
+ buy_exit_buffer_binary (1 period)
+ buy_signal_live (cancel back down to 0)
if close_strats == CCI
if CCI0 < -100
return(exit_buy)
if CCI0 > 100
return(exit_sell)
+ sell_exit_buffer_arrow
+ sell_exit_buffer_binary
+ sell_signal_live (cancel back down to 0)