Hi NeoTrader,
NeoTrader wrote:Hi Radar,
i think you get here some things mixed up... break even is when the current price passes your entry price in your favor. this means as soon as you see a 0 or a positive value in your profit you are break even.
e.g. if ( currentPrice > entryPrice ) breakeven; for a long position
if ( currentPrice < entryPrice ) breakeven; for a short position
Or did i just misunderstand you?
happy trading,
NeoTrader
That much I figured out, thanks
A lot of EA's ask for "BreakEvenPips" in their settings, and I would just guess what to put in there... I suppose I could put the spread plus 1 pip, but with brokers that have variable spreads, you could end up being a bit short... The biggest spread I've seen with my broker was 13.5 pips:(
Am I wrong in thinking that break-even can be set by simply getting the spread at the time of opening a trade, and setting BreakEvenPips to that? Or maybe adding 1 pip to the spread, and setting that as breakeven? How to pass the spread (or spread + ?) from the open trade routine to the breakeven routine, though? Global variable? Write it in the comment, then read it in the breakeven routine? Either of those, or just set a maximum spread. and use that as your breakeven?
By doing something like...
Code: Select all
double Spread = (MarketInfo(OrderSymbol(), MODE_SPREAD);
...And setting that as a global variable, just before or after sending an order, you could pull that into your breakeven routine.
Now, if the above works, or can be made to work, we no longer have to have BE in the setfile, as it's calculated at the time of each trade, so you can just have BreakEvenProfit in the setfile, and add, (since I don't know how to set GV's and read them, I've just called it "GVSpread")...
Code: Select all
if (BreakEvenProfit >0)
{
double BreakEven = (GVSpread + (point*BreakEvenProfit)); //Incorrect code, but you get the picture, I hope ;)
}
...Well, I hope it's that easy

I copied the breakeven code from MPTM, added a check for StopLevel to stop Error:130's, (Cowboy IBFX has a StopLevel of 0, so Steve never sees errors caused by this) and just put "GVSpread" where the proper code should go.
Code: Select all
void BreakEvenStopLoss() // Move stop loss to breakeven
{
if (!BreakEven) return(0); // User has not chosen this option, so abort
int ticket;
double StopLevel = MarketInfo(OrderSymbol(), MODE_STOPLEVEL);
double BreakEvenPoints = GVSpread; // I don't know the code to pull a global variable, so this needs fixing
if (BreakEvenProfit >0)
{
BreakEvenPoints = (GVSpread + (BreakEvenProfit*point)); //Incorrect code, but you get the picture, I hope ;)
}
if (OrderType()==OP_BUY)
{
if ((bid - StopLevel) >= (OrderOpenPrice() + BreakEvenPoints) &&
(OrderStopLoss()<OrderOpenPrice()|| OrderStopLoss()==0))
{
ticket = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() + BreakEvenPoints,OrderTakeProfit(),0,CLR_NONE);
if (ticket>0 && ShowAlerts==true) Alert("Breakeven set on ", OrderSymbol(), " ticket no ", OrderTicket());
}
}
if (OrderType()==OP_SELL)
{
if ((ask + StopLevel) <= (OrderOpenPrice() - BreakEvenPoints) &&
(OrderStopLoss()>OrderOpenPrice()|| OrderStopLoss()==0))
{
ticket = OederModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() - BreakEvenPoints,OrderTakeProfit(),0,CLR_NONE);
if (ticket>0 && ShowAlerts==true) Alert("Breakeven set on ", OrderSymbol(), " ticket no ", OrderTicket());
}
}
} // End BreakevenStopLoss sub
My guess is that some brokers will be using points for stoplevel, whist others will be using pips, just to add to the confuzzlement, though.
Is any of this making sense, or am I in lala land?
Take care,
&
Have fun!
Radar =8^)