How to create a profitable strategy? - page 3

 
jowysher #:

Here are my SL/TP settings when executing buy orders.

May I ask if there are any issues with these settings?

_shiftLowPrice is the lowest price over the past few days.

for starters, when you open a buy trade you use Ask (price) and when you close a buy trade you use Bid (price). And get used to using _Point instead of the MarketInfo, or use it like this 
double pnt = MarketInfo(Symbol(),MODE_POINT);
and then use the pnt instead of MarketInfo for 2nd, 3rd time.

But looks ok to me otherwise, it is that RiskRewardRatio that is not described. I can only assume that that is the culprit.

 
Fernando Carreiro #:

Please, always use the CODE button (Alt-S) when inserting code.

Thank you for the reminder.
 
Revo Trades #:

for starters, when you open a buy trade you use Ask (price) and when you close a buy trade you use Bid (price). And get used to using _Point instead of the MarketInfo, or use it like this 
double pnt = MarketInfo(Symbol(),MODE_POINT);
and then use the pnt instead of MarketInfo for 2nd, 3rd time.

But looks ok to me otherwise, it is that RiskRewardRatio that is not described. I can only assume that that is the culprit.

Thank you for your reply.

The RiskRewardRatio variable is an Int with a value of 2.

The MarketInfo place sometimes calls a function, so for convenience of display I just repeated the writing.

So do you think it could be an issue with the trading platform?

 
jowysher #:

Here are my SL/TP settings when executing buy orders.

May I ask if there are any issues with these settings?

_shiftLowPrice is the lowest price over the past few days.

Improperly formatted code edited by moderator.

The error is your calculation. You used the MarketInfo where the price was already valid until you added the 2nd MarketInfo. Proposed changes...

double atrValue = (ATR in _Point (s));
string cmt = "TradeComment";
double stopLoss = NormalizeDouble(_shiftLowPrice - atrValue, _Digits);
double takeProfit = NormalizeDouble(Bid + (atrValue * RiskRewardRatio), _Digits);

CreateOrder(_Symbol, bs, Lots, Ask, stopLoss, takeProfit, cmt, MagicNumber);
 
Revo Trades #:

The error is your calculation. You used the MarketInfo where the price was already valid until you added the 2nd MarketInfo. Proposed changes...

Thank you for your reply. My TP is not just RRR*ATR. Below is the logic for my SL/TP, and I have previously Printed out the values (in my earlier screenshots).

I will use the example image to do the calculations. Also, correcting my RRR value to 3.

SL: Recent low - ATR value

TP: Current price + ((Current price - SL)*RRR)

[Sell Order]

OpenPrice: 145.619

SL: 146.197

TP: 145.619 - ((146.197 - 145.619)*3) = 143.885

Files:
 
jowysher #:

Thank you for your reply. My TP is not just RRR*ATR. Below is the logic for my SL/TP, and I have previously Printed out the values (in my earlier screenshots).

I will use the example image to do the calculations. Also, correcting my RRR value to 3.

SL: Recent low - ATR value

TP: Current price + ((Current price - SL)*RRR)

[Sell Order]

OpenPrice: 145.619

SL: 146.197

TP: 145.619 - ((146.197 - 145.619)*3) = 143.885

yes, i do remember seeing the original tps were correct, and the modified tps being the issue, so why do you have 2 different calculations for the tp? why now use the same calculation?

The isse you had was that you used MarketInfo(Point) 1 too many times in that math/calculation.

 
Revo Trades #: yes, i do remember seeing the original tps were correct, and the modified tps being the issue, so why do you have 2 different calculations for the tp? why now use the same calculation?

The isse you had was that you used MarketInfo(Point) 1 too many times in that math/calculation.

Do you mean not to use MarketInfo or to pull out MarketInfo for sharing? The attached file is my current implementation which has already pulled out MarketInfo for sharing and is the same as the writing approach you suggested in your previous reply. Or do I need to change to another implementation?

Image of code removed by moderator.

void DoBuySell(int bs, double sl)
{
    double pipValue = MarketInfo(Symbol(), MODE_POINT);
    double takeProfit = 0.0;

    Print("Comment:",Comment," bs:",bs," Ask:",Ask," Bid:",Bid," sl:",sl," pipValue:",pipValue);

    if (bs == 0)//buy
    {
        double stopLossPips = (Ask - sl) / pipValue;
        takeProfit = Ask + stopLossPips * RiskRewardRatio * pipValue;
        
    }

    if (bs == 1)//sell
    {
        double stopLossPips = (sl - Bid) / pipValue;
        takeProfit = Bid - stopLossPips * RiskRewardRatio * pipValue;
    }

    sl = CalculateATRStopLoss(sl, 1, bs);

    CreateOrder(bs, sl, takeProfit);
    return;
}
 
jowysher #: Do you mean not to use MarketInfo or to pull out MarketInfo for sharing? The attached file is my current implementation which has already pulled out MarketInfo for sharing and is the same as the writing approach you suggested in your previous reply. Or do I need to change to another implementation?
Please don't post images of code. Post the actual code with the the CODE button (Alt-S). You have already been advised about this.

Code button in editor

 
Fernando Carreiro #:
Please don't post images of code. Post the actual code with the the CODE button (Alt-S). You have already been advised about this.

Thank you for the reminder.

 

Thank you, everyone.

I've found the issue and I'll explain to prevent others from encountering the same problem in the future.

I had previously created a file in the 'Include' folder where I stored commonly used functions.

Yes, this also included the function for placing trades.

When multiple EAs simultaneously called for trade placements, it caused the issue I experienced.

Logically, it shouldn't have affected it, but I noticed that the Take Profit (TP) set in EUR/USD was actually based on USD/JPY prices.

Due to the significant difference in PIP values between the two, it was easy to identify.

For now, I've moved the trade placement function back into each individual EA for use. Next week, I'll observe the trade placements again.

If no issues arise, then this was indeed the reason.

Reason: