ORDERS .:. Question for experienced programmers

 

Hello,



Based on indicators: RSI, the WPR% and Stochastic I intend to write an investment strategy (EA) which will open purchase and sale orders according to the generated signals by the indicators.



Levels stoploss and takeprofit should be defined in the program, so that when opening up their orders levels were not apparent in the system, but that strategy should constantly monitored them. For example:

Rsi indicators, Stochastic and WPR% generated a signal to buy. There is opened a new order BUY, but in the levels of stoploss and takeprofit amount to 0 (on the Forex, interbank system), while the programmed levels in the strategy shall be: 20, 40. So let's buy 0.1 Lot (volume) at a price of 0.1234. In a stoploss = 0, takeprofit = 0, but programmed them accordingly at stoploss = 20, takeprofit = 40 When the rate reaches 0.1214 strategy then closes the order because he registered a level of stoploss = 0.1234-(20 points), in the event that if the course 0.1274 was the first to reach then carried out by profit.

Question:

How to program hidden stoploss and takeprofit (showed on the system as 0, but programmed as the other value for example: 20, 40) and how to constantly monitor opened orders and close them if the current rate obtain the programmed stoploss or takeprofit?



Remark: quantity = 0.1 Lots always...



Regards,

Puncher





 
well...I guess you gotta write the S/L and T/P to a file since if you just save them to memory you lose them after closing MT4. So just write them to a file and read them in onc ewhen you start MT4 and then constantly (on every tick in EA, or in infinte loop in Script) check the current price if it hits T/P or S/L.
 
Ok but how to do it?
 

Puncher

You raise a very interesting subject - i.e. do we leave SL & TP values off our orders to prevent any possible stop hunting by brokers...?

I could code this into an EA but choose not to because:-

1) This creates a dependency for 100% guaranteed connectivity for the EA (IMHO neither wise nor realistic)

2) News events can prevent an OrderModify or Close succeeding at all, where a pre-set SL or TP would work, ok maybe with a gap, but it would normally kick in

3) Institutional market-movers will always be more of a risk to your stop losses than your broker, the MM's can move price as far as they want in quiet or moderate conditions - so you will have to set levels, concealed or not, and these guys will have a good idea where they are & do the necessary :(

--

Re your strategy - you're heavy on the oscillators, but dont forget time of day (for the pair), current volatility & long-term trend assessment.

Also choice of effective oscillator/s can be very pair-specific...

--

My 2c worth

-BB-

 

Hi BarrowBoy


Probably a better idea would be to define trailingstop and trailingprofit instead stoploss and takeprofit ... Is there something like this to be done? How to approach this?

And this raises another question: how to close opened roders to be able to further open another one (if confirmed by the signals of the rsi, wpr% & stochastic indicators)?


Regards,

Puncher

Reason: