Script for trailing stop needed please? - page 4

 

Move lines for SL, TP and Pending B or S

I need an indicator where I could drag and drop horizontal lines for SL, TP and Pending Orders.

Please check attached jpeg

 

Moving lines for SL, TP and pending orders

Image failed to upload on the start of thread. here it is

Files:
magic_lines.png  93 kb
 

...

Easy.ea in one of my posts...BS for buy...SS for sell

 
xtream:
Image failed to upload on the start of thread. here it is

Something close on this thread. Look for kimiv EA.

 

Percent Trailing (Trailing stop)

Hi everyone,

I am busy working on a simple exit strategy, using a percent trailing. I have previously been working with Tradestation, but then discovered Metatrader and am currently developing an EA.

Tradestation has a function SetPercentTrailing where I can pass 2 values a floor amount and a percent trailing. I am trying to reconstruct this function in EA.

So far I have put together this code:

// Trailing stop calculation

if(OrdersTotal() > 0)

{

OrderSelect(ticket, SELECT_BY_TICKET);

CurrentProfit = OrderProfit();

if (CurrentProfit >= HighestProfit)

{

HighestProfit = CurrentProfit;

}

if (HighestProfit >= (FloorAmt*Lots))

{

if ((HighestProfit - CurrentProfit) / HighestProfit) * 100 >= TrailingPct)

{

if(OrderType() == OP_BUY)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Red);

HighestProfit = 0;

}

if(OrderType() == OP_SELL)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red);

HighestProfit = 0;

}

//Print("Closing order for Trailing amount");

} }

}

How it works, is that if I am in a trade, it continuasly sets a highest profit. Now if my current profit is higher then a floor amount that I set, and my profit drops below a certain percentage of my highest profit, then I close my trade.

Logically I think that this is correct, but unfortunately it does not give me the same results as in Tradestation, and I am wondering if there is an error in my code, or if Tradestation's Trailing Percent works differently.

Any help appreciated...thanks

 

script horizontal line for S/L and T/P

I want to use horizontal line to manually move up or down for my S/L and T/P for my open trades.

Can anyone give me that script please. I don't want EA automatic Trailing Stoplosss and T/P. It 's better for me to adjust horizontal line

accordingly with price action.

Thanks for your help. I am very much appreciated

Reason: