Gentlemen programmers, help me with creating a simple EA

 

The implementation will be quite simple, in a couple of dozen lines! I'm sure it won't take much time for experienced MQL programmers, I'm not, unfortunately. The basis of the idea is the Renko chart, the question is not of creating it, assume that it already exists and we will put the EA on it.


Input parameters:

extern int Step = 10; // size of renegotiated bar, and step for pending orders in pips

extern double Lot = 0.01; // initial lot

extern double Martin = 2.00; // Martingale ratio

int TP = Step; // Take Profit

int SL = Step; // stop loss


What the Expert Advisor should do:


First trade:


1) If bar i-1 is bearish, then

a) to buy, pending order with the price (price_open(i-1 bar)+step) with stop, profit, lot in the input parameters

b) to sell - a pending order with the price (price_close(i-1 bar)-step) with a stop, profit, lot in the input parameters


1) if the bar i-1 is bullish, then

a) to buy, a pending order with the price (price_close(i-1 bar)+step) with a stop, profit and a lot in the input parameters

b) to sell - pending order with price (price_open(i-1 bar)-step) with a stop, profit, lot in the input parameters



As soon as one of the pending orders triggers and, correspondingly, a new Renko bar with the size of Step is formed, the second one is automatically deleted and two other pending orders are opened:

1) If there was a buy trade, then

a) first BUY at (price_close(already new i-1 bar-renko)+step), i.e. at take profit price for the i-th bar with stop, profit, lot in the input parameters,

b) the second SELL at price_open(already a new i-1 bar-renko), i.e. stop loss price for the i-th bar with a stop, profit, in the input parameters, and Lot*Martin

2) If the first trade is Sell, then

a) the first SELL at (price_close(already new i-1 bar-renko)-step), i.e. at Take Profit price for the i-th bar with Stop, Profit, Lot in the input parameters,

b) the second BUY at price_open(already a new i-1 renko bar), i.e. at the stop-loss price for the i-th bar with stop, profit, in the input parameters, and Lot*Martin.


So, if option 1a or 2a is triggered (i.e. take profit), the second order is automatically deleted and everything repeats in the same loop, starting with "as soon as one of...".

If option 1b or 2b is triggered (i.e. a stop loss is triggered), the second order is automatically deleted and everything repeats in the same loop, starting with "as soon as one of..." and the Martin parameter is doubled each time until the take profit is triggered. Once the take profit is triggered, the Martin parameter is set again based on the input parameters.


I hope I've made myself clear! Thank you very much in advance!
 
By the way, here's a good question - if the Renko is "non-native" and itself created in the form of an EA (like the latest version on forexfactory), then how do I put an EA on it that will earn on it? ))
 
sashasan >>:
кстати вот хороший вопрос - если ренко "не родной" и сам создан в виде советника (как последняя версия на forexfactory), то как поставить на него советник который будет по нему зарабатывать? ))

And why shouldn't the EA trade on a standalone chart! By the way, all this can be implemented without the Renko chart, it is just for visual perception. You can set pendants anyway, taking into account the Step parameter and the result of a previous trade.

 
Stoic >>:

А почему бы советнику не торговать на автономном графике?! Кстати говоря, все это можно реализовать и без графика Ренко, он лишь для визуального восприятия. Устанавливать отложенники можно и так с учетом параметра Step и результата предыдущей сделки.

Yes, yes, that's exactly what I tried to implement long time ago, but it didn't work out... By the way, you don't even need an autonomous graph there, you can draw squares on top of the candlesticks and make all calculations on their basis

 
sashasan >>:

да-да, вот именно это я как-то давно пытался реализовать, но так толком и не получилось...

I've been following renko charts as a visual idea for a few months now. I've been trading with pens, but it's, pardon the expression, "masturbation" that's killing me. This is why I need a robot, and this idea is very good. With initial lot 0.01, 10 pips Barrenco and initial deposit about 10 000 USD the account balance would look very nice.

 

And I already have an advisor trading on a similar system,

in January it showed 67%.

 
I had 215% in January, your settings must be bad)
 
satop >>:

А у меня уже советник торгует по подобной системе,

за январь показал 67%.

Satop, hello, please! At least you're not poisoning your soul! :) I'm not asking you to put yours out there, help create such a simplest EA, you're a well-known person in certain circles, including as a programmer.

 
qwerewq >>:
а у меня 215% было за январь, наверно настройки у вас плохие)

Well... here we go!

 

Renko good by the fact that even on the smallest timeframe can seriously smooth out the trading noise, and the news alone can make a very good profit.

As for the system itself - it is not quite clear what price_close(i-1 bar) means, if there is an i then it turns out that the cycle is calculated using the past, already formed bars

 

sashasan писал(а) >>

It is not quite clear what price_close(i-1 bar) means, if there is i then it turns out that we are calculating a cycle using already formed bars

It is not price_close(i-1 bar) but plus/minus the step, i.e. size of the Renko bar. The i-th bar is not completed yet, and due to the Renko chart features, the Open price is floating up to the moment of the final formation of the i-th bar; therefore we suggest to calculate from the i-1 bar. Everything should be clear here!
Reason: