I'm facing a really strange thing, that's several days i'm on it, and well ...
Here is the thing : i create something really basic with Steve's shell.
I want to set pending order + x pips to the high of the previous candle, the thing it :
It's working with High[0] and High[2], BUT it's not working with High[1] the one that i'm interested in.
The expert says error 130 invalid stops, and that's the same stops used with High[0] and High[2]
Maybe some of our geniuses can look at it.
Here is the code :
Code: Select all
//Long
if (SendLong)
{
type=OP_BUYLIMIT;
stype = " Buy Limit ";
price = High[1] + (PipsAdjust/factor);
if (!SendAlertNotTrade)
{
stop = CalculateStopLoss(OP_BUYLIMIT, price);
take = CalculateTakeProfit(OP_BUYLIMIT, price);
//Lot size calculated by risk
if (!CloseEnough(RiskPercent, 0)) SendLots = CalculateLotSize(price, NormalizeDouble(stop + (HiddenPips / factor), Digits) );
}//if (!SendAlertNotTrade)
SendTrade = true;
Code: Select all
double CalculateStopLoss(int type, double price)
{
//Returns the stop loss for use in LookForTradingOpps and InsertMissingStopLoss
double stop;
RefreshRates();
if (type == OP_BUYLIMIT)
{
if (!CloseEnough(StopLoss, 0) )
{
stop = price - (StopLoss / factor);
HiddenStopLoss = stop;
}//if (!CloseEnough(StopLoss, 0) )
if (HiddenPips > 0 && stop > 0) stop = NormalizeDouble(stop - (HiddenPips / factor), Digits);
}//if (type == OP_BUY)