Coding the takeprofit/stoploss
  #1 (permalink)  
Old 09-16-2005, 12:30 AM
gazuz's Avatar
Senior Trader and Moderat
 
Join Date: Aug 2004
Posts: 768
Thanks: 1
Thanked 8 Times in 5 Posts
gazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to all
Default Coding the takeprofit/stoploss

Hey everyone,

I need to add the take profit level in the code because it stops me at 5 pips max when i actually want to do 3 pips take profit (3 normal + 2 spread) I'd like to code it within so I don't get stopped by the program.

If anyone could help me that would be great, I have the code already here online,
http://forex1000.com/cnet/CCI-volatile.mql


if you just have a clip of the code could you tell me where to put it (either anywhere or beginning or end, etc., etc., etc.)

Thanks alot in advance
__________________
____________________________\¦/
___________________________(ò ó)
______________________o0o___(_)___o0o__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
Reply With Quote
  #2 (permalink)  
Old 09-17-2005, 06:32 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,992
Thanks: 125
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

Gazuz, let's fix the expert first. BelowPrevious2 and AbovePrevious2 are dummy variables (no value assigned to it). What are these two variables supposed to do here?
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
  #3 (permalink)  
Old 09-18-2005, 05:22 AM
gazuz's Avatar
Senior Trader and Moderat
 
Join Date: Aug 2004
Posts: 768
Thanks: 1
Thanked 8 Times in 5 Posts
gazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to all
Default

Oh I actually had another strategy planned with it, they were used before, they have no more use now. The expert is suppose to open a maximum of 1 trade per candle (even if the CCI indicator crosses back the 0 line). Also I want it to open the trade right when it crosses, not at the next candle.
__________________
____________________________\¦/
___________________________(ò ó)
______________________o0o___(_)___o0o__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
Reply With Quote
  #4 (permalink)  
Old 09-19-2005, 05:51 AM
gazuz's Avatar
Senior Trader and Moderat
 
Join Date: Aug 2004
Posts: 768
Thanks: 1
Thanked 8 Times in 5 Posts
gazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to allgazuz is a name known to all
Default

what should i do after this?
__________________
____________________________\¦/
___________________________(ò ó)
______________________o0o___(_)___o0o__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
___¦_____¦_____¦_____¦_____¦_____¦_____¦
¦_____¦_____¦_____¦_____¦_____¦_____¦__
Reply With Quote
  #5 (permalink)  
Old 09-19-2005, 07:27 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,992
Thanks: 125
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

Here's you go with virtual SL extra:

Code:
/*[[ Name := Gazuz CCI v2.1 Author := strategy from Gazuz, first coded by David, re-coded by Scorpion. Link := Enable Alerts := Yes Lots := 2.00 Stop Loss := 50 Take Profit := 5 Trailing Stop := 0 ]]*/ Defines : slippage(4),CCI_Period(50),Buy_Cross_Point(1),Sell_Cross_Point(-1); Defines : VirtualTP(5),VirtualSL(0); Variable : SignalStrength(0); Variable : cnt(0),i(0); Variable : CurrentCCI(0),AboveCurrent(0),BelowCurrent(0),AbovePrevious(0),BelowPrevious(0),BelowPrevious2(0),AbovePrevious2(0),; Variable : vSL(0),vTP(0),IsvSLTPHit(False); CurrentCCI=iCCI(CCI_Period,0); AboveCurrent = (CurrentCCI > (Buy_Cross_Point)); AbovePrevious = (iCCI(CCI_Period,1) > (Sell_Cross_Point)); BelowCurrent = (CurrentCCI < (Sell_Cross_Point)); BelowPrevious = (iCCI(CCI_Period,1) < (Buy_Cross_Point)); if abs(CurrentCCI)<200 then { SignalStrength=100-(abs(CurrentCCI)/2); } else { SignalStrength=0; }; Comment("Signal's Strength: ",SignalStrength,"%"); For cnt=1 to TotalTrades { If Ord(cnt,VAL_SYMBOL)=Symbol and Ord(cnt,VAL_TYPE)=OP_BUY Then { IsvSLTPHit = (Bid <= vSL and vSL > 0) or (Bid >= vTP and vTP > 0); If ((AbovePrevious2) and (BelowPrevious) and (BelowCurrent)) or IsvSLTPHit Then { CloseOrder(OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_LOTS), OrderValue(cnt,VAL_CLOSEPRICE), 0, White); vSL=0; vTP=0; Alert("CCI Expert Closed Buy Trade",".",Symbol); Exit; }; }; If Ord(cnt,VAL_SYMBOL)=Symbol and OrderValue(cnt,VAL_TYPE)=OP_SELL Then { IsvSLTPHit = (Bid >= vSL and vSL > 0) or (Bid <= vTP and vTP > 0); If ((BelowPrevious2) and (AbovePrevious) and (AboveCurrent)) or IsvSLTPHit Then { CloseOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_LOTS), Ord(cnt,VAL_CLOSEPRICE), 0, Gold); vSL=0; vTP=0; Alert("CCI Expert Closed Sell Trade",".",Symbol); Exit; }; }; }; If TotalTrades < 1 And Volume < 10 Then { If (AbovePrevious) and (BelowCurrent) Then { vTP=Bid-(VirtualTP*Point); vSL=Bid+(VirtualSL*Point); SetOrder(OP_SELL, Lots, bid, slippage, bid+StopLoss*Point, bid-TakeProfit*Point, Gold); Alert("CCI Expert Opened a Sell Trade",".",Symbol); Exit; }; If (BelowPrevious) and (AboveCurrent) Then { vTP=Bid+(VirtualTP*Point); vSL=Bid-(VirtualSL*Point); SetOrder(OP_BUY, Lots, ask, slippage, ask-StopLoss*Point, ask+TakeProfit*Point, white); Alert("CCI Expert Opened a Buy Trade",".",Symbol); Exit; }; }; For i=1 to TotalTrades { If TrailingStop<5 Then { print("Invalid trailing stop"); Exit; }; If Ord(i,VAL_SYMBOL)=Symbol and Ord(i,VAL_TYPE)=OP_BUY Then { If (Bid-Ord(i,VAL_OPENPRICE))>(TrailingStop*Point) Then { If Ord(i,VAL_STOPLOSS)<(Bid-TrailingStop*Point) Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Bid-TrailingStop*Point, Ord(i,VAL_TAKEPROFIT), White); }; }; }; If Ord(i,VAL_SYMBOL)=Symbol and Ord(i,VAL_TYPE)=OP_SELL Then { If (Ord(i,VAL_OPENPRICE)-Ask)>(TrailingStop*Point) Then { If Ord(i,VAL_STOPLOSS)>(Ask+TrailingStop*Point) Or Ord(i,VAL_STOPLOSS)=0 Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Ask+TrailingStop*Point, Ord(i,VAL_TAKEPROFIT), Gold); Exit; }; }; }; }; //------------- t_David
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
  #6 (permalink)  
Old 11-10-2007, 06:28 AM
Freshman
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
jkmforex is on a distinguished road
Default

hi,
my question may sound stupid,but thatz how everyone learns!!!!!!!!
how to use this ea code with any trading platform.please gimme step by step instructions.Will be a gr.....eat help.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dazler SAR-MA coding request dazler Trading Systems 2 06-14-2006 09:51 AM
Coding Needed plz !!!! nnjeim MetaTrader and ZeroCode 5 03-21-2006 10:37 PM
coding error? Scicronys MetaTrader and ZeroCode 1 11-07-2005 08:24 AM


All times are GMT. The time now is 06:14 AM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0

Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now

Main Menu

Economic Forecast