2. The EA is only executing one trade. Until that trade reaches TakeProfit and close, its not executing another trade when conditions are met.
So it has to open another buy trade when conditions are met despite having another open trade that has a TakeProfit and Stoploss.
Here is the full code
#include <Trade\Trade.mqh>
//Create an instance of CTrade
CTrade trade;
voidOnTick()
{
//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 pricesMqlRates PriceInfo[];
//Sort the price array from the current candle downwardsArraySetAsSeries(PriceInfo,true);
//We fill the array with price dataint PriceData =CopyRates(_Symbol,_Period,0,3,PriceInfo);
//Create a string for the signalstring signal="";
//Create 2 Arrays for Ichimoku and SMAdouble IchimokuArray[],ShiftedAverageArray[];
//we define Ichimokuint IchimokuDefinition = iIchimoku(_Symbol,_Period,9,9,52);
//we define Shifted Averageint ShiftedAverageDefinition = iMA(_Symbol,_Period,1,2,MODE_SMA,PRICE_CLOSE);
//Sort the price array from the current candle downwardsArraySetAsSeries(IchimokuArray,true);
//Sort the price array from the current candle downwardsArraySetAsSeries(ShiftedAverageArray,true);
//we fill the array with price data//Defined EA, one line, current candle for 10 candles, store in arrayCopyBuffer(IchimokuDefinition,0,0,10,IchimokuArray);
//we fill the array with price dataCopyBuffer(ShiftedAverageDefinition,0,0,10,ShiftedAverageArray);
//Buy signal//if the price is above the Tenkansenif (ShiftedAverageArray[0]<IchimokuArray[0])
//and was above the Ichimoku beforeif (ShiftedAverageArray[1]>IchimokuArray[1])
{ signal="buy"; }
//Buy 10 microlotif (signal =="buy" && PositionsTotal()<2)
trade.Buy(0.10,NULL,Ask,(Ask-1000*_Point),(Ask+500 *_Point),NULL);
//chat outputComment("The signal is now: ",signal);
Note: As a learner i was putting command and instructions so that i dont forget.
Hello. May you assist me with this Expert Advisor i am coding. I don't have programming background but i am still learning.
1. i would like to modify my TakeProfit and StopLoss.
i have put a Take profit of 150 before, now i modified it to 500 but still shows 150 once it opens a trade
I am suspecting that i may have missed something but i do not know where exactly on the code below. May you help
2. The EA is only executing one trade. Until that trade reaches TakeProfit and close, its not executing another trade when conditions are met.
So it has to open another buy trade when conditions are met despite having another open trade that has a TakeProfit and Stoploss.
Here is the full code
Note: As a learner i was putting command and instructions so that i dont forget.