Help Please 4H EA

 

Hi, i got this EA from a forum as it was similar to what i wanted and thought i could learn some codeing as i changed it to what i want. well after a few weeks or month i got this far and it pretty much does what i want but now im trying to fine tune it and there is couple of things that i cant get.

CHART - 4H, AC, AO, Stoch 5,3,4

Signal - Buy = StochMain crosses StochSignal up, StochMain > 20, StochMain1 < 20, AC > AC1, AO > AO1, Buy when signal generated on current bar.

Sell = (opposite)

What i want to add here is 1 trade per 4h bar, so it wont open a new order if the signal is still valid but has closed the previous order in the same bar.

Signal - CloseBuy = StochMain crosses StochSignal down, StochMain > 50, Close @ end of bar -(not sure if this is working right)

MoveStopOnce = StochMain crosses StochSignal down, StochMain < 50, if current bid < Open Buy then close - (this not working)

TrailingStop = Start TrailingStop when bid + 50 from Open Buy - (this seems to be working ok)

Would appreciate if anyone could check over this EA and help fine tune it with me.

 
When you open a new order set lastTrade=Time[0]; ( datetime type) and then when lastTrade=Time[0] do not open a new order
 
fugi wrote >>
When you open a new order set lastTrade=Time[0]; ( datetime type) and then when lastTrade=Time[0] do not open a new order

thanks for the reply fugi, i am very new to programming and my brain is fried from reading through MLQ4 Book. I have tried a couple of times but really dont know what im doing. can you show me where to put this in the EA. Does the [0] mean current as in current bar?