Indicator Programmer Wanted. - page 2

 
junglelion:
I used it purely to draw fibonacci levels, nothing else. Since this was my first try at writing indicators, I guess I missed out the cleanup code.

The quick ugly way to do it is simply add ObjectsDeleteAll() to the deinit(), but beware it will erase all objects from the chart.

 
Nicholishen:
The quick ugly way to do it is simply add ObjectsDeleteAll() to the deinit(), but beware it will erase all objects from the chart.

cool, since the only indicator that i use is fibonacci, this is good.

also i need to study this for sometime, designing ea at this stage would not be appropriate, but lets see.

Sad that 2molo will be a no trade day due to holidays

 

drawLine() update

Hi Folks! I see u used my function to create this indicator.

I made another one to manage with trend line instead of horizontal line, I think indicators made with this function looks more pretty.

Here it is:

void drawLine(string name,datetime tfrom, datetime tto, double pfrom, double pto, int width, int ray, color Col,int type)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_TREND, 0, tfrom, pfrom,tto,pto);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else if(type == 2)

ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOT);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,width);

ObjectSet(name,OBJPROP_RAY,ray);

}

else

{

ObjectDelete(name);

ObjectCreate(name, OBJ_TREND, 0, tfrom, pfrom,tto,pto);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else if(type == 2)

ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOT);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,width);

ObjectSet(name,OBJPROP_RAY,ray);

}

}

 
Kalenzo:
Hi Folks! I see u used my function to create this indicator. I made another one to manage with trend line instead of horizontal line, I think indicators made with this function looks more pretty.

Thanks a lot for that wonderful function.

Okay I have a queer question here, how do I list total trades for a particular symbol which are already open whether by EA or mannualy and adjust their trailing stop loss by a certain pip level everytime an event occurs, lets say if price moves 20 pips from 9140 to 9160 then move trailing SL by 20 pips also.

 
junglelion:
Thanks a lot for that wonderful function. Okay I have a queer question here, how do I list total trades for a particular symbol which are already open whether by EA or mannualy and adjust their trailing stop loss by a certain pip level everytime an event occurs, lets say if price moves 20 pips from 9140 to 9160 then move trailing SL by 20 pips also.

I use the OrderModify() function to move the stoploss. You can call this function at each incoming tick.

bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE)

Modification of characteristics for the previously opened position or pending orders. If the function succeeds, the returned value will be TRUE. If the function fails, the returned value will be FALSE. To get the detailed error information, call GetLastError() function.

Notes: Open price and expiration time can be changed only for pending orders.

If unchanged values are passed as the function parameters, the error 1 (ERR_NO_RESULT) will be generated.

Pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.

Parameters:

ticket - Unique number of the order ticket.

price - New open price of the pending order.

stoploss - New StopLoss level.

takeprofit - New TakeProfit level.

expiration - Pending order expiration time.

arrow_color - Arrow color for StopLoss/TakeProfit modifications in the chart. If the parameter is missing or has CLR_NONE value, the arrows will not be shown in the chart.

Sample:

if(TrailingStop>0)

{

OrderSelect(12345,SELECT_BY_TICKET);

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Blue);

return(0);

}

}

}
Reason: