Hi ! Can someone help my EA, i need it to open a position when the K and D lines are crossing above 20 and then close that same position when it crosses down 81, that is for the bullish positions. I also need it to open another position when the stochastic crosses down 80 and then close the position when the stochastic crosses above 21.
i tried to do it mylsef but it doesn't work well.
I add the code.
if someone can help that will be nice...
Sorry for my english, i'm french...and that's not a good excuse !
Thank you
#include<Trade\Trade.mqh>
//Create an Instance of CTrade
CTrade trade;
voidOnTick()
{
//We create a string for the signalstring signal="";
//We calculate the Ask Pricedouble Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
//We calculate the bid Pricedouble Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
//We create an array for the K-line and D-Linedouble Karray[];
double Darray[];
//Sort the array from the ccurrent candle downwardsArraySetAsSeries(Karray,true);
ArraySetAsSeries(Darray,true);
//Defined EA, Current Candle, 3 candles, Save the resultint StochasticDefinition=iStochastic(_Symbol,_Period,14,2,1,MODE_SMA,STO_LOWHIGH);
//We fill the array with price dataCopyBuffer(StochasticDefinition,0,0,4,Karray);
CopyBuffer(StochasticDefinition,1,0,4,Darray);
//We calculate the value for the current candledouble Kvalue0=Karray[0];
double Dvalue0=Darray[0];
//We calculate the value for the last candledouble Kvalue1=Karray[1];
double Dvalue1=Darray[1];
//Buy Signal //If Both value are above 20if(Kvalue0>20&&Dvalue0>20)
//if the K value has crossed the D value from aboveif((Kvalue0<Dvalue0)&&(Kvalue1>Dvalue1))
{
signal="buy";
}
//Sell Signal //If Both Values are below 81if(Kvalue0>81&&Dvalue0>81)
//If the K value Has crossed the D value From belowif((Kvalue0<Dvalue0)&&(Kvalue1>Dvalue1))
{
signal="sell";
}
//Sell 3 Microlotif(signal == "sell"&&PositionsTotal()<1)
trade.Sell(0.03,NULL,Bid,0,(Bid-100*_Point),NULL);
//Buy 3 Microlotif (signal =="buy"&& PositionsTotal()<1)
trade.Buy(0.03,NULL,Ask,0,(Ask+100*_Point),NULL);
//Create a chart output Comment("The current signal is: ",signal);
}
Hi ! Can someone help my EA, i need it to open a position when the K and D lines are crossing above 20 and then close that same position when it crosses down 81, that is for the bullish positions. I also need it to open another position when the stochastic crosses down 80 and then close the position when the stochastic crosses above 21.
i tried to do it mylsef but it doesn't work well.
I add the code.
if someone can help that will be nice...
Sorry for my english, i'm french...and that's not a good excuse !
Thank you