I'm in the making of an ea with a sort of stepma with the incredible steve's shell code.
So, i enter when the stepma changes color, but in strong trend, my orders hit the take profits, and immediately a new order open in the same direction, and i don't want that, i only want a new order when stepma changes color.
I show you the code, please can someone help me.
Thanks !
Code: Select all
//Trading decision.
bool SendLong=false,SendShort=false;
double clnow = iCustom(Symbol(),BuzzerTimeFrame,"Buzzer",Price,Length,AlertON,EmailON,0,clbar);
double clpre = iCustom(Symbol(),BuzzerTimeFrame,"Buzzer",Price,Length,AlertON,EmailON,0,clbar+1);
//Long trade
//Specific system filters
//if (some condition) SendLong = true;
if (clnow>clpre) SendLong = true;
//Usual filters
if(SendLong)
{
//User choice of trade direction
if(!TradeLong) return;
//Bob's 240 H4 ma trend filter
if (MaPeriod > 0)
if (MaTrend != up)
return;
if(UseZeljko && !BalancedPair(OP_BUY) ) return;
//Change of market state - explanation at the end of start()
//if (OldAsk <= some_condition) SendLong = false;
}//if (SendLong)
/////////////////////////////////////////////////////////////////////////////////////
if(!SendLong)
{
//Short trade
//Specific system filters
//if (some condition) SendShort = true;
if (clnow<clpre) SendShort = true;
if(SendShort)
{
//Usual filters
//User choice of trade direction
if(!TradeShort) return;
//Other filters
//Bob's 240 H4 ma trend filter
if (MaPeriod > 0)
if (MaTrend != down)
return;
if(UseZeljko && !BalancedPair(OP_SELL) ) return;
//Change of market state - explanation at the end of start()
//if (OldBid += some_condition) SendShort = false;
}//if (SendShort)
}//if (!SendLong)
////////////////////////////////////////////////////////////////////////////////////////
//DELETE THIS
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//Long
if(SendLong)
{
stype =" Buy ";
price=Ask;//Change this to whatever the price needs to be
if(!SendAlertNotTrade)
{
stop=CalculateStopLoss(OP_BUY,price);
take=CalculateTakeProfit(OP_BUY,price);
//Lot size calculated by risk
if(RiskPercent>0) SendLots=NormalizeDouble(AccountBalance() * RiskPercent/100 / 1000.0, Digits);
type=OP_BUY;
}//if (!SendAlertNotTrade)
SendTrade=true;
}//if (SendLong)
//Short
if(SendShort)
{
stype =" Sell ";
price=Bid;//Change this to whatever the price needs to be
if(!SendAlertNotTrade)
{
stop=CalculateStopLoss(OP_SELL,price);
take=CalculateTakeProfit(OP_SELL,price);
//Lot size calculated by risk
if(RiskPercent>0) SendLots=NormalizeDouble(AccountBalance() * RiskPercent/100 / 1000.0, Digits);
type=OP_SELL;
}//if (!SendAlertNotTrade)
SendTrade=true;
}//if (SendShort)
