The OrderEntry function actually looks like this, sorry:
void OrderEntry() { // Place order. if(OrderDirection == 0) if(OrdersTotal() == 0) OrderSend(Symbol(),OP_BUY,LOTSIZE,Ask, SLIPPAGE,Ask-(STOPLOSS*PipSize),Ask+(TAKEPROFIT*PipSize),COMMENT,MAGICNUMBER,EXPIRATION, Green); if(OrderDirection ==1) if(OrdersTotal()==0) OrderSend(Symbol(),OP_SELL,LOTSIZE,Bid, SLIPPAGE,Bid+(STOPLOSS*PipSize),Bid-(TAKEPROFIT*PipSize),COMMENT,MAGICNUMBER,EXPIRATION, Red); }
brad:
Have you looked up what PRICE_CLOSE actually means ? it's a constant, most of the "variables" in upper case are constants, it is zero. So this explains why you only have Sell trades.
The OrderEntry function actually looks like this, sorry:
- PRICE_CLOSE == 0
OrderSend(Symbol(),OP_SELL,LOTSIZE,Bid, SLIPPAGE,Bid+(STOPLOSS*PipSize), ...
- What are Function return values ? How do I use them ? - MQL4 forum
- Not adjusting for ECN brokers.
- Not adjusting for 4/5 digit brokers (SLIPPAGE)
if (NumberOfBars == Bars)
bars is unreliable, volume is unreliable, always use time.bool MACDCrossedSignal()
returns random result at end of function. No return(false)
Thanks for your comments! Very helpful.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there,
Thanks in advance.
I have this working code that in Strategy Tester detects a MACD crossover and places a trade in the relevant direction:
I want to add PSAR as the next criteria to be met and adjust the code to include this:
Strategy Tester simulates long and short trades for the working code. After I created the PSARConfirms function and called it from CheckTradingConditins function, ST only simulates short trades! When I look in the journal, the time of the bar ST should detect as a long trade isn't there!
ST should place a long trade at 2013.05.29 22.00 as both MACD and PSAR are indicating a long position but journal skips from 17:30 to 22:30.
Strangely ST appears to do the same thing in the journal with the working code but still actually simulates the code in the visual view and results sections as shown below.
How can I get ST to sim both long and short trades.
Thanks so much.