[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 89

 

Help! Please help - there is a custom indicator that, among other things, draws Buy and Sell arrows. How to make an EA based on it???? How to make it easier - to determine whether an arrow is drawn from an EA? Or, is the indicator code made as a function of the Expert Advisor???? I am familiar with MQL. I have not found the answers to my questions there.

I am very interested in it.

 
andrey14 >> :

Help! Please help - there is a custom indicator that, among other things, draws Buy and Sell arrows. How to make an EA based on it???? How to make it easier - to determine whether an arrow is drawn from an EA? Or, is the code of the indicator made as a function of the Expert Advisor???? I am familiar with MQL. I have not found the answers to my questions there.

Help me.

https://www.mql5.com/ru/code/8524

 

Great, a ready-made advisor! I'll look into it, thank you!

 
sergeev >> :
what does it say in the log on the attempt?

says nothing

 
Mischek >> :

https://www.mql5.com/ru/code/8524

As it turns out, it's a little more complicated than that. This Expert Advisor works with indicators where arrows are allocated two indicator arrays (indicator buffers). In my indicator, the objects (arrows) are created using the ObjectCreate() method. As far as I understand, the object (arrow) is created according to time-price coordinates. I think the easiest way to make an Expert Advisor, where an indicator formula is used in a function, so to say, and positions open instead of arrows at the same conditions. How to be ??? Help!

 
andrey14 >> :

As it turns out, it's a little more complicated than that. This Expert Advisor works with indicators where arrows are allocated two indicator arrays (indicator buffers). In my indicator, the objects (arrows) are created using the ObjectCreate() method. What to do in this case? Help!

You can just transfer the code of indicator to your Expert Advisor. There, instead of the ObjectCreate() command for the arrow Buy open a Buy deal. The same way is with Sell.
 
Looked through the list of similar topics - it looks like finding an object is the only way, if not counting - to move the indicator code completely into the EA. I.e. to refuse from the indicator as such. Please advise how to make it easier. Or there are other ways?
 
LostTrader >> :
You can simply move the indicator code to the Expert Advisor. There, instead of the ObjectCreate() command for the Buy arrow, open a Buy deal. The same for Sell.

Thank you! I will do it - I think there is nothing difficult.

 

Hello

Help me out here. Bottom line. The EA only sells and closes, it works with one order. When stochastic is above 80, we can catch some loss, so I have an idea to change condition to sell if the position has closed on stop loss with isCloseLastPosByStop function from KimA. That is, it is true when the last position has closed on Stop Loss, and false when it has not, and these conditions have been entered in the selling condition. When connected, one position is opened which is closed by stoploss or not closed at all. Please tell me what is wrong in the code or how to make it look like this

i

int start()

{

int

cnt=0,

ticket,

total;

double

StochK_0, // K line value

StochD_1, // value of line D

SL=StopLoss;

bool

isCloseLastPosByStop(NULL,OP_SELL, MagicNamber); // function KimA

StochK_0=iStochastic(NULL, 0, K_per,D_per,Slow,MODE_SMA,0,MODE_MAIN, 0); // K

StochD_1=iStochastic(NULL, 0, K_per,D_per,Slow,MODE_SMA,0,MODE_MAIN, 2); //D

ticket= OrderTicket();

total=OrdersTotal();

if (total<1)

if ( isCloseLastPosByStop(NULL,OP_SELL, MagicNamber) == 0)

{

if ( (StochK_0<StochD_1) && (StochD_1 > 80) ) // 1st ist sale

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*Point,0, "My EXP", MagicNamber,0,Green); // sell

OrderSelect(0, SELECT_BY_POS);

if (OrderSelect(0, SELECT_BY_POS)==true )

Print("SELECT_BY_POS");

else

Print("failed to select error : ",GetLastError());

if((StochK_0<30)&& (StochD_1 < 30))

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);

}

else

if ( isCloseLastPosByStop(NULL,OP_SELL, MagicNamber) == 1)

{

if ((StochK_0<StochD_1) && (StochK_0 < 60) && (StochD_1 < 60) ) 2nd asses sale

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*0,0, "My EXP", MagicNamber,0,Green); //

OrderSelect(0, SELECT_BY_POS);

if (OrderSelect(0, SELECT_BY_POS)==true )

Print("SELECT_BY_POS");

else

Print("failed to select2 error : ",GetLastError());

if((StochK_0<30)&& (StochD_1 < 30)) // close condition

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);

}

return(0);

}

//___ fu ______ isCloseLastPosByStop(NULL,OP_SELL, MagicNamber)______

bool isCloseLastPosByStop(string sy="", int op=-1, int mn=-1) {

...............itd..............................

 
how to make a simple advisor from an indicator to trade on arrows??????
Reason: