I would like to ask experienced programmers to tell me what is written incorrectly.
Now I will describe first how everything should actually work:
1) Waiting for the candle to close:
1.1) If it closed and we determined that the candle is bullish (bearish), we check 1.2
1.2) Calculate the size of the candle
1.3) Open 2 trades (1 buy,1 sell) if the candle size is equal to the specified range specified in the input parameters. (If the candle is bearish, we open a buy at 0.03 sell at 0.01, for a bullish candle, the opposite is true)
2) The logic of opening the following positions ( taking into account the fact that the candle was bearish)
2.1) Open trades buy_1 at 0.03
sell_1 by 0.01
2.2) If the buy stop loss trade is closed, we open another buy_2 trade with a double lot from the initial volume and 1 sell_2 trade with a double volume
2.3) If the sell is closed by stop loss, we do not do anything, we wait for the sell to close
2.3) If buy_2 closed on stop loss then open sell_3 volume = (buy_1+buy_2+sell_1+sell_2)
2.4) We do not take into account the closing of the stop loss, when the stop loss leads to a positive result because the trailing stop was moved
2.5) When closing any trade on takeprofit then do nothing waiting for the signal
I will attach parts of the code below .
Checking the correctness of the code
Share
barabashkakvn
It is better to immediately name the parameters so that they carry a semantic load. Instead of bars_points and bars_points_1:
minimum_size_bar and maximum_size_bar
boski
no, these are not input parameters
double bar=bars_points*_Point;
double bar_1=bars_points_1*_Point;
here is the input :
input int bars_points=120; / / maximum bar size
input int bars_points_1=80; / / minimum bar size
barabashkakvn
“bar_1” and “bar” are the input parameters of the first and second bar?
Like this:
int val_1=false;
you can’t write. It is necessary so:
bool val_1=false;
boski
Determine the type of candle and check whether it matches the range of the candle.
// getting the opening and closing difference..
bool BarsSignal_buy(int SSP=1)
{
double AvgRange;
int val=false;
AvgRange=MathAbs(iClose(SSP)-iOpen(SSP));
if(AvgRange>=bar_1 && AvgRange<=bar)//
{
if(Candle_type_sell(1))
val=true;
else
val=false;
}
return(val);
}
//+——————————————————————+
// getting the opening and closing difference..
bool BarsSignal_sell(int SSP=1)
{
double AvgRange_1;
int val_1=false;
AvgRange_1=MathAbs(iClose(SSP)-iOpen(SSP));
if(AvgRange_1>=bar_1 && AvgRange_1<=bar)// bar= 0.001
{
if(Candle_type_buy(1))
val_1=true;
else
val_1=false;
}
return(val_1);
}