Hi!
I want to write an expert advisoir that:
1. buy automatically when attach to chart with specific stoploss
2. when a price reaches some level, stoploss is automaticaly moved
somewhere above openprice, and in this moment trailing stop is enabled.
Tell me please what are the mistakes in my program, it doesn't even move
stoploss... Thank you and forgive me my english
I want to write an expert advisoir that:
1. buy automatically when attach to chart with specific stoploss
2. when a price reaches some level, stoploss is automaticaly moved
somewhere above openprice, and in this moment trailing stop is enabled.
Tell me please what are the mistakes in my program, it doesn't even move
stoploss... Thank you and forgive me my english
Inserted Code
bool First = True; int Tral_Stop=15; double Price, PriceOpen; double Level; int Ticket; //------------------------------------------------------------------- int init() { Ticket = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-15*Point,Bid+500*Point); if(OrderSelect(Ticket,SELECT_BY_TICKET)==true) { PriceOpen = OrderOpenPrice(); Level = PriceOpen+3*Point; } return(0); } //------------------------------------------------------- int deinit() { return(0); } //---------------------------------------------------------------- int start() { Price = Bid; string Symb=Symbol(); if (First==True) { if (Price >= Level) { OrderModify(Ticket, PriceOpen, Level, Bid+500*Point, 0); First=False; return; } else { return; } } else { OrderSelect(Ticket,SELECT_BY_TICKET); double SL=OrderStopLoss(); double TS=Tral_Stop; int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL); if (TS < Min_Dist) TS=Min_Dist; if (NormalizeDouble(SL,Digits)<NormalizeDouble(Bid-TS*Point,Digits)) { SL=Bid-TS*Point; } } return(0); }